PDA

View Full Version : 3d OBJECT



aus79er
03-29-2002, 02:54 PM
HI,
I want to display a 3D object.
I have the x,y,z [in an array]co-ords.
I am displaying those objects using

void display()
{
glBegin (GL_TRIANGLES);
glVertex3f(xw[si],0, yw[sj]);
glVertex3f(xw[si+1],0, yw[sj]);
glVertex3f(xw[si+1],zw[si+1][sj], yw[sj]);
....

}
void init()
{
glClearColor(0.0,0.0,0.0,0.0);
glColor3f(1.0,1.0,1.0);
glViewport(0,0,250,250);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 250.0, 0.0 , 250.0, 0.0, -250.0);

}


etc..
The program is running.But the object doesn't look 3D

Now I want to display it in such a way that it should look 3D
What should i do.
Also variations of z values is very less i.e
100,99.6,99.5,99,99.5,100...etc...
What can i do to display it in much better way

Thanks

nexusone
03-29-2002, 04:30 PM
Add lighting to the scene.
Change from glortho mode to gluPerspective.


Originally posted by aus79er:
HI,
I want to display a 3D object.
I have the x,y,z [in an array]co-ords.
I am displaying those objects using

void display()
{
glBegin (GL_TRIANGLES);
glVertex3f(xw[si],0, yw[sj]);
glVertex3f(xw[si+1],0, yw[sj]);
glVertex3f(xw[si+1],zw[si+1][sj], yw[sj]);
....

}
void init()
{
glClearColor(0.0,0.0,0.0,0.0);
glColor3f(1.0,1.0,1.0);
glViewport(0,0,250,250);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 250.0, 0.0 , 250.0, 0.0, -250.0);

}


etc..
The program is running.But the object doesn't look 3D

Now I want to display it in such a way that it should look 3D
What should i do.
Also variations of z values is very less i.e
100,99.6,99.5,99,99.5,100...etc...
What can i do to display it in much better way

Thanks

chxfryer
03-31-2002, 09:51 PM
in Ortho, z is ignored anyways. Its for 2d