public void Update() { lock (Transformation) { var tRotationMatrix = Matrix4.CreateFromQuaternion(Transformation.GetOrientation().Inverted()); var tViewMatrix = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix; if (cone == null) { var tcone = FrustumCone.Create(Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); cone = tcone; } else { FrustumCone.Update(cone, Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); } RotationMatrix = tRotationMatrix; ViewMatrix = tViewMatrix; VPMatrix = Matrix4.Mult(ViewMatrix, ProjectionMatrix); } }
public void UpdateFromRollPitch() { lock (Transformation) { var rotationX = Quaternion.FromAxisAngle(Vector3.UnitY, Pitch); var rotationY = Quaternion.FromAxisAngle(Vector3.UnitX, Roll); Transformation.SetOrientation(Quaternion.Multiply(rotationX.Inverted(), rotationY.Inverted())); var tRotationMatrix = Matrix4.CreateFromQuaternion(rotationX) * Matrix4.CreateFromQuaternion(rotationY); var tViewMatrix = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix; if (cone == null) { var tcone = FrustumCone.Create(Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); cone = tcone; } else { FrustumCone.Update(cone, Transformation.GetPosition(), tViewMatrix, ProjectionMatrix); } RotationMatrix = tRotationMatrix; ViewMatrix = tViewMatrix; VPMatrix = Matrix4.Mult(ViewMatrix, ProjectionMatrix); } }