graphics.GLCameraController: respect angular limits

master
Harald Wolff 2017-06-10 23:11:29 +02:00
parent a5a3110170
commit 5b2a6632e4
1 changed files with 21 additions and 6 deletions

View File

@ -23,8 +23,8 @@ namespace org.budnhead.graphics
private Point mouseCapturePosition; private Point mouseCapturePosition;
private bool mouseCaptured; private bool mouseCaptured;
public Limits LimitUpDown { get; set; } = new Limits(-MathHelper.PiOver2,-MathHelper.Pi / 16); public Limits LimitUpDown { get; set; } = new Limits(MathHelper.PiOver2,MathHelper.Pi);
public Limits LimitLeftRight { get; set; } = new Limits(-Math.PI, Math.PI); public Limits LimitLeftRight { get; set; } = new Limits(-MathHelper.Pi, MathHelper.Pi);
public GLCameraController(GLCamera camera, SceneWindow sceneWindow){ public GLCameraController(GLCamera camera, SceneWindow sceneWindow){
@ -148,8 +148,18 @@ namespace org.budnhead.graphics
v *= mrot; v *= mrot;
t *= mrot; t *= mrot;
camera.View = v; float angle = (float)Math.Acos(Vector3.Dot(v, Vector3.UnitZ));
camera.Top = t;
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) public void rotateLeftRight(float arc)
{ {
@ -166,8 +176,13 @@ namespace org.budnhead.graphics
v *= mrot; v *= mrot;
t *= mrot; t *= mrot;
camera.View = v; float angle = (float)Math.Acos(Vector2.Dot(v.Xy, Vector2.UnitY));
camera.Top = t;
if (LimitLeftRight.ValueIsValid(angle))
{
camera.View = v;
camera.Top = t;
}
} }
public void walk(float distance) public void walk(float distance)