PDA

View Full Version : 3D mesh surface

aus79er
05-21-2002, 01:09 PM
HI,
I am still learning OpenGl
I have written a program through which i am able to obtain x,y,z values for an object.
Now the x & Y value can vary from 1 to 100,
Z value varies between 99.5 and 100.

Now using these points i want to display a 3D surface.I have written a code for drawing the triangle strips and calculating the normal...
Note that the x and y values are stored in an 1D array while z values in 2D array

glBegin ( GL_TRIANGLES ) ;

for(i=1;i<=100;i++)
{
for(j=1;j<=100;j++)
{
n1=check.CCalNormal(i,j,1);
glNormal3f(n1.x,n1.z,n1.y);
glVertex3f (xw[i],zw[i][j],-yw[j]/10) ;
glVertex3f (xw[i+1],zw[i+1][j],-yw[j]/10) ;
glVertex3f (xw[i+1],zw[i+1][j+1],-yw[j+1]/10) ;

/* n2=check.CCalNormal(i,j,2);

glNormal3f(n2.x,n2.z,n2.y)*/;;
glVertex3f (xw[i],zw[i][j],-yw[j]/10) ;
glVertex3f (xw[i],zw[i][j+1],-yw[j+1]/10) ;
glVertex3f (xw[i+1],zw[i+1][j+1],-yw[j+1]/10) ;

}
}
glEnd();
This is my code....

I am more intrested in displaying the surface having the z value variations between 99.5 to 100.

For eg. the x,z,y values can be as follows...
(1,100,1)
(2,99.5,1)
(3,99.75,1)
(1,100,2)
(1,99.5,3)
.....
so on....
I want to display the variation in the Z value...by using a 3D mesh....
How Can i do that ,can anybody help me with a sample code
Thanks
aus