private void put(final FloatBuffer fb, final FloatBuffer nb, final Vector3 vec) { fb.put((float) vec.getX()).put((float) vec.getY()).put((float) vec.getZ()); final Vector3 v = vec.normalize(Vector3.fetchTempInstance()); nb.put((float) v.getX()).put((float) v.getY()).put((float) v.getZ()); Vector3.releaseTempInstance(v); }
private void put(final FloatBuffer fb, final FloatBuffer nb, final Vector3 vec) { fb.put((float) vec.getX()).put((float) vec.getY()).put((float) vec.getZ()); final Vector3 v = vec.normalize(Vector3.fetchTempInstance()); nb.put((float) v.getX()).put((float) v.getY()).put((float) v.getZ()); Vector3.releaseTempInstance(v); }
/** * Normalize a Vector3 in-buffer. * * @param buf * the buffer to find the Vector3 within * @param index * the position (in terms of vectors, not floats) of the vector to normalize */ public static void normalizeVector3(final FloatBuffer buf, final int index) { final Vector3 temp = Vector3.fetchTempInstance(); populateFromBuffer(temp, buf, index); temp.normalizeLocal(); setInBuffer(temp, buf, index); Vector3.releaseTempInstance(temp); }
/** * Normalize a Vector3 in-buffer. * * @param buf * the buffer to find the Vector3 within * @param index * the position (in terms of vectors, not floats) of the vector to normalize */ public static void normalizeVector3(final FloatBuffer buf, final int index) { final Vector3 temp = Vector3.fetchTempInstance(); populateFromBuffer(temp, buf, index); temp.normalizeLocal(); setInBuffer(temp, buf, index); Vector3.releaseTempInstance(temp); }
/** * Add to a Vector3 in-buffer. * * @param toAdd * the vector to add from * @param buf * the buffer to find the Vector3 within * @param index * the position (in terms of vectors, not floats) of the vector to add to */ public static void addInBuffer(final ReadOnlyVector3 toAdd, final FloatBuffer buf, final int index) { final Vector3 temp = Vector3.fetchTempInstance(); populateFromBuffer(temp, buf, index); temp.addLocal(toAdd); setInBuffer(temp, buf, index); Vector3.releaseTempInstance(temp); }
/** * Multiply and store a Vector3 in-buffer. * * @param toMult * the vector to multiply against * @param buf * the buffer to find the Vector3 within * @param index * the position (in terms of vectors, not floats) of the vector to multiply */ public static void multInBuffer(final ReadOnlyVector3 toMult, final FloatBuffer buf, final int index) { final Vector3 temp = Vector3.fetchTempInstance(); populateFromBuffer(temp, buf, index); temp.multiplyLocal(toMult); setInBuffer(temp, buf, index); Vector3.releaseTempInstance(temp); }
/** * Multiply and store a Vector3 in-buffer. * * @param toMult * the vector to multiply against * @param buf * the buffer to find the Vector3 within * @param index * the position (in terms of vectors, not floats) of the vector to multiply */ public static void multInBuffer(final ReadOnlyVector3 toMult, final FloatBuffer buf, final int index) { final Vector3 temp = Vector3.fetchTempInstance(); populateFromBuffer(temp, buf, index); temp.multiplyLocal(toMult); setInBuffer(temp, buf, index); Vector3.releaseTempInstance(temp); }
public void startDrag(final int mouseX, final int mouseY) { final Vector3 vec = Vector3.fetchTempInstance(); vec.set(mouseX, mouseY, 0); _uiFrameStatusBar.getWorldTransform().applyInverseVector(vec); _initialX = Math.round(vec.getXf()); _initialY = Math.round(vec.getYf()); Vector3.releaseTempInstance(vec); final UIFrame frame = UIFrame.findParentFrame(_uiFrameStatusBar); _initialLocalComponentWidth = frame.getLocalComponentWidth(); _initialLocalComponentHeight = frame.getLocalComponentHeight(); _initFrameTransform.set(frame.getWorldTransform()); }
public void startDrag(final int mouseX, final int mouseY) { final Vector3 vec = Vector3.fetchTempInstance(); vec.set(mouseX, mouseY, 0); _uiFrameStatusBar.getWorldTransform().applyInverseVector(vec); _initialX = Math.round(vec.getXf()); _initialY = Math.round(vec.getYf()); Vector3.releaseTempInstance(vec); final UIFrame frame = UIFrame.findParentFrame(_uiFrameStatusBar); _initialLocalComponentWidth = frame.getLocalComponentWidth(); _initialLocalComponentHeight = frame.getLocalComponentHeight(); _initFrameTransform.set(frame.getWorldTransform()); }
public double eval(final double x, final double y, final double z) { final Vector3 temp = Vector3.fetchTempInstance(); temp.set(x, y, z); rotation.applyPost(temp, temp); final double val = source.eval(temp.getX(), temp.getY(), temp.getZ()); Vector3.releaseTempInstance(temp); return val; } };
public double eval(final double x, final double y, final double z) { final Vector3 temp = Vector3.fetchTempInstance(); temp.set(x, y, z); rotation.applyPost(temp, temp); final double val = source.eval(temp.getX(), temp.getY(), temp.getZ()); Vector3.releaseTempInstance(temp); return val; } };
public void killParticle() { setStatus(Status.Dead); final Vector3 tempVec3 = Vector3.fetchTempInstance(); final FloatBuffer vertexBuffer = parent.getParticleGeometry().getMeshData().getVertexBuffer(); BufferUtils.populateFromBuffer(tempVec3, vertexBuffer, startIndex); final int verts = ParticleSystem.getVertsForParticleType(type); for (int x = 1; x < verts; x++) { BufferUtils.setInBuffer(tempVec3, vertexBuffer, startIndex + x); } Vector3.releaseTempInstance(tempVec3); }
public void killParticle() { setStatus(Status.Dead); final Vector3 tempVec3 = Vector3.fetchTempInstance(); final FloatBuffer vertexBuffer = parent.getParticleGeometry().getMeshData().getVertexBuffer(); BufferUtils.populateFromBuffer(tempVec3, vertexBuffer, startIndex); final int verts = ParticleSystem.getVertsForParticleType(type); for (int x = 1; x < verts; x++) { BufferUtils.setInBuffer(tempVec3, vertexBuffer, startIndex + x); } Vector3.releaseTempInstance(tempVec3); }
public void updateLeftRightCameraFrames() { // update camera frame final Vector3 rightDir = Vector3.fetchTempInstance(); final Vector3 work = Vector3.fetchTempInstance(); rightDir.set(getDirection()).crossLocal(getUp()).multiplyLocal(_eyeSeparation / 2.0); _leftCamera.setFrame(getLocation().subtract(rightDir, work), getLeft(), getUp(), getDirection()); _rightCamera.setFrame(getLocation().add(rightDir, work), getLeft(), getUp(), getDirection()); Vector3.releaseTempInstance(work); Vector3.releaseTempInstance(rightDir); }
public void updateLeftRightCameraFrames() { // update camera frame final Vector3 rightDir = Vector3.fetchTempInstance(); final Vector3 work = Vector3.fetchTempInstance(); rightDir.set(getDirection()).crossLocal(getUp()).multiplyLocal(_eyeSeparation / 2.0); _leftCamera.setFrame(getLocation().subtract(rightDir, work), getLeft(), getUp(), getDirection()); _rightCamera.setFrame(getLocation().add(rightDir, work), getLeft(), getUp(), getDirection()); Vector3.releaseTempInstance(work); Vector3.releaseTempInstance(rightDir); }
/** * 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 stateChanged(final ChangeEvent e) { final Rectangle3 rect = ((RectangleEmitter) getEdittedParticles().getParticleEmitter()).getSource(); final double width = _rectWidthPanel.getDoubleValue(); final Vector3 helper = Vector3.fetchTempInstance(); helper.set(rect.getA()).setX(-width / 2.0); rect.setA(helper); helper.set(rect.getB()).setX(width / 2.0); rect.setB(helper); helper.set(rect.getC()).setX(-width / 2.0); rect.setC(helper); Vector3.releaseTempInstance(helper); } });
public void stateChanged(final ChangeEvent e) { final Rectangle3 rect = ((RectangleEmitter) getEdittedParticles().getParticleEmitter()).getSource(); final double height = _rectHeightPanel.getDoubleValue(); final Vector3 helper = Vector3.fetchTempInstance(); helper.set(rect.getA()).setZ(-height / 2.0); rect.setA(helper); helper.set(rect.getB()).setZ(-height / 2.0); rect.setB(helper); helper.set(rect.getC()).setZ(height / 2.0); rect.setC(helper); Vector3.releaseTempInstance(helper); } });
@Override public void prepare(final ParticleSystem system) { _line.setOrigin(_axis.getOrigin()); _line.setDirection(_axis.getDirection()); final ReadOnlyMatrix3 mat = system.getEmitterTransform().getMatrix(); if (_transformWithScene && !mat.isIdentity()) { final Vector3 temp = Vector3.fetchTempInstance(); mat.applyPost(_line.getOrigin(), temp); _line.setOrigin(temp); mat.applyPost(_line.getDirection(), temp); _line.setDirection(temp); Vector3.releaseTempInstance(temp); } if (_type == VT_CYLINDER) { _rot.fromAngleAxis(-_divergence, _line.getDirection()); } }
@Override public void prepare(final ParticleSystem system) { _line.setOrigin(_axis.getOrigin()); _line.setDirection(_axis.getDirection()); final ReadOnlyMatrix3 mat = system.getEmitterTransform().getMatrix(); if (_transformWithScene && !mat.isIdentity()) { final Vector3 temp = Vector3.fetchTempInstance(); mat.applyPost(_line.getOrigin(), temp); _line.setOrigin(temp); mat.applyPost(_line.getDirection(), temp); _line.setDirection(temp); Vector3.releaseTempInstance(temp); } if (_type == VT_CYLINDER) { _rot.fromAngleAxis(-_divergence, _line.getDirection()); } }