8 Dec 2007, 5:46pm

leave a comment

Creating a World Matrix from a Forward vector

To create a world matrix from a Forward vector, cross the forward vector with the coordinate system up and normalise the result to get the Right vector. Then get the real Up vector by crossing the Right vector with the Forward. Then set the matrix with the 3 components and you’re done.

Vector3 right = Vector3.Cross(forward, Vector3.Up);
right.Normalize();
Vector3 up = Vector3.Cross(right, forward);
localToWorld.Forward = forward;
localToWorld.Right = right;
localToWorld.Up = up;

ref

*name

*e-mail

web site

leave a comment