Verifying Positions
In using openGL, I need to query the positions of 2 objects relative to an outside observer unaffected by rotations and the like. For example, consider the following:
On a 2-D coordinate plane, a square and a circle are present. In typical openGL fashion, I used the translate command to move from drawing the square to drawing the circle. Now if I rotated say 180 around z so the shapes are flip-flopped before drawing the shapes for the next frame, the same translate command would work and the objects would be swapped. Now, if I use the translate command''s coordinates (the 3 arguments I passed it) as the coordinates of each object, both pictures would have the same coordinates because those coordinates are relative to the box. But I want the absolute coordinates, which would show that the scene had changed.
Sorry if I confused anyone with this poor explanation. Anyway, I could really appreciate your help.
You should store all objects relative to the world, not to eachother. Also, make an observer (or camera) class and code like this:
glLoadIdentity()
PositionCamera
glPushMatrix()
PositionSquare
DrawSquare
glPopMatrix()
glPushMatrix()
PositionCircle
DrawCircle
glPopMatrix()
all changes in the scene are changes in the objects position. Changes in the camera are not changes in the scene.
- An eye for an eye will make the world go blind -
glLoadIdentity()
PositionCamera
glPushMatrix()
PositionSquare
DrawSquare
glPopMatrix()
glPushMatrix()
PositionCircle
DrawCircle
glPopMatrix()
all changes in the scene are changes in the objects position. Changes in the camera are not changes in the scene.
- An eye for an eye will make the world go blind -
<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement