Add support for being notified when a camera path is complete.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3830 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-02-04 03:24:44 +00:00
parent 47f0772412
commit 428afd4ca0
2 changed files with 32 additions and 0 deletions
@@ -27,6 +27,8 @@ import com.jme.math.Plane;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.samskivert.util.ObserverList;
/**
* Provides various useful mechanisms for manipulating the camera.
*/
@@ -125,6 +127,7 @@ public class CameraHandler
{
if (_campath != null) {
_campath.abort();
_campathobs.apply(new CompletedOp(_campath));
}
_campath = path;
}
@@ -146,6 +149,7 @@ public class CameraHandler
{
if (_campath != null) {
if (_campath.tick(frameTime)) {
_campathobs.apply(new CompletedOp(_campath));
_campath = null;
}
}
@@ -317,8 +321,24 @@ public class CameraHandler
}
}
/** Used to dispatch {@link CameraPath.Observer#pathCompleted}. */
protected static class CompletedOp implements ObserverList.ObserverOp
{
public CompletedOp (CameraPath path) {
_path = path;
}
public boolean apply (Object observer) {
((CameraPath.Observer)observer).pathCompleted(_path);
return true;
}
protected CameraPath _path;
}
protected Camera _camera;
protected CameraPath _campath;
protected ObserverList _campathobs =
new ObserverList(ObserverList.SAFE_IN_ORDER_NOTIFY);
protected Matrix3f _rotm = new Matrix3f();
protected Vector3f _temp = new Vector3f();
@@ -28,6 +28,18 @@ import com.jme.renderer.Camera;
*/
public abstract class CameraPath
{
/** Used to inform observers when a camera path is completed or aborted. */
public interface Observer
{
/**
* Called when this path is finished (potentially early because another
* path was set before this path completed).
*
* @param path the path that was completed.
*/
public void pathCompleted (CameraPath path);
}
/**
* This is called on every frame to allow the path to adjust the position
* of the camera.