/** * Converts this quaternion to a rotation matrix and then extracts rotation axes. * * @param axes * the array of vectors to be filled. * @throws ArrayIndexOutOfBoundsException * if the given axes array is smaller than 3 elements. * @return the axes */ @Override public Vector3[] toAxes(final Vector3[] axes) { final Matrix3 tempMat = toRotationMatrix(Matrix3.fetchTempInstance()); axes[2] = tempMat.getColumn(2, axes[2]); axes[1] = tempMat.getColumn(1, axes[1]); axes[0] = tempMat.getColumn(0, axes[0]); Matrix3.releaseTempInstance(tempMat); return axes; }
/** * Converts this quaternion to a rotation matrix and then extracts rotation axes. * * @param axes * the array of vectors to be filled. * @throws ArrayIndexOutOfBoundsException * if the given axes array is smaller than 3 elements. * @return the axes */ @Override public Vector3[] toAxes(final Vector3[] axes) { final Matrix3 tempMat = toRotationMatrix(Matrix3.fetchTempInstance()); axes[2] = tempMat.getColumn(2, axes[2]); axes[1] = tempMat.getColumn(1, axes[1]); axes[0] = tempMat.getColumn(0, axes[0]); Matrix3.releaseTempInstance(tempMat); return axes; }
/** * Forces rotation and translation of this node to be sync'd with the attached camera. (Assumes the node is in world * space.) */ public void updateFromCamera() { final ReadOnlyVector3 camLeft = _camera.getLeft(); final ReadOnlyVector3 camUp = _camera.getUp(); final ReadOnlyVector3 camDir = _camera.getDirection(); final ReadOnlyVector3 camLoc = _camera.getLocation(); final Matrix3 rotation = Matrix3.fetchTempInstance(); rotation.fromAxes(camLeft, camUp, camDir); setRotation(rotation); setTranslation(camLoc); Matrix3.releaseTempInstance(rotation); }
@Override public boolean intersectsSphere(final BoundingSphere bs) { if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) { return false; } _compVect1.set(bs.getCenter()).subtractLocal(_center); final Matrix3 tempMa = Matrix3.fetchTempInstance().fromAxes(_xAxis, _yAxis, _zAxis); tempMa.applyPost(_compVect1, _compVect1); boolean result = false; if (Math.abs(_compVect1.getX()) < bs.getRadius() + _extent.getX() && Math.abs(_compVect1.getY()) < bs.getRadius() + _extent.getY() && Math.abs(_compVect1.getZ()) < bs.getRadius() + _extent.getZ()) { result = true; } Matrix3.releaseTempInstance(tempMa); return result; }
@Override public boolean intersectsSphere(final BoundingSphere bs) { if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) { return false; } _compVect1.set(bs.getCenter()).subtractLocal(_center); final Matrix3 tempMa = Matrix3.fetchTempInstance().fromAxes(_xAxis, _yAxis, _zAxis); tempMa.applyPost(_compVect1, _compVect1); boolean result = false; if (Math.abs(_compVect1.getX()) < bs.getRadius() + _extent.getX() && Math.abs(_compVect1.getY()) < bs.getRadius() + _extent.getY() && Math.abs(_compVect1.getZ()) < bs.getRadius() + _extent.getZ()) { result = true; } Matrix3.releaseTempInstance(tempMa); return result; }
public void stateChanged(final ChangeEvent e) { final Vector3 val = _rotationPanel.getValue().multiplyLocal(MathUtils.DEG_TO_RAD); final Matrix3 mat = Matrix3.fetchTempInstance().fromAngles(val.getX(), val.getY(), val.getZ()); getEdittedParticles().setRotation(mat); Matrix3.releaseTempInstance(mat); } });
/** * Forces rotation and translation of this node to be sync'd with the attached camera. (Assumes the node is in world * space.) */ public void updateFromCamera() { final ReadOnlyVector3 camLeft = _camera.getLeft(); final ReadOnlyVector3 camUp = _camera.getUp(); final ReadOnlyVector3 camDir = _camera.getDirection(); final ReadOnlyVector3 camLoc = _camera.getLocation(); final Matrix3 rotation = Matrix3.fetchTempInstance(); rotation.fromAxes(camLeft, camUp, camDir); setRotation(rotation); setTranslation(camLoc); Matrix3.releaseTempInstance(rotation); }
public ReadOnlyTransform getValue() { final Transform t = new Transform(); t.setTranslation(_translationX.getDoubleValue(), _translationY.getDoubleValue(), 0); final double val = _rotation.getDoubleValue() * MathUtils.DEG_TO_RAD; final Matrix3 mat = Matrix3.fetchTempInstance().fromAngles(0, 0, val); t.setRotation(mat); Matrix3.releaseTempInstance(mat); t.setScale(_scale.getDoubleValue()); return t; }
@Override public void update(final double time, final Spatial caller) { if (null == caller) { throw new IllegalArgumentException("caller can not be null!"); } final Vector3 interpolated = Vector3.fetchTempInstance(); final Matrix3 rotation = Matrix3.fetchTempInstance(); _curveController.interpolateVectors(_curveController.getControlFrom(), _curveController.getControlTo(), _curveController.getDelta(), interpolated); MathUtils.matrixLookAt(_previous, interpolated, _worldUp, rotation); if (isLocalRotation()) { caller.setRotation(rotation); } else { caller.setWorldRotation(rotation); } _previous.set(interpolated); Matrix3.releaseTempInstance(rotation); Vector3.releaseTempInstance(interpolated); }
@Override public void update(final double time, final Spatial caller) { if (null == caller) { throw new IllegalArgumentException("caller can not be null!"); } final Vector3 interpolated = Vector3.fetchTempInstance(); final Matrix3 rotation = Matrix3.fetchTempInstance(); _curveController.interpolateVectors(_curveController.getControlFrom(), _curveController.getControlTo(), _curveController.getDelta(), interpolated); MathUtils.matrixLookAt(_previous, interpolated, _worldUp, rotation); if (isLocalRotation()) { caller.setRotation(rotation); } else { caller.setWorldRotation(rotation); } _previous.set(interpolated); Matrix3.releaseTempInstance(rotation); Vector3.releaseTempInstance(interpolated); }
box.setZExtent(Math.abs(_compVect1.getZ())); Matrix3.releaseTempInstance(transMatrix);
box.setZExtent(Math.abs(_compVect1.getZ())); Matrix3.releaseTempInstance(transMatrix);
public ReadOnlyTransform getValue() { final Transform t = new Transform(); t.setTranslation(_translation.getValue()); final Vector3 val = _rotation.getValue().multiplyLocal(MathUtils.DEG_TO_RAD); final Matrix3 mat = Matrix3.fetchTempInstance().fromAngles(val.getX(), val.getY(), val.getZ()); t.setRotation(mat); Matrix3.releaseTempInstance(mat); t.setScale(_scale.getValue()); return t; }
Matrix3.releaseTempInstance(invertedMatrix);
Matrix3.releaseTempInstance(invertedMatrix);
Matrix3.releaseTempInstance(invertedMatrix);
Matrix3.releaseTempInstance(invertedMatrix);
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); }
Matrix3.releaseTempInstance(mat);