protected Vector3 getNewOffset(final Vector2 oldMouse, final MouseState current, final Camera camera, final InteractManager manager) { // make plane object final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B, _calcVec3C); // find out where we were hitting the plane before getPickRay(oldMouse, camera); if (!_calcRay.intersectsPlane(pickPlane, _calcVec3A)) { return _calcVec3A.zero(); } // find out where we are hitting the plane now getPickRay(new Vector2(current.getX(), current.getY()), camera); if (!_calcRay.intersectsPlane(pickPlane, _calcVec3B)) { return _calcVec3A.zero(); } // convert to target coord space final Node parent = manager.getSpatialTarget().getParent(); if (parent != null) { parent.getWorldTransform().applyInverse(_calcVec3A); parent.getWorldTransform().applyInverse(_calcVec3B); } return _calcVec3B.subtractLocal(_calcVec3A); } }
protected double getNewScale(final Vector2 oldMouse, final MouseState current, final Camera camera, final InteractManager manager) { // calculate a plane running through the Arrow and facing the camera. _calcVec3A.set(_handle.getWorldTranslation()); _calcVec3B.set(_calcVec3A).addLocal(camera.getLeft()); _calcVec3C.set(_calcVec3A).addLocal(_arrowDirection); final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B, _calcVec3C); // find out where we were hitting the plane before getPickRay(oldMouse, camera); _calcRay.intersectsPlane(pickPlane, _calcVec3A); final double oldHeight = _calcVec3A.getY(); // find out where we are hitting the plane now getPickRay(new Vector2(current.getX(), current.getY()), camera); _calcRay.intersectsPlane(pickPlane, _calcVec3A); final double newHeight = _calcVec3A.getY(); // Use distance between points against arrow length to determine how big we need to grow our bounding radius final double delta = newHeight - oldHeight; final double oldRadius = manager.getSpatialTarget().getWorldBound().getRadius(); return manager.getSpatialTarget().getScale().getY() * (1.0 + delta / oldRadius); } }
assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertTrue(pickRay.intersectsPlane(plane, intersectionPoint)); assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertTrue(pickRay.intersectsPlane(plane, intersectionPoint)); assertTrue(pickRay.intersectsPlane(plane, intersectionPoint)); assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertFalse(pickRay.intersectsPlane(plane, intersectionPoint)); assertTrue(pickRay.intersectsPlane(plane, null));
if (!_calcRay.intersectsPlane(pickPlane, _calcVec3A)) { return _calcVec3A.zero(); if (!_calcRay.intersectsPlane(pickPlane, _calcVec3B)) { return _calcVec3A.zero();
if (!_calcRay.intersectsPlane(pickPlane, _calcVec3A)) { return _calcVec3A.zero(); if (!_calcRay.intersectsPlane(pickPlane, _calcVec3B)) { return _calcVec3A.zero();
if (!_calcRay.intersectsPlane(pickPlane, _calcVec3A)) { return Quaternion.IDENTITY; if (!_calcRay.intersectsPlane(pickPlane, _calcVec3B)) { return Quaternion.IDENTITY;