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); } }
final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B, _calcVec3C.addLocal(_calcVec3A));
final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B.addLocal(_calcVec3A), _calcVec3C.addLocal(_calcVec3A));
final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B.addLocal(_calcVec3A), _calcVec3C.addLocal(_calcVec3A));
@Test public void testGetSet() { final Plane plane = new Plane(); assertEquals(Vector3.UNIT_Y, plane.getNormal()); assertTrue(plane.getConstant() == 0.0); plane.setNormal(Vector3.UNIT_X); plane.setConstant(1.0); assertEquals(Vector3.UNIT_X, plane.getNormal()); assertTrue(plane.getConstant() == 1.0); final Plane plane2 = new Plane(plane); assertEquals(Vector3.UNIT_X, plane2.getNormal()); assertTrue(plane.getConstant() == 1.0); final Plane plane3 = new Plane(Vector3.NEG_UNIT_Z, 2.5); assertEquals(Vector3.NEG_UNIT_Z, plane3.getNormal()); assertTrue(plane3.getConstant() == 2.5); final Plane plane4 = new Plane().setPlanePoints(new Vector3(1, 1, 1), new Vector3(2, 1, 1), new Vector3(2, 2, 1)); assertEquals(Vector3.UNIT_Z, plane4.getNormal()); assertTrue(plane4.getConstant() == 1.0); }