private void UpdateViewMatrix()
{
Matrix.CreateFromQuaternion(ref orientation, out viewMatrix);
xAxis.X = viewMatrix.M11;
xAxis.Y = viewMatrix.M21;
xAxis.Z = viewMatrix.M31;
yAxis.X = viewMatrix.M12;
yAxis.Y = viewMatrix.M22;
yAxis.Z = viewMatrix.M32;
zAxis.X = viewMatrix.M13;
zAxis.Y = viewMatrix.M23;
zAxis.Z = viewMatrix.M33;
if (behavior == Behavior.Orbit)
{
// Calculate the new camera position based on the current
// orientation. The camera must always maintain the same
// distance from the target. Use the current offset vector
// to determine the correct distance from the target.
eye = target + zAxis * orbitOffsetLength;
}
viewMatrix.M41 = -Vector3.Dot(xAxis, eye);
viewMatrix.M42 = -Vector3.Dot(yAxis, eye);
viewMatrix.M43 = -Vector3.Dot(zAxis, eye);
viewDir.X = -zAxis.X;
viewDir.Y = -zAxis.Y;
viewDir.Z = -zAxis.Z;
viewDir.Normalize();
}