Wednesday, May 12, 2010

XNA Camera Direction from Orientation


_cameraDirection = new Vector3((float)Math.Sin(_cameraAngle.Y) * (float)Math.Cos(_cameraAngle.X),
-(float)Math.Sin(_cameraAngle.X),
(float)Math.Cos(_cameraAngle.Y) * (float)Math.Cos(_cameraAngle.X));

Forward vector from euler angles:

public Vector3 _Forward
{
get
{
return new Vector3((float)Math.Sin(_orientation.Y) * (float)Math.Cos(_orientation.X),
-(float)Math.Sin(_orientation.X),
(float)Math.Cos(_orientation.Y) * (float)Math.Cos(_orientation.X));
}
}