Jump to content



How to draw at exact positions instead of relative

  • You cannot reply to this topic
3 replies to this topic

#1 Colby_   Members   -  Reputation: 100

Like
0Likes
Like

Posted 21 February 2012 - 06:19 PM

Imagine I have a list of things I want to draw, and their exact positions in relation to the origin. For drawing the first object, I can simply translate to the coordinates of the object and draw it. However, for any object after that one, the points i enter are relative to the last translation. How can I reset similarly to glLoadIdentity(); but without discarding my camera rotations? Surely I dont have to subtract the coordinates of all models or re translate the camera for each position?

For example, say I have two cubes at (0, 5, 0) and (0, 10, 0). I currently must draw them as so:


translatecam
translate(0, 5, 0);
drawcube
translate(0, 5, 0);
drawcube
updatescreen

and I need to be able to do it like so:

translatecam
setresetpoint

translate(0, 5, 0);
drawcube
reset
translate(0, 10, 0);
drawcube
updatescreen

Ad:

#2 Waterlimon   Members   -  Reputation: 162

Like
0Likes
Like

Posted 21 February 2012 - 06:25 PM

I think there is a function for going backwards in the matrix stack, you should call that a few times.
My face when i saw i have almost 1000 profile views. I feel popular among random web browsing bots.

#3 SiCrane   Moderators   -  Reputation: 2378

Like
0Likes
Like

Posted 21 February 2012 - 06:56 PM

I think what you want is glPushMatrix() and glPopMatrix().

#4 slicer4ever   Members   -  Reputation: 149

Like
0Likes
Like

Posted 22 February 2012 - 12:40 AM

glPushMatrix/glPopMatrix, per above's answer, essentially:

glMultMatrix(CameraMatrix);
glPushMatrix();
glTranslater(0.0f, 5.0f, 0.0f);
drawCube();
glPopMatrix()
glPushMatrix()
glTranslate(0.0f, 10.0f, 0.0f);
drawCube();
glPopMatrix()







We are working on generating results for this topic
PARTNERS