public void takeOverParent() { //got playerPos from scaleAsChild before getPlayerPosition().normalizeLocal().multLocal(poiRadius); currentReturnLevel = this; }
/** * Scales the spatial by the given scale vector. * * @return The spatial on which this method is called, e.g <code>this</code>. */ public Spatial scale(float x, float y, float z) { this.localTransform.getScale().multLocal(x, y, z); setTransformRefresh(); return this; }
/** * Convert the cell coordinate (integer coordinates) into world coordinates. */ public Vector3f toWorldSpace(Vector3f cellLocation) { return cellLocation.mult(getLocalScale()).multLocal(quadSize - 1); }
/** * This method fills the point with coordinates of randomly selected point inside a convex hull * of randomly selected mesh. * @param store * the variable to store with coordinates of randomly selected selected point inside a convex hull * of randomly selected mesh */ @Override public void getRandomPoint(Vector3f store) { super.getRandomPoint(store); // now move the point from the meshe's face towards the center of the mesh // the center is in (0, 0, 0) in the local coordinates store.multLocal(FastMath.nextRandomFloat()); }
/** * Projects this vector onto another vector, stores the result in this * vector * * @param other The vector to project this vector onto * @return This Vector3f, set to the projection result */ public Vector3f projectLocal(Vector3f other){ float n = this.dot(other); // A . B float d = other.lengthSquared(); // |B|^2 return set(other).multLocal(n/d); }
/** * Projects this vector onto another vector * * @param other The vector to project this vector onto * @return A new vector with the projection result */ public Vector3f project(Vector3f other){ float n = this.dot(other); // A . B float d = other.lengthSquared(); // |B|^2 return new Vector3f(other).multLocal(n/d); }
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); }
/** * calculateCenter finds the average point of the triangle. * */ public void calculateCenter() { if (center == null) { center = new Vector3f(pointa); } else { center.set(pointa); } center.addLocal(pointb).addLocal(pointc).multLocal(FastMath.ONE_THIRD); }
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); } },
@Override public void adjustHeight(List<Vector2f> xz, List<Float> height) { Vector3f currentGridLocation = getCurrentCell().mult(getLocalScale()).multLocal(quadSize - 1); for (Vector2f vect : xz) { vect.x -= currentGridLocation.x; vect.y -= currentGridLocation.z; } super.adjustHeight(xz, height); }
/** * This method applies the variation to the particle with already set velocity. * @param particle * the particle to be affected */ protected void applyVelocityVariation(Particle particle) { particle.velocity.set(initialVelocity); temp.set(FastMath.nextRandomFloat(), FastMath.nextRandomFloat(), FastMath.nextRandomFloat()); temp.multLocal(2f); temp.subtractLocal(1f, 1f, 1f); temp.multLocal(initialVelocity.length()); particle.velocity.interpolateLocal(temp, velocityVariation); }
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); }
public Vector3f reflect(Vector3f point, Vector3f store){ if (store == null) store = new Vector3f(); float d = pseudoDistance(point); store.set(normal).negateLocal().multLocal(d * 2f); store.addLocal(point); return store; }
public BIHTriangle(Vector3f p1, Vector3f p2, Vector3f p3) { pointa.set(p1); pointb.set(p2); pointc.set(p3); center.set(pointa); center.addLocal(pointb).addLocal(pointc).multLocal(FastMath.ONE_THIRD); }
@Override public void simpleUpdate(float tpf) { if(forward){ model.move(model.getLocalRotation().multLocal(new Vector3f(0,0,1)).multLocal(tpf)); }else if(backward){ model.move(model.getLocalRotation().multLocal(new Vector3f(0,0,1)).multLocal(-tpf)); }else if(leftRotate){ model.rotate(0, tpf, 0); }else if(rightRotate){ model.rotate(0, -tpf, 0); } fpsText.setText(cam.getLocation() + "/" + cam.getRotation()); }
private void checkPlanetGravity() { Vector3f planetDist = planet.getWorldTranslation().subtract(characterNode.getWorldTranslation()); if (planetDist.length() < 24) { physicsCharacter.setGravity(planetDist.normalizeLocal().multLocal(9.81f)); } else { physicsCharacter.setGravity(normalGravity); } }
@Override public void updateGeometricState() { super.updateGeometricState(); if (channel < 0 || this.getParent() == null) return; Vector3f currentWorldTranslation = worldTransform.getTranslation(); if (!previousWorldTranslation.equals(currentWorldTranslation)) { getRenderer().updateSourceParam(this, AudioParam.Position); if (velocityFromTranslation && !Float.isNaN(previousWorldTranslation.x)) { velocity.set(currentWorldTranslation).subtractLocal(previousWorldTranslation).multLocal(1f / lastTpf); getRenderer().updateSourceParam(this, AudioParam.Velocity); } previousWorldTranslation.set(currentWorldTranslation); } }