View Full Version : Understanding glVertex3f z Coordinate

Usman

12-15-2010, 12:56 PM

Hy,

Could anyone help me to understanding the glVertex3f coordinate? I want to understand the opengl coordinate system . . .

all three coordinate make confusing when specifying in 3d coordinate system? Where the x , y and z axis direction in opengl? Like in cartesian coordinate system x on bottm, y up and z outward . . .

Now take for instance glVertex3f(1, 1, -1) or glVertex3f(0, 0, -1). Where the point will plot ?

And last how there coordinate link with glMatrixMode or gluPerpective etc

Thanks

_arts_

12-15-2010, 02:20 PM

http://resumbrae.com/ub/dms423_f08/10/coordSystem.jpg

PS: This is the default trigonometry system coordinates.

The default view will make Z axis points to you, X axis at right and Y at top.

glMatrixMode is just a function that let you choose between modelisation-visualisation matrix (matrix to draw), and texture matrix which you should forget for now.

gluPerspective is just making a "cone" perspective, so that the far the object is, the little it will look and so that parallel lines will look like to join at infinite point.

Usman

12-15-2010, 11:31 PM

Thanks a lot about the information which you have provided . . .

Ok i understand the system of coordinates it make confusing when i plot a point in 3D . . . In 2D glVertex2f(5.0, 5.0) is making understanding that 5.0 along x-axis and 5.0 along y-axis and the prediction of point location is right. In 3D glVertex3f(5.0,5.0,5.0) is making more confusing and the point location on screen is not understandable . . . I read it about the z coordinate that if z is negative then you are dividing your screen in 5. If z is 0 then imaging that it just being on the screen. If z > 0 i imagine it being outside the screen coming towards your face.

I am not getting it what is all about . . .

I more thing i read that opengl allow you to specify whatever type of coordinate system you want. You can have gl treat the window as if the z axis is the y axis, y axis the x axis, and the x axis the z axis.

Please help me to understand these concepts . . .

Thanks again

Usman

12-15-2010, 11:33 PM

Thanks a lot about the information which you have provided . . .

Ok i understand the system of coordinates it make confusing when i plot a point in 3D . . . In 2D glVertex2f(5.0, 5.0) is making understanding that 5.0 along x-axis and 5.0 along y-axis and the prediction of point location is right. In 3D glVertex3f(5.0,5.0,5.0) is making more confusing and the point location on screen is not understandable . . . I read it about the z coordinate that if z is negative then you are dividing your screen in 5. If z is 0 then imaging that it just being on the screen. If z > 0 i imagine it being outside the screen coming towards your face.

I am not getting it what is all about . . .

I more thing i read that opengl allow you to specify whatever type of coordinate system you want. You can have gl treat the window as if the z axis is the y axis, y axis the x axis, and the x axis the z axis.

Please help me to understand these concepts . . .

Thanks again

_arts_

12-16-2010, 02:19 AM

Well, this is 3D as in real life. The image I gave in link in my previous post should help you to see how things work.

I think a good way to start is to draw a line for each axis, with different color, so something like this:

glBegin (GL_LINES);

glColor3f (1,0,0);

glVertex3f (0,0,0);

glVertex3f (1,0,0);

glColor3f (0,1,0);

glVertex3f (0,0,0);

glVertex3f (0,1,0);

glColor3f (0,0,1);

glVertex3f (0,0,0);

glVertex3f (0,0,1);

glEnd();

I don't recommand to switch axis since for me it's more troubleshooting than everything else, mainly for starting.

For the default view, Z axis is going outside, pointing to the user, so in my code you won't see the blue line, because the camera is perpandicular to x,y basis.

After you can do all what you want: rotate, translate, scale... so that the view change. Try to rotate the code I put with putting glRotatef before the code.

After, nehe tutorials are very good for beginning.

Usman

12-16-2010, 06:51 AM

Thanks . . .

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.