Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In my Game I'm currently have "Scene Coordinates" which are the X,Y coordinates relative to a Game Scene.

In that Scene there are Game Entities, let's say there's a GameEntity A in x=100.0, y=100.0 ( scene coordinates )

Which is the best way to have "Entity Coordinates" so that from GameEntity A point of view, he's standing at x=0.0, y=0.0 with OpenGL transformations?

In that way if I apply something like

glRotatef(angle, 0, 0, 1) 

The entity will rotate around it's own origin and not the scene "global" origin.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

The order of transformations in OpenGL is the opposite order than for DirectX. For DirectX its the SRT-Rule: Scale, Rotate, Translate - for OpenGL its: Translate, Rotate, Scale

glPushMatrix();
    // move entity to its position
    glTranslate(...);
    // rotate entity around its origin
    glRotate(...);
    // drawn entity
    DrawEntity();
glPopMatrix();

DrawEntity must render the entity using its local space coordsystem, they are fixed if there is no animation.

If that doesnt answer your question, please rephrase it and elaborate.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.