diff options
Diffstat (limited to 'src/net/java/joglutils/msg/nodes/Camera.java')
-rw-r--r-- | src/net/java/joglutils/msg/nodes/Camera.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/net/java/joglutils/msg/nodes/Camera.java b/src/net/java/joglutils/msg/nodes/Camera.java index 04380f1..8dc63d4 100644 --- a/src/net/java/joglutils/msg/nodes/Camera.java +++ b/src/net/java/joglutils/msg/nodes/Camera.java @@ -216,18 +216,21 @@ public abstract class Camera extends Node { Vec3f to = new Vec3f(unproj.x() * ooZ, unproj.y() * ooZ, unproj.z() * ooZ); - // FIXME: for orthographic projections, need to do something - // different; can't just use the eye point - Vec3f from = getPosition(); + Vec3f from = getRayStartPoint(point, to); Vec3f dir = to.minus(from); - // System.err.println("unprojected point: " + from); + // System.err.println("unprojected point: " + to); // System.err.println("unprojected dir : " + dir); line.setPoint(from); line.setDirection(dir); } + /** Computes the start point of a ray for picking, given a point in + normalized screen coordinates ((0, 0) to (1, 1)) and a 3D point + which that point unprojects to. */ + protected abstract Vec3f getRayStartPoint(Vec2f point, Vec3f unprojectedPoint); + public void doAction(Action action) { if (ViewingMatrixElement.isEnabled(action.getState())) { ViewingMatrixElement.set(action.getState(), getViewingMatrix()); |