graphics.GLCameraController: respect angular limits
parent
a5a3110170
commit
5b2a6632e4
|
@ -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,9 +148,19 @@ namespace org.budnhead.graphics
|
||||||
v *= mrot;
|
v *= mrot;
|
||||||
t *= mrot;
|
t *= mrot;
|
||||||
|
|
||||||
|
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.View = v;
|
||||||
camera.Top = t;
|
camera.Top = t;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void rotateLeftRight(float arc)
|
public void rotateLeftRight(float arc)
|
||||||
{
|
{
|
||||||
Vector3 v, // view direction
|
Vector3 v, // view direction
|
||||||
|
@ -166,9 +176,14 @@ namespace org.budnhead.graphics
|
||||||
v *= mrot;
|
v *= mrot;
|
||||||
t *= mrot;
|
t *= mrot;
|
||||||
|
|
||||||
|
float angle = (float)Math.Acos(Vector2.Dot(v.Xy, Vector2.UnitY));
|
||||||
|
|
||||||
|
if (LimitLeftRight.ValueIsValid(angle))
|
||||||
|
{
|
||||||
camera.View = v;
|
camera.View = v;
|
||||||
camera.Top = t;
|
camera.Top = t;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void walk(float distance)
|
public void walk(float distance)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue