Advertisement

About world movement

Started by January 08, 2003 10:25 PM
2 comments, last by UponTheEnd 22 years, 1 month ago
there are two ways i know of to move around in the world, using a bunch of math and use glutLookAt() or use glTranslatef() and glRotatef() on the entire scene. my question is if you are using the glTranslatef() and glRotatef() to do the movment, when you are actually coding the scene. you cant use glLoadIdentity() and such because it will reset everything and the calls to those two function will be gone right? is there a way you can get around that. or am i thinking very wrong. please correct me. i dont bite.
"What we do in life, echos in eternity" -- Gladiator
First off, the two methods you said are the same thing. gluLookAt just does both glTranslate and glRotatef in one, and provides a nice way of handling a "camera". You''re going to need a lot of math to handle both methods properly.

Second, if you don''t want to lose all of the Matrix changes you''ve done, then do this:
//blah blah glTranslate/rotate etcglPushMatrix();glLoadIdentity();//do whatever you wanted the identity matrix forglPopMatrix();//continue on with the glTranslate/rotate etc you had before 


------------
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155
"It''s all part of the conspiracy of conspirators conspiring to conspire their own conspiracies..."
_______________________________________Pixelante Game Studios - Fowl Language
Advertisement
I never understood why people don''t set the camera position inside of the Projection matrix. Is there something terribly wrong about doing it that I don''t know about? I mean I thought the red book said that is what the projection matrix is for?

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(...);
// Adjust the camera location
// ....
glMatrixMode(GL_MODELVIEW);
// Draw the scene
The projection matrix is for projection. The modelview matrix is for your model transform and your view transform. Setting the camera position in the projection matrix messes up lighting, fog, and probably other things too.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

This topic is closed to new replies.

Advertisement