world coordinate/local coordinate

Started by
2 comments, last by koexistens 19 years, 8 months ago
hello all, I'm new to this world of OpenGL and would like to understand the difference between local coordinate system & world coordinate system. Theoretically, i could understand the terms but am not able to implement an example by a tranformation of a cube. appreciate your inputs (Especially in reference to glMatrixMode (GL_MODELVIEW) ) just showing the render code in a way I could understand what happens when ~ boyd
Advertisement
I got myself a result::

whatever transformations that happens inside the top glPushMatrix() & corresponding glPopMatrix () corresponds to the local coordinate system of the object where itz being intially transformed;

once the flow control comes out of corresponding glPopMatrix(), tranformations applied are done in world coordinate system.

I hope my conclusion is correct ? but still am not sure how coordinate systems (local to world) corresponds to GL_MODELVIEW ??

appreciate your example.

~boyd
Basically it's just a matter of how you store the vertices of your cube. You may either store them in local or world coordinates. In local coordinates a vertex might look like (1.0; 0.0; 1.0) whereas in world coordinates it might be (312.0; 12.0; -13.0). To get the local coordinate cube to be displayed at the same spot as the world coordinate cube you would call glTranslatef(311.0, 12.0, -14.0); and the coordinates would be transformed to the correct position.

Local coordinates are usually better since you can easily apply a rotation about the center of the cube and the center of the world. With world coordinates you need to do some tricks before you can rotate around the center of the cube.

Hope that clarifies things a bit.

Edit: What goes on inside between glPushMatrix() and glPopMatrix() does not necessarily have anything to do with local or world coordinates. The transformations that take place between these calls will not have any effect after glPopMatrix(), so these calls are useful if you want to make unique transformations to a single object. Actually they are useful for a lot of stuff, but that's one perhaps one of the most common things they're used for.

glMatrixMode(GL_MODELVIEW) declares that you want to manipulate the modelview matrix which means that you are manipulating the positions of the vertices of your cube. Other matrix modes might transform texture coordinates or color values for example. So GL_MODELVIEW is not really related to local or world coordinates in a way that makes any difference.
Hi!

Have you read the oh-so-good articles about OpenGL programming over at NeHe? That would be the first place to visit ifo you want to learn all the basics and a lot of not so basic. It's probably the most popular OpenGL tuts on the net...

Happy coding!
Read my devblog at: koex.dyndns.org/blog

This topic is closed to new replies.

Advertisement