graphics.GLCameraController: respect angular limits
parent
a5a3110170
commit
5b2a6632e4
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue