/** * Convert a vector (in) from this spatial's local coordinate space to world coordinate space. * * @param in * vector to read from * @param store * where to write the result (null to create a new vector, may be same as in) * @return the result (store) */ public Vector3 localToWorld(final ReadOnlyVector3 in, Vector3 store) { if (store == null) { store = new Vector3(); } return _worldTransform.applyForward(in, store); }
final Vector3 vec3 = new Vector3(0, 1, 0); final Vector3 result = trans.applyForward(vec3, null); assertTrue(Math.abs(new Vector3(1, 2, 4).distance(result)) <= MathUtils.EPSILON); trans.applyForward(vec3, result); assertTrue(Math.abs(new Vector3(1, 2, 4).distance(result)) <= MathUtils.EPSILON); trans.applyForward(vec3); assertTrue(Math.abs(new Vector3(1, 2, 4).distance(vec3)) <= MathUtils.EPSILON); trans.applyForward(vec3); trans.applyInverse(vec3); assertTrue(Math.abs(orig.distance(vec3)) <= 10 * MathUtils.EPSILON); // accumulated error trans.applyForward(vec3); assertEquals(orig, vec3); trans.applyForwardVector(vec3);
/** * Convert a vector (in) from this spatial's local coordinate space to world coordinate space. * * @param in * vector to read from * @param store * where to write the result (null to create a new vector, may be same as in) * @return the result (store) */ public Vector3 localToWorld(final ReadOnlyVector3 in, Vector3 store) { if (store == null) { store = new Vector3(); } return _worldTransform.applyForward(in, store); }
/** * Applies this transform to the given point and returns the result in the given store vector: P' = M*P+T * * @param point * @param store * the vector to store our result in. if null, a new vector will be created. * @return the transformed point. * @throws NullPointerException * if point is null. */ @Override public Vector3 applyForward(final ReadOnlyVector3 point, final Vector3 store) { Vector3 result = store; if (result == null) { result = new Vector3(); } result.set(point); return applyForward(result); }
/** * Applies this transform to the given point and returns the result in the given store vector: P' = M*P+T * * @param point * @param store * the vector to store our result in. if null, a new vector will be created. * @return the transformed point. * @throws NullPointerException * if point is null. */ @Override public Vector3 applyForward(final ReadOnlyVector3 point, final Vector3 store) { Vector3 result = store; if (result == null) { result = new Vector3(); } result.set(point); return applyForward(result); }
public void transformVertices(final Transform transform) { final FloatBuffer vertexBuffer = getVertexBuffer(); final Vector3 store = new Vector3(); for (int x = 0; x < _vertexCount; x++) { BufferUtils.populateFromBuffer(store, vertexBuffer, x); transform.applyForward(store, store); BufferUtils.setInBuffer(store, vertexBuffer, x); } }
public void transformVertices(final Transform transform) { final Vector3 store = new Vector3(); for (int x = 0; x < _vertexCount; x++) { BufferUtils.populateFromBuffer(store, _vertexCoords.getBuffer(), x); transform.applyForward(store, store); BufferUtils.setInBuffer(store, _vertexCoords.getBuffer(), x); } }
@Test(expected = NullPointerException.class) public void testApplyFail1() { final Transform trans = new Transform(); trans.applyForward(null); }
/** * translates/rotates and scales the vectors of this Mesh to world coordinates based on its world settings. The * results are stored in the given FloatBuffer. If given FloatBuffer is null, one is created. * * @param store * the FloatBuffer to store the results in, or null if you want one created. * @return store or new FloatBuffer if store == null. */ public FloatBuffer getWorldVectors(FloatBuffer store) { final FloatBuffer vertBuf = _meshData.getVertexBuffer(); if (store == null || store.capacity() != vertBuf.limit()) { store = BufferUtils.createFloatBuffer(vertBuf.limit()); } final Vector3 compVect = Vector3.fetchTempInstance(); for (int v = 0, vSize = store.capacity() / 3; v < vSize; v++) { BufferUtils.populateFromBuffer(compVect, vertBuf, v); _worldTransform.applyForward(compVect); BufferUtils.setInBuffer(compVect, store, v); } Vector3.releaseTempInstance(compVect); return store; }
/** * translates/rotates and scales the vectors of this Mesh to world coordinates based on its world settings. The * results are stored in the given FloatBuffer. If given FloatBuffer is null, one is created. * * @param store * the FloatBuffer to store the results in, or null if you want one created. * @return store or new FloatBuffer if store == null. */ public FloatBuffer getWorldVectors(FloatBuffer store) { final FloatBuffer vertBuf = _meshData.getVertexBuffer(); if (store == null || store.capacity() != vertBuf.limit()) { store = BufferUtils.createFloatBuffer(vertBuf.limit()); } final Vector3 compVect = Vector3.fetchTempInstance(); for (int v = 0, vSize = store.capacity() / 3; v < vSize; v++) { BufferUtils.populateFromBuffer(compVect, vertBuf, v); _worldTransform.applyForward(compVect); BufferUtils.setInBuffer(compVect, store, v); } Vector3.releaseTempInstance(compVect); return store; }
start.applyForward(Vector3.ZERO, stPnt); end.applyForward(Vector3.ZERO, endPnt);
start.applyForward(Vector3.ZERO, stPnt); end.applyForward(Vector3.ZERO, endPnt);
_transform.applyForward(vect); if (vect.getX() < minX) { minX = vect.getX();
_transform.applyForward(vect); if (vect.getX() < minX) { minX = vect.getX();
point.zero(); SkeletalDebugger.jointText.setTranslation(Camera.getCurrentCamera().getScreenCoordinates( t.applyForward(point)));
SkeletalDebugger.jointText.setTranslation(current.getScreenCoordinates(t.applyForward(point)));
_emitterTransform.applyForward(p.getPosition()); p.getPosition().divideLocal(_emitterTransform.getScale());
_emitterTransform.applyForward(p.getPosition()); p.getPosition().divideLocal(_emitterTransform.getScale());