5
\$\begingroup\$

I'm representing the rotations of my actors (or gameobjects) with euler angles (one float for each axis). And I've always considered the vector (1,0,0) (x,y,z) to be the actor's direction if all angles are 0. So if an actor don't have any rotation, and walks forward, he will be walking down the positive x axis.

However, I was implementing a camera today that's supposed to display the view from the actors perspective. If I use the actor's rotation, that is (0, 0, 0), the camera will be looking down the -z direction (straight into the monitor), but the actor is actually looking to the right.

If, instead, -z would be considered the direction when the rotation is (0, 0, 0), then the camera would be facing the correct direction. Is that how this is normally handled? Or am I thinking of this the wrong way?

To clear things up, I'm using a right handed coordinate system with y as the up axis.

\$\endgroup\$
5
\$\begingroup\$

This is entirely a matter of convention. (Since you didn't mention any particular tools.)

But! If you are modeling in the same default orientation as your screen, which you say is right-handed, X-right, Y-up, and therefore Z-towards-you, then it would be natural to model your characters facing you, where forward is Z-positive.

Which also implies your default camera looking, as you mention, towards Z-negative into the screen. So your character with an identity matrix will appear centered, looking at you the viewer.

(Which is the convention I use, by the way.)

\$\endgroup\$
  • 1
    \$\begingroup\$ Thanks! I guess it makes sense to have characters facing Z-positive, now that you say it. So I guess the solution is to add a 180 degree rotation to the camera to look the same direction as the player? (If Z-positive is default direction.) \$\endgroup\$ – lawls Mar 23 '15 at 6:04
  • \$\begingroup\$ Yes, exactly... I just went back and checked; all my little test screens start with the same: cameraMatrix.lTranslateZ(7.5); cameraMatrix.lRotateY(MePi); (Which still doesn't tell the entire story, since more stuff happens in the vertex shader (in my case) also, but yes, I do what you just described.) \$\endgroup\$ – david van brink Mar 23 '15 at 18:26

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.