Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Right thumbstick (up and down) pitches the camera
- Pitch = pController.ThumbSticks.Right.Y * -MathHelper.ToRadians(speedAnglePitch);
- // Orbit 360 (yaw) Camera around model no matter where model moves to
- public void cameraYaw(float yaw)
- {
- Vector3 yawAngle = ModelLoad.CameraPos - ModelLoad.camTarget;
- Vector3 axisYaw = Vector3.Up;
- ModelLoad.CameraPos = Vector3.Transform(yawAngle,
- Matrix.CreateFromAxisAngle(axisYaw, yaw)) + ModelLoad.camTarget;
- ModelLoad.CameraPos.Normalize();
- }
- // Pitch Camera around model
- public void cameraPitch(float pitch)
- {
- // Which way is the camera facing?
- cameraDirection = ModelLoad.CameraPos - ModelLoad.camTarget;
- axisPitch = Vector3.Cross(Vector3.Up, cameraDirection);
- // pitch constrained to model's orientation
- axisPitch.Normalize();
- ModelLoad.CameraPos = Vector3.Transform(cameraDirection,
- Matrix.CreateFromAxisAngle(axisPitch, pitch)) + ModelLoad.camTarget;
- }
- // Called in update method
- public void updateCamera()
- {
- cameraYaw(Yaw); // <-works perfectly (360 degrees around model's center)
- cameraPitch(Pitch); // <-Not working as desired (cannot seem to limit pitch between two degrees)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement