Vector3f thisWorld = ((InputManager3D)InputManager3D.getInputManager()).
getCamera().getWorldCoordinates(scrPos, 0f);
logger.fine("thisWorld = " + thisWorld);
// The calculations need to take place in eye space. Get the necessary matrices.
Matrix4f camMatrix = InputPicker3D.getInputPicker().getCameraModelViewMatrix(null);
Matrix4f camInverse = InputPicker3D.getInputPicker().getCameraModelViewMatrixInverse(null);
logger.finest("camInverse = " + camInverse);
// Transform vectors from world space into eye space
Vector3f dragEye = new Vector3f();
Vector3f dragStartEye = new Vector3f();
Vector3f pressEye = new Vector3f();
Vector3f eyeEye = new Vector3f();
Vector3f thisEye = new Vector3f();
camInverse.mult(dragWorld, dragEye);
camInverse.mult(dragStartWorld, dragStartEye);
camInverse.mult(pressWorld, pressEye);
// TODO: perf: only really need to recalc eyeEye on camera change
camInverse.mult(eyeWorld, eyeEye);
camInverse.mult(thisWorld, thisEye);
// The displacement vector of this event from the center of the drag plane
Vector3f dragVectorEye = new Vector3f(
(dragEye.x - pressEye.x) * (dragStartEye.z - eyeEye.z) / (thisEye.z - eyeEye.z),
(pressEye.y - dragEye.y) * (dragStartEye.z - eyeEye.z) / (thisEye.z - eyeEye.z),