// Rotate camera left or right (aka Pan) public void Yaw(float angle) { // rotate around the up vector (normally the y-axis) viewdir = (viewdir * (float) Math.Cos (angle)) - (right * (float) Math.Sin (angle)); viewdir.Normalize (); right = viewdir.Cross (up); right.Normalize (); }
// Rotate camera up or down (aka Tilt) public void Pitch(float angle) { // rotate around the right vector (normally the x-axis) viewdir = (viewdir * (float) Math.Cos (angle)) + (up * (float) Math.Sin (angle)); viewdir.Normalize (); up = viewdir.Cross (right); up.Normalize (); }
// Roll the camera left or right public void Roll(float angle) { // rotate around the view-direction vector (normally the z-axis) right = (right * (float) Math.Cos (angle)) + (up * (float) Math.Sin (angle)); right.Normalize (); up = viewdir.Cross (right) * -1.0f; up.Normalize (); }
// Direct the camera toward a specific point in space using the specified upward orientation public void LookAt(Vertex point, Vector upVector) { viewdir = point - position; viewdir.Normalize (); up = upVector.Normal; right = viewdir.Cross (up); right.Normalize (); }