diff --git a/org.budnhead/graphics/GLCameraController.cs b/org.budnhead/graphics/GLCameraController.cs index 829843a..e84adbf 100644 --- a/org.budnhead/graphics/GLCameraController.cs +++ b/org.budnhead/graphics/GLCameraController.cs @@ -23,8 +23,8 @@ namespace org.budnhead.graphics private Point mouseCapturePosition; private bool mouseCaptured; - public Limits LimitUpDown { get; set; } = new Limits(-MathHelper.PiOver2,-MathHelper.Pi / 16); - public Limits LimitLeftRight { get; set; } = new Limits(-Math.PI, Math.PI); + public Limits LimitUpDown { get; set; } = new Limits(MathHelper.PiOver2,MathHelper.Pi); + public Limits LimitLeftRight { get; set; } = new Limits(-MathHelper.Pi, MathHelper.Pi); public GLCameraController(GLCamera camera, SceneWindow sceneWindow){ @@ -148,8 +148,18 @@ namespace org.budnhead.graphics v *= mrot; t *= mrot; - camera.View = v; - camera.Top = t; + float angle = (float)Math.Acos(Vector3.Dot(v, Vector3.UnitZ)); + + if ((camera.View.X * v.X <= 0)||(camera.View.Y * v.Y <= 0)){ + angle = (float)((2 * Math.PI) - angle); + } + + Console.WriteLine("Angle: {0}",angle); + + if (LimitUpDown.ValueIsValid(angle)){ + camera.View = v; + camera.Top = t; + } } public void rotateLeftRight(float arc) { @@ -166,8 +176,13 @@ namespace org.budnhead.graphics v *= mrot; t *= mrot; - camera.View = v; - camera.Top = t; + float angle = (float)Math.Acos(Vector2.Dot(v.Xy, Vector2.UnitY)); + + if (LimitLeftRight.ValueIsValid(angle)) + { + camera.View = v; + camera.Top = t; + } } public void walk(float distance)