Added support for smoothly rotating the camera.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3699 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -90,13 +90,41 @@ public class GodViewHandler extends InputHandler
|
|||||||
return (_camera.getLocation().z - _minZ) / (_maxZ - _minZ);
|
return (_camera.getLocation().z - _minZ) / (_maxZ - _minZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the rotational velocity of the camera, which is used to
|
||||||
|
* smoothly slide the camera to its new position following a call to
|
||||||
|
* {@link #rotateCamera}.
|
||||||
|
*/
|
||||||
|
public void setRotateVelocity (float radiansPerSecond)
|
||||||
|
{
|
||||||
|
_rotateVelocity = radiansPerSecond;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swings the camera around the point on the ground at which it is
|
* Swings the camera around the point on the ground at which it is
|
||||||
* "looking", by the requested angle (in radians).
|
* "looking", by the requested angle (in radians). The camera does not
|
||||||
|
* jump by the specified angle but rather smoothly rotates there.
|
||||||
*/
|
*/
|
||||||
public void rotateCamera (float deltaAngle)
|
public void rotateCamera (float deltaAngle)
|
||||||
{
|
{
|
||||||
rotateCamera(_groundNormal, deltaAngle);
|
_rotateDelta += deltaAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void update (float time)
|
||||||
|
{
|
||||||
|
super.update(time);
|
||||||
|
|
||||||
|
float deltaAngle = 0;
|
||||||
|
if (_rotateDelta < 0) {
|
||||||
|
deltaAngle = Math.min(time * _rotateVelocity, -_rotateDelta);
|
||||||
|
} else if (_rotateDelta > 0) {
|
||||||
|
deltaAngle = Math.max(-1f * time * _rotateVelocity, -_rotateDelta);
|
||||||
|
}
|
||||||
|
if (deltaAngle != 0) {
|
||||||
|
_rotateDelta += deltaAngle;
|
||||||
|
rotateCamera(_groundNormal, deltaAngle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setKeyBindings (String api)
|
protected void setKeyBindings (String api)
|
||||||
@@ -350,6 +378,8 @@ public class GodViewHandler extends InputHandler
|
|||||||
protected Camera _camera;
|
protected Camera _camera;
|
||||||
protected Matrix3f _rotm = new Matrix3f();
|
protected Matrix3f _rotm = new Matrix3f();
|
||||||
|
|
||||||
|
protected float _rotateVelocity = 3*FastMath.PI/2, _rotateDelta;
|
||||||
|
|
||||||
protected float _minX = Float.MIN_VALUE, _maxX = Float.MAX_VALUE;
|
protected float _minX = Float.MIN_VALUE, _maxX = Float.MAX_VALUE;
|
||||||
protected float _minY = Float.MIN_VALUE, _maxY = Float.MAX_VALUE;
|
protected float _minY = Float.MIN_VALUE, _maxY = Float.MAX_VALUE;
|
||||||
protected float _minZ = Float.MIN_VALUE, _maxZ = Float.MAX_VALUE;
|
protected float _minZ = Float.MIN_VALUE, _maxZ = Float.MAX_VALUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user