Advertisement

Terrain tutorials?

Started by December 07, 2000 05:37 PM
6 comments, last by necko 24 years, 2 months ago
Hi. I just stumbled upon this excellant site. I have not noticed any terrain tutorials and I would like to learn how to do it. Anybody has a link or doc. about this matter. Any help would be greatly appreaciated. Thanks.
http://www.vterrain.org
Advertisement
Flipcode has a couple(I think) well I know they have at least one. Here''s the address: http://www.flipcode.com/tutorials.shtml

Hope this helps!
hey necko I have a nice simply piece of code to generate a height map for terrain.. then you can figure out how to join the heights.. Nice recursive algorithm.. generates a perfect heightmap though the dimension must be a power of 2


int GLTerrain::Build(int x, int z, int dimension)
{

//Cut the dimensions in half to populate other sections.
int halfsize = (dimension / 2);

//The following 4 lines will set up new points on the plane to
//specify heights for.

int xh = x + halfsize;
int zh = z + halfsize;

int x2 = x + dimension;
int z2 = z + dimension;

if(Terrain[xh][z] == -1.0f)
{
Terrain[xh][z] = ((Terrain[x][z] + Terrain[x2][z]) / 2) + getRand(-1.0f, 1.0f) * dimension / 8;

}

if(Terrain[xh][z2] == -1.0f)
{
Terrain[xh][z2] = ((Terrain[x][z2] + Terrain[x2][z2]) / 2) + getRand(-1.0f, 1.0f) * dimension / 8;


}

if(Terrain[x][zh] == -1.0f)
{
Terrain[x][zh] = ((Terrain[x][z] + Terrain[x][z2]) / 2) + getRand(-1.0f, 1.0f) * dimension / 8;

}

if(Terrain[x2][zh] == -1.0f)
{
Terrain[x2][zh] = ((Terrain[x2][z] + Terrain[x2][z2]) / 2) + getRand(-1.0f, 1.0f) * dimension / 8;

}

if(Terrain[xh][zh] == -1.0f)
{
Terrain[xh][zh] = ((Terrain[xh][z] + Terrain[xh][z2]
+ Terrain[x][zh] + Terrain[x2][zh]) / 4) + getRand(-1.0f, 1.0f) * dimension / 8;

}
if(halfsize >= 1)
{

Build(x, z, halfsize);
Build(xh, z, halfsize);
Build(x, zh, halfsize);
Build(xh, zh, halfsize);
}
return 0;
}//End of Build() Method





I''m in school right now and will be work on a developing a perfect random terrain class over the winter break. I''m moving along, I want to do a ROAM also, along with a 3dsmax file loader..

I''m still a newbie so give it time, I noticed a lack of terrain tutorials, and this is the area I am mainly interested in.. Virtual worlds.. so good luck hope this algorithm helps..
Thank You all very much!
Advertisement
there aren''t any terrain tutorials because they are too easy!

all you do is make a grey scale image in paint shop pro with random colors, and save it as a .raw file. Then just load each one of those pixels from the raw file into your engine, and the whiter the pixel, the higher it is. I have a pretty score terrian engine going, (i think atleast, probably sucks compared to what everybody else is doing) and that method works perfect
"This is stupid. I can't believe this! Ok, this time, there really IS a bug in the compiler."... 20 mins pass ..."I'M AN IDIOT!!!"
psionic, just as info.. the difficulty of a terrainengine is not the "how-to-load" (when you want a hightmap-terrain), its the how-to-render-it-fast-without-an-overdraw-of-bout-1000%-question!

and the how-to-create-perfect-level-of-detail-question, too..

we wanna play, not watch the pictures

If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

This topic is closed to new replies.

Advertisement