Pitch camera around model
- by ChocoMan
Currently, my camera rotates with my model's Y-Axis (yaw) perfectly. What I'm having trouble with is rotating the X-Axis (pitch) along with it. I've tried the same method for cameraYaw() in the form of cameraPitch(), while adjusting the axis to Vector.Right, but the camera wouldn't pitch at all in accordance to the Y-Axes of the controller.
Is there a way similar to this to get the same effect for pitching the camera around the model?
// Rotates model on its own Y-axis
public void modelRotMovement(GamePadState pController)
{
Yaw = pController.ThumbSticks.Right.X * MathHelper.ToRadians(speedAngleMAX);
AddRotation = Quaternion.CreateFromYawPitchRoll(Yaw, 0, 0);
ModelLoad.MRotation *= AddRotation;
MOrientation = Matrix.CreateFromQuaternion(ModelLoad.MRotation);
}
// Orbit (yaw) Camera around model
public void cameraYaw(Vector3 axis, float yaw, float pitch)
{
Pitch = pController.ThumbSticks.Right.Y * MathHelper.ToRadians(speedAngleMAX);
ModelLoad.CameraPos = Vector3.Transform(ModelLoad.CameraPos - ModelLoad.camTarget,
Matrix.CreateFromAxisAngle(axis, yaw)) + ModelLoad.camTarget;
}
public void updateCamera()
{
cameraYaw(Vector3.Up, Yaw);
}