Sign in to follow this  

terrain

This topic is 3624 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am completely confused about what games do to create terrain. I am using directx/c++ and have tried terrain generators with confusing results. If i want to create a simple terrain with a few hills or curved ground do i create this myself with about 100 triangles, or use a terrain generator or what is a common way?

Share this post


Link to post
Share on other sites

Hi,

There are several ways of doing terrain, after all, terrain is just another model in your 3d-space, it just happens to be rather big. Some games where the terrain areas are rather small it is totally ok to create a 3D triangle model with a modelling program.

However, there are few point to consider when creating terrains.

- Usually it is easier to edit the terrain using a height map or map contour curves than triangle soup

- a huge terrain modelled as triangle mesh might take insane amount of memory compared to the stored/packed height map

- a terrain using height map is one way of optimizing the memory usage. The idea is based on the fact that most of the time terrains are rather flat and don't have complex shapes. Of course, as a trade off, you'll loose the ability to integrate caves and cliffs easily to the terrain.

Can you tell what kind of confusion you are facing?

Best regards!

Share this post


Link to post
Share on other sites
i am having massive problems using software to create a heightmap and load into directx/c++ as a raw file. I only have an example of heightmaps and raw files which is hard enough. I dont have examples of other file types to load in.

I use terragen.9 but there is a bug in the raw file export. SO i use world machine and i create a raw file but directx loads it and i get a mess!

I dont know what information i need to use a raw file into directx ?I know vertice nuber 128X128 and colors for height terrains.

I need this for directx to understand the raw file
number of vertices per row and column, cell spacing and height scale which i have no idea of how to get from a raw file?

Share this post


Link to post
Share on other sites
When you save the .RAW file, make sure that you save it without header information (or if you want the header (and you probably don't), the loading code should take that into account).

Also, if you just want to make sure that your code works, use an existing heightmap (you can find lots of those with google, usually attached to tutorials that show how to load then), and later worry about creating your own.

Share this post


Link to post
Share on other sites
You can also use photoshop to create RAW files. Create a new file, and specify the width and height you would like (i think by default you need to hard code the height and width into the terrain generator youre using, as theres no header in the RAW file).

Then specify color mode as greyscale - 8 bit. You can then draw your heightmap using all the tools photoshop has to offer.

When your done, file > save as, then specify from the format drop down menu, "Photoshop RAW". Then click save. A box will pop up asking you if you would like to specify a header, say no (or set header to 0). And you're done!

Share this post


Link to post
Share on other sites
ok i found world machine which creates raw files heightmaps. i load into some c++ code with size and spacing and it works.

I dont get an option for without header information but it works.

q)My problem is now a 256X256 with a few hills isnt that big. How can i make a bigger terrain or maybe put together 2 terrain maps?

q)I can use the tutorial code and understand important parts but is it necessary to understand the whole 500lines of code , as there is many calculations? I know what the parts are doing and what to change to make things work but i couldnt write it again off the top of my head.

Share this post


Link to post
Share on other sites
It's actually very simple.
Create a structure that holds you image data, then load your heightmaps into that!

(Pseudo code)



struct Terrain
{
char data[256][256];
point2d pos;

void render();
};

Terrain terrain1,
terrain2;

void load(image,terraindata)
{
image.loadInto(terraindata);
}

void main()
{
load(terrain1.wan, terrain1.data);
load(terrain2.wan, terrain2.data);
}

void render()
{
setPos(terrain1)
terrain1.render()
setPos(terrain2)
terrain2.render()
}



Share this post


Link to post
Share on other sites
Quote:

but i couldnt write it again off the top of my head.

...Understanding how the code works is much more important then remembering the code. As long as you know how it works, you should be able to re-implement it in different ways to achieve your desired results.

I personally still recommend going against *.raw files for the reasons discussed in your previous post. It is good that you have got it working for the most part though :)

Share this post


Link to post
Share on other sites
Most terrains are flat and any big objects are further models.
i can create a terrain with a raw file but with problems; i created a 64X64 with textures and the thing runs 10fps!
I want to use a X file but i dont believe i can get the height of given triangle for camera movements

so my best bet is to create a file eg ter file and parse it into a directx mesh, and split it up .

Is this correct?

Share this post


Link to post
Share on other sites
Quote:

i can create a terrain with a raw file but with problems; i created a 64X64 with textures and the thing runs 10fps!

Hm...The type of file being used should not create this problem. (i.e., It does not matter the file type.) Your problem may be elsewhere in your main loop and rendering code.

Quote:

so my best bet is to create a file eg ter file and parse it into a directx mesh, and split it up .

This is up to you (Although I do recommend against *.raw files.) Nonetheless, unless you are loading the file every frame, it would not be the cause of your current problem.

Share this post


Link to post
Share on other sites
my code runs slowly when i add textures to each triangle compared to colors. with such a large file 64X64 being written all the time with thousands of textures fitted then it runs slowly .

if i create an empty mesh with 256X256 then it fails as it is too lalrge.

hence is never see this in examples.

"Nonetheless, unless you are loading the file every frame, it would not be the cause of your current problem." dont i have to load the file every frame as i cant render the screen unless i write something to it. Can i have a terrain loaded once on screen then never render again?

Share this post


Link to post
Share on other sites

This topic is 3624 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this