Limit the amount a camera can pitch
- by ChocoMan
I'm having problems trying to limit the range my camera can pitch. Currently my camera can pitch around a model without restriction, but having a hard time trying to find the value of the degree/radian the camera is currently at after pitching. Here is what I got so far:
// Moves camera with thumbstick
Pitch = pController.ThumbSticks.Right.Y * MathHelper.ToRadians(speedAngleMAX);
// Pitch Camera around model
public void cameraPitch(float pitch)
{
pitchAngle = ModelLoad.camTarget - ModelLoad.CameraPos;
axisPitch = Vector3.Cross(Vector3.Up, pitchAngle);
// pitch constrained to model's orientation
axisPitch.Normalize();
ModelLoad.CameraPos = Vector3.Transform(ModelLoad.CameraPos - ModelLoad.camTarget,
Matrix.CreateFromAxisAngle(axisPitch, pitch)) + ModelLoad.camTarget;
}
I've tried restraining the Y-camera position of ModelLoad.CameraPos.Y, but doing so gave me some unwanted results.