3

I have an object in 3D space where all I have is a euler position and rotation. How can I calculate forward and up vectors from the information I have?

I know that I can calculate the forward vector in this way:

Vector3 forward = (target.getPosition() - object.getPosition()).normalize();

.. where target is any point along the axis which the object is looking. Using the information I have, how can I pick an arbitrary point in this way to normalize?

I'm not sure how to go about solving the "up" vector at all.

Zhro
  • 2,546
  • 2
  • 29
  • 39

1 Answers1

0

First create a transform matrix from your euler angles (with the same method as you are using while rendering). Then extract the axises vectors for forward and up from it directly. For example my view matrices uses Z axis for forward/backward and X axis for left/right so I would just use those two. You will find the location of the vectors here:

Understanding 4x4 homogenous transform matrices

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380