Revamped camera handling. We now have a camera handler through which all camera

manipulations pass. It can then ensure that the camera remains within zoom and
pan boundaries and is generally in the right place. It also handles camera
paths, which adjust the camera through the handler. The input handler now has
no camera logic but simply wires up camera manipulations to input mechanisms
which is much cleaner.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3752 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-11-09 22:30:02 +00:00
parent 86abf1675f
commit 35caa3a79f
5 changed files with 344 additions and 301 deletions
+19 -35
View File
@@ -51,8 +51,7 @@ import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.util.Timer;
import com.threerings.jme.camera.CameraPath;
import com.threerings.jme.camera.GodViewHandler;
import com.threerings.jme.camera.CameraHandler;
/**
* Defines a basic application framework providing integration with the
@@ -181,27 +180,6 @@ public class JmeApp
}
}
/**
* Starts the camera moving along a path which will be updated every tick
* until it is complete.
*/
public void moveCamera (CameraPath path)
{
if (_campath != null) {
_campath.abort();
}
_campath = path;
}
/**
* Returns true if the camera is currently animating along a path, false if
* it is not.
*/
public boolean cameraIsMoving ()
{
return (_campath != null);
}
/**
* Instructs the application to stop the main loop, cleanup and exit.
*/
@@ -293,16 +271,26 @@ public class JmeApp
*/
protected void initInput ()
{
_input = createInputHandler(_camera, _properties.getRenderer());
_camhand = createCameraHandler(_camera);
_input = createInputHandler(_camhand, _properties.getRenderer());
}
/**
* Creates the input handler used to control our camera and manage
* non-UI keyboard input.
* Creates the camera handler which provides various camera manipulation
* functionality.
*/
protected InputHandler createInputHandler (Camera camera, String api)
protected CameraHandler createCameraHandler (Camera camera)
{
return new GodViewHandler(camera, api);
return new CameraHandler(camera);
}
/**
* Creates the input handler used to control our camera and manage non-UI
* keyboard input.
*/
protected InputHandler createInputHandler (CameraHandler camhand, String api)
{
return new InputHandler();
}
/**
@@ -416,12 +404,8 @@ public class JmeApp
float timePerFrame = _timer.getTimePerFrame();
_root.updateGeometricState(timePerFrame, true);
// if there's a camera path, update that as well
if (_campath != null) {
if (_campath.tick(timePerFrame)) {
_campath = null;
}
}
// update the camera handler
_camhand.update(timePerFrame);
// update our stats display if we have one
if (_stats != null) {
@@ -538,7 +522,7 @@ public class JmeApp
protected PropertiesIO _properties;
protected DisplaySystem _display;
protected Camera _camera;
protected CameraPath _campath;
protected CameraHandler _camhand;
protected InputHandler _input;
protected BRootNode _rnode;