View Full Version : Local and global coordinate system

10-11-2002, 09:18 AM
What is a local coordinate system as opposed to a global coordinate system? How do I set up a local coordinate system if there is such a thing?

10-11-2002, 09:53 AM
If you draw everything in the global coordinate system, then everything is relative to the global origin.

A local coordinate system is just that...local to the object you are drawing.

For example.

If you draw a circle centered at (5,5) in the global coordinate system, it would appear centered 5 units from the origin in the x and y direction.

The same circle could be drawn in the local coordinate system that has it's origin at 5,5

Sorry, it is kind of hard to explain without a diagram.

Check out
www.gamedev.net (http://www.gamedev.net) and look in the articles and resources section. They may have some more info.


10-12-2002, 09:12 AM
"Need Help", you may want to register, so we can call you something other than "Need Help". http://www.opengl.org/discussion_boards/ubb/smile.gif

When you start specifying vertices for some object, you specify them relative to some origin. Say, a little spaceship object may have verts at (-1.34, 3.81, 2.50), (2.89, -6.78, 0.23), and so on. The points are being specified relative to some origin, probably near the center of the spaceship. If you drew this spaceship on a piece of paper, somewhere near the middle of this drawing would be a place you write (0.00, 0.00, 0.00). You just call it "the origin" because it's not relative to anything else yet at the moment.

Now, when you draw your spaceship in some larger drawing, maybe containing asteriods, that larger drawing has an origin too.

You might tell OpenGL to draw the spaceship at (24.00, -12.00, 3.89). You're specifying those coordinates relative to the big-picture's origin -- ie, in global coordinates.

However, the actual verts for the pieces of your spaceship are still saved somewhere, and are relative to somewhere near the middle of the spaceship -- that is to say, they are relative to the local origin of the spaceship, and specified in the spaceship's local coordinate system.

10-12-2002, 02:45 PM
Those old points are saved somewhere, but where is "somewhere?" Can I see those points on the screen? How do I access them?

10-12-2002, 03:11 PM
I don't think you can, since once drawn they became part of the global matrix.
You could keep track of there position in the world by doing some math

But explane what you are trying to do, and maybe there is another way to get the same results you want.

As for local vs. global.

Objects are should be drawn as if they where the only thing in the scene, most times with there origin at the center. This makes rotation and translation to other places in the scene easy.

This is where the scene is put together, objects with their local points are translated and rotated into position in the scene.

All objects will start at 0,0,0 and be translated to their desired location in the global world.

Originally posted by Need help:
Those old points are saved somewhere, but where is "somewhere?" Can I see those points on the screen? How do I access them?

[This message has been edited by nexusone (edited 10-12-2002).]

10-12-2002, 06:10 PM
"Need Help", you seem to be missing the distinction between points in 3d space (a trio of floats, a vertex) and points drawn on your screen (pixels).

When all is said and done, and there's a picture on your screen, there's no longer any meaning to global and local coordinate systems. Those terms were used when describing objects in 3d space. Now, what you've got is 2d window coordinates. Such is the magic that is OpenGL. http://www.opengl.org/discussion_boards/ubb/smile.gif