View Full Version : how to reset the position of object after transfor

03-09-2011, 06:36 AM
hello sir i have problem regarding
resetting of whole scene to it's original position

actually i have drawn two object in screen. and selecting the object through keyboard by pressing the number

after choosing a object i can rotate that object with mouse movement ..(it's going perfectly)

but as i m selecting the other object(through keyboard) the position of all object changed

plz tell me how to reset the whole screen i.e to it's original position as i select other object

or any other way to not affecting other object after selecting other object
(execuse me for any mistake ...i m new to openGL)

03-10-2011, 01:12 AM

I'm doing similar thing in my application by this:
1.Keep your object and camera initial position in addition to current position (only for objects which you want to allow to move).
2.I'm doing transformations with gluLookAt(..). So I keep original "eye" and "look at" positions.
And then when you need to reset the whole scene ,just overwrite current positions with initial.

P.S. I'm not too experienced in OpenGL, so I'm not sure if my solution is most effective, but it works.

03-10-2011, 02:04 AM
If your using a compatability profile then you can make use of glPushMatrix/glPopMatrix to save the current modelview matrix as you draw each object.
By using glulookat you are setting the modelview matrix. When drawing an object you'd typically use glTranslatef (x,y,z) to 'move' the object into it's position and then draw. The glTranslatef actually modifies the current modelview matrix, so it's necessary to restore the matrix back to it's initial value. Two ways to do that: re-issue the camera code (gluLookat) or use glPushMatrix to save the modelview matrix, and after drawing use glPopMatrix to restore.

03-11-2011, 09:42 PM
it's good way ....but can u plz help in coding

how to reset the modelview matrix (glulookat) ie how to reset it