clamp arcball pitch
parent
2e3a331d13
commit
8798fe3b48
|
@ -83,13 +83,13 @@ namespace KavTest
|
||||||
WorldBuilder.SetComponent(cameraEntity, new ArcballTransformComponent(
|
WorldBuilder.SetComponent(cameraEntity, new ArcballTransformComponent(
|
||||||
new ArcballTransform(
|
new ArcballTransform(
|
||||||
new Vector3(0, 0, -10),
|
new Vector3(0, 0, -10),
|
||||||
MathHelper.Pi,
|
Microsoft.Xna.Framework.MathHelper.Pi,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
WorldBuilder.SetComponent(cameraEntity, new CameraComponent(
|
WorldBuilder.SetComponent(cameraEntity, new CameraComponent(
|
||||||
Matrix.CreatePerspectiveFieldOfView(
|
Matrix.CreatePerspectiveFieldOfView(
|
||||||
MathHelper.PiOver4,
|
Microsoft.Xna.Framework.MathHelper.PiOver4,
|
||||||
16f / 9f,
|
16f / 9f,
|
||||||
0.1f,
|
0.1f,
|
||||||
200f
|
200f
|
||||||
|
|
|
@ -25,7 +25,8 @@ namespace KavTest
|
||||||
|
|
||||||
public ArcballTransform RotateLocal(float deltaYaw, float deltaPitch)
|
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)
|
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