Jump to content
  • Advertisement
Sign in to follow this  
cybergolem

Problem to understand glLoadIdentity

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have read a lot of Tutorials in the Articles section and from NeHe. but I still don't get it when it comes to placement of rotations,translations and the loadIdentity line. for example, I have a car. -> only 4 wheels and a chassi. how do I have to place glRotation.translation loadidentity... can anyone help me with some Pseudocode, or a GL Guide for dummy-dummys ? Thanks Chris

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
glLoadIdentity loads (or better: resets) the current matrix to its, oh well, identity. An identity matrix does absolutely nothing, that is no change or any kind of effect on your model.

Multiplying a point in the space by an identity matrix is identical to doing a multiplication by one.

3dPoint * identityMatrix = 3dPoint

same as, for exemple:

8 * 1 = 8 ;)

Share this post


Link to post
Share on other sites
Ah, ein Namensvetter ;)

You might want to check out this site
It explains what matrices are in general and how they are used in OpenGL.
The author tries to explain everything in easy words - maybe it helps you.

Greets,

Chris ;)

Share this post


Link to post
Share on other sites
In fact, your order is defined by the camera perspective you want to have:

for a first person view:

LoadIdentity
RenderCar
Transform@CarPosition
Rotate@CarRotation
RenderScene

for a third person view:

LoadIdentity
Translate@WishedDistance (in most games only z-)
Rotate@ViewingDirection
RenderCar
Transform@CarPosition
Rotate@CarRotation
RenderScene

Little notation: At these examples you can see very nice that you really don't move the object itself, you move the whole world around it!

for a bird camera view:

LoadIdentity
Translate@BirdPosition
Rotate@Earth (for example glRotatef(90, 1, 0, 0))
RenderScene
Transform@CarPosition
Rotate@CarRotation
RenderCar

if you want to make something like a hud, put this after EVERY pseudocode:

Switch@OrthoDrawMode
LoadIdentity
DrawHud (all parameters to glVertex2f etc are now in pixels!)
Switch@PerspectiveDrawMode

if you want to put some objects in your landscape (e.g trees) by using translate and rotate too, use the following for EACH object:

glPushMatrix;
Translate@ObjectPosition
Rotate@ObjectRotation
RenderObject
glPopMatrix;

I hope these examples helped you with your question
greets, KyRo1989

Share this post


Link to post
Share on other sites
awww i'm sorry but i made a little mistake!

if you want to place your bird along the y-axis (e.g (0, 10, 0)), then you have to call rotate first!
to get the same result calling translate first, you have to move your bird in -z-axis to bring it higher. but then rotate -90, not 90!
sorry about that

greets KyRo1989

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!