clamp arcball pitch
							parent
							
								
									2e3a331d13
								
							
						
					
					
						commit
						8798fe3b48
					
				|  | @ -83,13 +83,13 @@ namespace KavTest | |||
|             WorldBuilder.SetComponent(cameraEntity, new ArcballTransformComponent( | ||||
|                 new ArcballTransform( | ||||
|                     new Vector3(0, 0, -10), | ||||
|                     MathHelper.Pi, | ||||
|                     Microsoft.Xna.Framework.MathHelper.Pi, | ||||
|                     0 | ||||
|                 ) | ||||
|             )); | ||||
|             WorldBuilder.SetComponent(cameraEntity, new CameraComponent( | ||||
|                 Matrix.CreatePerspectiveFieldOfView( | ||||
|                     MathHelper.PiOver4, | ||||
|                     Microsoft.Xna.Framework.MathHelper.PiOver4, | ||||
|                     16f / 9f, | ||||
|                     0.1f, | ||||
|                     200f | ||||
|  |  | |||
|  | @ -25,7 +25,8 @@ namespace KavTest | |||
| 
 | ||||
|         public ArcballTransform RotateLocal(float deltaYaw, float deltaPitch) | ||||
|         { | ||||
|             return new ArcballTransform(Position, Yaw + deltaYaw, Pitch + deltaPitch); | ||||
|             var newPitch = MathHelper.Clamp(Pitch + deltaPitch, -Microsoft.Xna.Framework.MathHelper.PiOver2, Microsoft.Xna.Framework.MathHelper.PiOver2); | ||||
|             return new ArcballTransform(Position, Yaw + deltaYaw, newPitch); | ||||
|         } | ||||
| 
 | ||||
|         public ArcballTransform TranslateLocal(Vector3 localTranslation) | ||||
|  |  | |||
|  | @ -0,0 +1,10 @@ | |||
| namespace KavTest | ||||
| { | ||||
|     public static class MathHelper | ||||
|     { | ||||
|         public static float Clamp(float value, float min, float max) | ||||
|         { | ||||
|             return System.Math.Min(System.Math.Max(value, min), max); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue