@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; }
/** * 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); }
/** * 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); }
/** * Rotate the billboard so it points directly opposite the direction the camera's facing */ private void rotateScreenAligned() { final Camera camera = Camera.getCurrentCamera(); _look.set(camera.getDirection()).negateLocal(); _left.set(camera.getLeft()).negateLocal(); _orient.fromAxes(_left, camera.getUp(), _look); if(_localRot != null) _orient.multiplyLocal(_localRot); _worldTransform.setRotation(_orient); }
/** * Rotate the billboard so it points directly opposite the direction the camera's facing * * @param camera * Camera */ private void rotateScreenAligned() { final Camera camera = Camera.getCurrentCamera(); // coopt diff for our in direction: _look.set(camera.getDirection()).negateLocal(); // coopt loc for our left direction: _left.set(camera.getLeft()).negateLocal(); _orient.fromAxes(_left, camera.getUp(), _look); _worldTransform.setRotation(_orient); }
/** * * @param cam */ public void correctTransform(final Camera cam) { updateWorldTransform(false); if (_autoRotate) { // Billboard rotation _look.set(cam.getDirection()); _left.set(cam.getLeft()).negateLocal(); _rot.fromAxes(_left, _look, cam.getUp()); if (_rot.isOrthonormal()) { _worldTransform.setRotation(_rot); } else { logger.warning("BMText: non-orthonormal rotation matrix :" + getName()); } } _worldTransform.setScale(_localTransform.getScale()); }
/** * * @param cam */ public void correctTransform(final Camera cam) { updateWorldTransform(false); if (_autoRotate) { // Billboard rotation _look.set(cam.getDirection()); _left.set(cam.getLeft()).negateLocal(); _rot.fromAxes(_left, _look, cam.getUp()); _worldTransform.setRotation(_rot); } _worldTransform.setScale(_localTransform.getScale()); }
/** * Modifies this matrix to equal the rotation required to point the z-axis at 'direction' and the y-axis to 'up'. * * @param direction * where to 'look' at * @param up * a vector indicating the local up direction. * @return this matrix for chaining */ public Matrix3 lookAt(final ReadOnlyVector3 direction, final ReadOnlyVector3 up) { final Vector3 xAxis = Vector3.fetchTempInstance(); final Vector3 yAxis = Vector3.fetchTempInstance(); final Vector3 zAxis = Vector3.fetchTempInstance(); direction.normalize(zAxis); up.normalize(xAxis).crossLocal(zAxis).normalizeLocal(); zAxis.cross(xAxis, yAxis); fromAxes(xAxis, yAxis, zAxis); Vector3.releaseTempInstance(xAxis); Vector3.releaseTempInstance(yAxis); Vector3.releaseTempInstance(zAxis); return this; }
/** * Modifies this matrix to equal the rotation required to point the z-axis at 'direction' and the y-axis to 'up'. * * @param direction * where to 'look' at * @param up * a vector indicating the local up direction. * @return this matrix for chaining */ public Matrix3 lookAt(final ReadOnlyVector3 direction, final ReadOnlyVector3 up) { final Vector3 xAxis = Vector3.fetchTempInstance(); final Vector3 yAxis = Vector3.fetchTempInstance(); final Vector3 zAxis = Vector3.fetchTempInstance(); direction.normalize(zAxis); up.normalize(xAxis).crossLocal(zAxis).normalizeLocal(); zAxis.cross(xAxis, yAxis); fromAxes(xAxis, yAxis, zAxis); Vector3.releaseTempInstance(xAxis); Vector3.releaseTempInstance(yAxis); Vector3.releaseTempInstance(zAxis); return this; }
/** * 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); }
mat3A.fromAxes(new Vector3(1, 2, 3), new Vector3(4, 5, 6), new Vector3(7, 8, 9)); mat3A.setColumn(0, new Vector3(1, 2, 3)); mat3A.setColumn(1, new Vector3(4, 5, 6));