/** * Gets the local translation vector. * * @return the translation */ public ReadOnlyVector3 getTranslation() { return _localTransform.getTranslation(); }
/** * Gets the local translation vector. * * @return the translation */ public ReadOnlyVector3 getTranslation() { return _localTransform.getTranslation(); }
/** * Gets the world translation vector. * * @return the world translation */ public ReadOnlyVector3 getWorldTranslation() { return _worldTransform.getTranslation(); }
/** * Gets the world translation vector. * * @return the world translation */ public ReadOnlyVector3 getWorldTranslation() { return _worldTransform.getTranslation(); }
@Override public void drawTo(final BufferedImage image, final ReadOnlyTransform localTransform, final int clipmapLevel) { // apply the two transforms together and then use result to scale/translate and rotate image final Transform trans = new Transform(); localTransform.multiply(getTransform(), trans); // grab a copy of the graphics so we don't bleed state to next image final Graphics2D g2d = (Graphics2D) image.getGraphics().create(); // apply hints for (final RenderingHints.Key key : hints.keySet()) { g2d.setRenderingHint(key, hints.get(key)); } // set transform g2d.translate(trans.getTranslation().getX(), trans.getTranslation().getY()); g2d.rotate(trans.getMatrix().toAngles(null)[2]); // rotation about z g2d.scale(trans.getScale().getX(), trans.getScale().getY()); // set composite if (_compositeOverride != null) { g2d.setComposite(_compositeOverride); } // draw the image g2d.drawImage(_image, 0, 0, null); } }
@Override public void drawTo(final BufferedImage image, final ReadOnlyTransform localTransform, final int clipmapLevel) { // apply the two transforms together and then use result to scale/translate and rotate image final Transform trans = new Transform(); localTransform.multiply(getTransform(), trans); // grab a copy of the graphics so we don't bleed state to next image final Graphics2D g2d = (Graphics2D) image.getGraphics().create(); // apply hints for (final RenderingHints.Key key : hints.keySet()) { g2d.setRenderingHint(key, hints.get(key)); } // set transform g2d.translate(trans.getTranslation().getX(), trans.getTranslation().getY()); g2d.rotate(trans.getMatrix().toAngles(null)[2]); // rotation about z g2d.scale(trans.getScale().getX(), trans.getScale().getY()); // set composite if (_compositeOverride != null) { g2d.setComposite(_compositeOverride); } // draw the image g2d.drawImage(_image, 0, 0, null); } }
g2d.translate(trans.getTranslation().getX(), trans.getTranslation().getY()); g2d.rotate(trans.getMatrix().toAngles(null)[2]); // rotation about z g2d.scale(trans.getScale().getX(), trans.getScale().getY());
g2d.translate(trans.getTranslation().getX(), trans.getTranslation().getY()); g2d.rotate(trans.getMatrix().toAngles(null)[2]); // rotation about z g2d.scale(trans.getScale().getX(), trans.getScale().getY());
@Test public void testTranslate() { final Transform trans = new Transform(); trans.translate(1, 3, 5); assertEquals(new Vector3(1, 3, 5), trans.getTranslation()); trans.translate(trans.getTranslation().negate(null)); assertEquals(Vector3.ZERO, trans.getTranslation()); trans.translate(new Vector3(1, 3, 5)); assertEquals(new Vector3(1, 3, 5), trans.getTranslation()); trans.translate(-1, -3, -5); assertEquals(Vector3.ZERO, trans.getTranslation()); }
@Override public void applyFilter(final InteractManager manager) { final SpatialState state = manager.getSpatialState(); _calcVectorA.set(state.getTransform().getTranslation()); for (final ReadOnlyPlane plane : _planes) { final double distance = plane.pseudoDistance(_calcVectorA); if (distance < 0) { // push us back to the plane. _calcVectorB.set(plane.getNormal()).multiplyLocal(-distance); _calcVectorA.addLocal(_calcVectorB); } } state.getTransform().setTranslation(_calcVectorA); }
/** * Aligns this Billboard Node so that it points to the camera position. */ private void rotateCameraAligned() { final Camera camera = Camera.getCurrentCamera(); _look.set(camera.getLocation()).subtractLocal(_worldTransform.getTranslation()).normalizeLocal(); _left.set(camera.getUp()).crossLocal(_look); final Vector3 up = Vector3.fetchTempInstance(); up.set(_look).crossLocal(_left); _orient.fromAxes(_left, up, _look); if(_localRot != null) _orient.multiplyLocal(_localRot); _worldTransform.setRotation(_orient); Vector3.releaseTempInstance(up); }
public void reconstruct(final Vector3 top, final Vector3 bottom, final double radius) { // our temp vars final Vector3 localTranslation = Vector3.fetchTempInstance(); final Vector3 capsuleUp = Vector3.fetchTempInstance(); // first make the capsule the right shape height = top.distance(bottom); this.radius = radius; setGeometryData(); // now orient it in space. localTranslation.set(_localTransform.getTranslation()); top.add(bottom, localTranslation).multiplyLocal(.5); // rotation that takes us from 0,1,0 to the unit vector described by top/center. top.subtract(localTranslation, capsuleUp).normalizeLocal(); final Matrix3 rotation = Matrix3.fetchTempInstance(); rotation.fromStartEndLocal(Vector3.UNIT_Y, capsuleUp); _localTransform.setRotation(rotation); Vector3.releaseTempInstance(localTranslation); Vector3.releaseTempInstance(capsuleUp); Matrix3.releaseTempInstance(rotation); updateWorldTransform(false); }
public void reconstruct(final Vector3 top, final Vector3 bottom, final double radius) { // our temp vars final Vector3 localTranslation = Vector3.fetchTempInstance(); final Vector3 capsuleUp = Vector3.fetchTempInstance(); // first make the capsule the right shape height = top.distance(bottom); this.radius = radius; setGeometryData(); // now orient it in space. localTranslation.set(_localTransform.getTranslation()); top.add(bottom, localTranslation).multiplyLocal(.5); // rotation that takes us from 0,1,0 to the unit vector described by top/center. top.subtract(localTranslation, capsuleUp).normalizeLocal(); final Matrix3 rotation = Matrix3.fetchTempInstance(); rotation.fromStartEndLocal(Vector3.UNIT_Y, capsuleUp); _localTransform.setRotation(rotation); Vector3.releaseTempInstance(localTranslation); Vector3.releaseTempInstance(capsuleUp); Matrix3.releaseTempInstance(rotation); updateWorldTransform(false); }
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final Vector3 loc = getNewOffset(oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); transform.setTranslation(loc.addLocal(transform.getTranslation())); // apply our filters, if any, now that we've made updates. applyFilters(manager); }
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag if (_lastDragSpatial != null && _lastDragSpatial.getParent() instanceof InteractArrow) { final InteractArrow arrow = (InteractArrow) _lastDragSpatial.getParent(); _lastArrow = arrow; final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final Vector3 loc = getNewOffset(arrow, oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); transform.setTranslation(loc.addLocal(transform.getTranslation())); // apply our filters, if any, now that we've made updates. applyFilters(manager); } }
_look.negateLocal().addLocal(_worldTransform.getTranslation());
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag final PickData pickData = _results.getNumber() > 0 ? _results.getPickData(0) : null; if (pickData != null && _lastDragSpatial instanceof Mesh && pickData.getIntersectionRecord().getNumberOfIntersections() > 0) { final PrimitiveKey key = pickData.getIntersectionRecord().getIntersectionPrimitive(0); ((Mesh) _lastDragSpatial).getMeshData().getPrimitiveVertices(key.getPrimitiveIndex(), key.getSection(), new Vector3[] { _calcVec3A, _calcVec3B, _calcVec3C }); _lastDragSpatial.localToWorld(_calcVec3A, _calcVec3A); _lastDragSpatial.localToWorld(_calcVec3B, _calcVec3B); _lastDragSpatial.localToWorld(_calcVec3C, _calcVec3C); final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final Vector3 loc = getNewOffset(oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); transform.setTranslation(loc.addLocal(transform.getTranslation())); // apply our filters, if any, now that we've made updates. applyFilters(manager); } }
_look.set(camera.getLocation()).subtractLocal(_worldTransform.getTranslation());
_look.set(camera.getLocation()).subtractLocal(_worldTransform.getTranslation()); final Matrix3 worldMatrix = Matrix3.fetchTempInstance().set(_worldTransform.getMatrix());
matrixA.applyPost(transformBy.getTranslation(), newTranslate).addLocal(getTranslation());