4
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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