HEIGHT MAP

Hello,

I am using MFC and OpenGL to display 3D surface.
Now I want to highlight the difference in the height by using different colors…i.e each region having same height should have same color and there should be difference in the color…to display different height…
So how should i go about it…

I am using glBegin(GL_LINES) command to display the 3D mesh

I need some help in this matter…

Thanks
aus

Use a 1D texture…

yeah, a 1d texture is definitely the way to go. i have a nice one that i use for the same purpose if you want it.

Thanks,Pat & SThomas

SThomas,I am interested in your code can you help me.

Also I am new to Texturing …so can you explain in detail…
Currently I am drawing the 3D mesh using following commands…
glBegin(GL_LINES) ;
glColor3f(1.0f,0.0f,0.0f);

	for(i=1;i<=98;i++)
	{
		for(j=1;j<=98;j++)
		{
			
			n1=check.CCalNormal(i,j,1);
			glNormal3f(n1.x,n1.z,n1.y);
			glVertex3f (xw[i],zw[i][j]-99.4,-yw[j]) ;
			glVertex3f (xw[i+1],zw[i+1][j]-99.4,-yw[j]) ;
			glVertex3f (xw[i+1],zw[i+1][j+1]-99.4,-yw[j+1]) ;
			
		//	n2=check.CCalNormal(i,j,2);
			glNormal3f(n1.x,n1.z,n1.y);
				glVertex3f (xw[i+1],zw[i+1][j+1]-99.4,-yw[j+1]) ;
				glVertex3f (xw[i],zw[i][j+1]-99.4,-yw[j+1]) ;
				glVertex3f (xw[i],zw[i][j]-99.4,-yw[j]) ;
			
			
		}
	}
	glEnd();

Thanks
aus

SThomas Thanks for offering your code…
My email id is aus79er@yahoo.com
Please mail it to me

Bye
aus

suppose the height field is a two dimensional array of 3-d vectors (which are stored as floats) declared as:
Vector3 terrainMesh[100][100];

to draw the terrain in wireframe mode, i’d do something like this:

//make sure front face winding is counter clockwise
//don’t worry about normals since we’re in wireframe mode
glBegin(GL_QUADS);
for (int i = 0; i < 99; i++)
for (int j = 0; j < 99; j++)
{
glVertex3fv(terrainMesh[i][j]);
glVertex3fv(terrainMesh[i+1][j]);
glVertex3fv(terrainMesh[i+1][j+1]);
glVertex3fv(terrainMesh[i][j+1]);
}
glEnd();

that’ll be real slow though. to make that faster, you could:
a) use a quad strip for each row of the terrain instead of individual quads
b) use vertex arrays to store the quad strips
c) compile the quad strips into a display list

for info on loading textures and what not, check out nehe.gamedev.net