We Have Terrain!

• 03-09-2006
Shamino
We Have Terrain!
http://img.photobucket.com/albums/v1...no/Terrain.jpg

Hmm..

Moving on up theme song anyone?

Now I gotta learn how to texture map this beast...
• 03-10-2006
joeprogrammer
Nice :) Can't quite say I can do that yet.
• 03-10-2006
Morgul
After all the work you have been putting into this and all the setbacks you have needed to go through, I'm glad to see you have stuck to it and come up with a product however far from a full game it may be :).
• 03-10-2006
BobMcGee123
Good job man, keep up the good work.
• 03-10-2006
VirtualAce
Good work Shamino!

A simple texture map that applies the texture evenly across the terrain is this:

Code:

``` float fUCoef=1.0f/(float)iMapWidth; float fVCoef=1.0f/(float)iMapHeight; int row=0,col=0; DWORD dwVertexNum; DWORD dwOffset=0; for (int z=iStartZ;z<iEndZ;z+=iCellSize) {   for (int x=iStartX;x<iEndX;x+=iCellSize)   {     float height=(float)pHeightMap[dwOffset]*fScaleFactor;     Vertices[dwVertexNum]=TerrainVertex(x,height,y,(float)col*fUCoef,(float)row*fVCoef);     col++;     dwOffset++;     dwVertexNum++;   }   col=0;   row++; }```
• 03-11-2006
Shamino
Lol, I think it's pretty hillarious that I tried to understand what you wrote Bubba last night when I was incredibly trashed..

It was like a foreign language..

Looking at it now, I see that it is basically grabbing a quad of vertices from the heightmap, a "cell" and just iterating through each cell. This sets us up nicely to simply apply a texture right after we find the right vertices.. Where would the actual texture application code go in that?

Right before you increase the col, offset, and the vertex num?

EDIT: POST 500 WOOT
• 03-11-2006
VirtualAce
Well in Direct3D you don't 'bind' textures to anything. You use SetTexture() to change the current texture it's using and every primitive you draw will have that texture applied to it. So the texture code is in the loop. It just sets the u and v texture coordinates and Direct3D uses those to map the texture onto the triangle.
• 03-14-2006
Shamino
And now we have wireframe

Quality sucks due to jpegage..

http://img.photobucket.com/albums/v1...rrainLines.jpg
• 03-14-2006
Shamino
Another question, is upscaling a terrain the same as getting a bigger one?
• 03-15-2006
Perspective
Quote:

Originally Posted by Shamino
And now we have wireframe

Quality sucks due to jpegage..

http://img.photobucket.com/albums/v1...rrainLines.jpg

why are there no cross-sections in the wireframe?
• 03-15-2006
Perspective
Quote:

Originally Posted by Shamino
Another question, is upscaling a terrain the same as getting a bigger one?

No, because each poly just gets bigger with scaling, if you get a bigger terrain, you can scale it the same way but have more polys per unit area (higher res).
• 03-15-2006
The Wazaa
Quote:

Originally Posted by Perspective
why are there no cross-sections in the wireframe?

I think he renders the terrain as I do; with glBegin(GL_QUADS); but for Direct 3D :rolleyes: . I guess that it is a bit faster to do like that since it will become less calls to the API, but this is just what I guess prove me wrong :)

And that is a cool terrain, what kind of lighting do you use? Nice work.

Daniel

EDIT: Here is a screen of my terrain http://e43.sag.karlstad.se/it18/screenShot.jpg
• 03-15-2006
Perspective
> but this is just what I guess prove me wrong

ok. :)

If you render with individual quads or triangles you repeat many many vertices. The same vertex will be sent through the graphics pipeline 4 times (on average, for a uniform grid based terrain). It is much faster to use trianlge strips or trianlge fans which link triangles together.

btw: your quads are split into two triangles in the pipeline anyway.
• 03-15-2006
VirtualAce
For Direct3D you cannot render quads by themselves. Everything is in triangles since any 3 points in space are guaranteed to be colinear or lie in the same plane and thus create a plane.

A triangle is easy to texture as well but I won't go into the math right here.

Do what Perspective said. Use triangle strips. Each row of the terrain should be a strip. Depending on your space partitioning algo your setup may differ significantly from just using a regular grid. However I've found that regular grids do lend themselves to a lot of usefulness.

www.vterrain.org - Everything you ever wanted to know about terrain and more.

Still working on my implementation. However I'm more focused on another project at the moment.