public void move(Vector3f dir) { if (playerPos == null) { playerPos = new Vector3f(); } playerPos.addLocal(dir); }
public static void methodThatUsesAllocation(){ Vector3f vector = new Vector3f(); vector.set(0.1f, 0.2f, 0.3f); sumCompute.addLocal(vector); }
/** * Translates the spatial by the given translation vector. * * @return The spatial on which this method is called, e.g <code>this</code>. */ public Spatial move(Vector3f offset) { this.localTransform.getTranslation().addLocal(offset); setTransformRefresh(); return this; }
/** * Translates the spatial by the given translation vector. * * @return The spatial on which this method is called, e.g <code>this</code>. */ public Spatial move(float x, float y, float z) { this.localTransform.getTranslation().addLocal(x, y, z); setTransformRefresh(); return this; }
public Vector3f getMax(Vector3f store) { if (store == null) { store = new Vector3f(); } store.set(center).addLocal(xExtent, yExtent, zExtent); return store; }
/** * @return the centroid of the face */ public Vector3f computeCentroid() { Vector3f result = new Vector3f(); List<Vector3f> vertices = temporalMesh.getVertices(); for (Integer index : indexes) { result.addLocal(vertices.get(index)); } return result.divideLocal(indexes.size()); }
public static void methodThatUsesTempVars() { TempVars vars = TempVars.get(); { vars.vect1.set(0.1f, 0.2f, 0.3f); sumCompute.addLocal(vars.vect1); } vars.release(); } }
public static void recursiveMethod(int recurse) { TempVars vars = TempVars.get(); { vars.vect1.set(0.1f, 0.2f, 0.3f); if (recurse < 4) { recursiveMethod(recurse + 1); } sumCompute.addLocal(vars.vect1); } vars.release(); }
public Vector3f transformVector(final Vector3f in, Vector3f store){ if (store == null) store = new Vector3f(); // multiply with scale first, then rotate, finally translate (cf. // Eberly) return rot.mult(store.set(in).multLocal(scale), store).addLocal(translation); }
@Override protected void applyVelocityVariation(Particle particle) { temp.set(FastMath.nextRandomFloat() * velocityVariation, FastMath.nextRandomFloat() * velocityVariation, FastMath.nextRandomFloat() * velocityVariation); particle.velocity.addLocal(temp); }
public Vector3f getClosestPoint(Vector3f point, Vector3f store){ // float t = constant - normal.dot(point); // return store.set(normal).multLocal(t).addLocal(point); float t = (constant - normal.dot(point)) / normal.dot(normal); return store.set(normal).multLocal(t).addLocal(point); }
@Override public void cast(Vector3f pointToCast, float radius) { //computed using the Thales' theorem float length = 2 * pointToCast.subtractLocal(0.5f, 0.5f, 0.5f).length() * radius; pointToCast.normalizeLocal().addLocal(0.5f, 0.5f, 0.5f).multLocal(length); } },
public void setMinMax(Vector3f min, Vector3f max) { this.center.set(max).addLocal(min).multLocal(0.5f); xExtent = FastMath.abs(max.x - center.x); yExtent = FastMath.abs(max.y - center.y); zExtent = FastMath.abs(max.z - center.z); }
@Override public void getRandomPoint(Vector3f store) { do { store.x = (FastMath.nextRandomFloat() * 2f - 1f); store.y = (FastMath.nextRandomFloat() * 2f - 1f); store.z = (FastMath.nextRandomFloat() * 2f - 1f); } while (store.lengthSquared() > 1); store.multLocal(radius); store.addLocal(center); }
protected void computePosition() { float hDistance = (distance) * FastMath.sin((FastMath.PI / 2) - vRotation); pos.set(hDistance * FastMath.cos(rotation), (distance) * FastMath.sin(vRotation), hDistance * FastMath.sin(rotation)); pos.addLocal(target.getWorldTranslation()); }
private Geometry createFirstCube() { Vector3f loc = player.getLocalTranslation(); loc.addLocal(4, 0, 0); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); geom.setLocalTranslation(loc); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); geom.setMaterial(mat); return geom; }
private void scaleAsParent(float percent, Vector3f playerPos, Vector3f dist) { float scale = mapValue(percent, 1.0f, poiRadius); Vector3f distToHorizon = dist.subtract(dist.normalize()); Vector3f offLocation = playerPos.add(distToHorizon); Vector3f rootOff = offLocation.mult(scale).negate(); rootOff.addLocal(dist); debugTools.setGreenArrow(Vector3f.ZERO, offLocation); getRootNode().setLocalScale(scale); getRootNode().setLocalTranslation(rootOff); }