/** * Sets the light direction to use to compute shadows * * @param direction */ public void setDirection(Vector3f direction) { this.direction.set(direction).normalizeLocal(); }
/** * sets the light direction to use to computs shadows * @param direction */ public void setDirection(Vector3f direction) { this.direction.set(direction).normalizeLocal(); }
public void takeOverParent() { //got playerPos from scaleAsChild before getPlayerPosition().normalizeLocal().multLocal(poiRadius); currentReturnLevel = this; }
/** * <p>Creates a new LineSegment with a given origin and end. This constructor will calculate the * center, the direction and the extent.</p> */ public LineSegment(Vector3f start, Vector3f end) { this.origin = new Vector3f(0.5f * (start.x + end.x), 0.5f * (start.y + end.y), 0.5f * (start.z + end.z)); this.direction = end.subtract(start); this.extent = direction.length() * 0.5f; direction.normalizeLocal(); }
/** * A method that computes normal for a triangle defined by three vertices. * @param v1 first vertex * @param v2 second vertex * @param v3 third vertex * @return a normal for the face */ public static Vector3f computeNormal(Vector3f v1, Vector3f v2, Vector3f v3) { Vector3f a1 = v1.subtract(v2); Vector3f a2 = v3.subtract(v2); return a2.crossLocal(a1).normalizeLocal(); }
public Vector3f getNormal(){ Vector3f normal = new Vector3f(pointb); normal.subtractLocal(pointa).crossLocal(pointc.x-pointa.x, pointc.y-pointa.y, pointc.z-pointa.z); normal.normalizeLocal(); return normal; }
@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 static Vector3f computeTriangleNormal(Vector3f v1, Vector3f v2, Vector3f v3, Vector3f store) { if (store == null) { store = new Vector3f(v2); } else { store.set(v2); } store.subtractLocal(v1).crossLocal(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z); return store.normalizeLocal(); }
/** * Add all managed physics objects to the specified space. * * @param space which physics space to add to (not null) */ @Override protected void addPhysics(PhysicsSpace space) { space.getGravity(localUp).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); space.addCollisionObject(rigidBody); space.addTickListener(this); }
void computeNormal() { // Cross-product 2 edges tmpV1.set(vertex[1].position).subtractLocal(vertex[0].position); tmpV2.set(vertex[2].position).subtractLocal(vertex[1].position); normal = tmpV1.cross(tmpV2); normal.normalizeLocal(); }
/** * Add all managed physics objects to the specified space. * * @param space which physics space to add to (not null) */ @Override protected void addPhysics(PhysicsSpace space) { space.getGravity(localUp).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); space.addCollisionObject(rigidBody); space.addTickListener(this); }
private void setupLight() { // AmbientLight al = new AmbientLight(); // al.setColor(ColorRGBA.White.mult(1)); // rootNode.addLight(al); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); }
private void setupLight() { DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); }
private void createLight() { Vector3f direction = new Vector3f(-0.1f, -0.7f, -1).normalizeLocal(); DirectionalLight dl = new DirectionalLight(); dl.setDirection(direction); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); }
public void setupLighting(){ DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-1, -1, 1).normalizeLocal()); dl.setColor(new ColorRGBA(2,2,2,1)); rootNode.addLight(dl); }
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); } }
protected Spatial makeCharacter() { // load a character from jme3test-test-data Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(-1.0f, -1.5f, -0.6f); // We must add a light to make the model visible DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); golem.addLight(sun); return golem; } }
private static CollisionResults pick(Camera cam, Vector2f mouseLoc, Node node) { CollisionResults results = new CollisionResults(); Ray ray = new Ray(); Vector3f pos = new Vector3f(mouseLoc.x, mouseLoc.y, -1); Vector3f dir = new Vector3f(mouseLoc.x, mouseLoc.y, 1); dir.subtractLocal(pos).normalizeLocal(); ray.setOrigin(pos); ray.setDirection(dir); node.collideWith(ray, results); return results; } }
private void setUpLight() { // We add light so we see the scene AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(1.3f)); rootNode.addLight(al); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal()); rootNode.addLight(dl); }
public void setupLighting() { DirectionalLight dl = new DirectionalLight(); dl.setDirection(lightDir); dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); rootNode.addLight(dl); dl = new DirectionalLight(); dl.setDirection(new Vector3f(1, 0, -1).normalizeLocal()); dl.setColor(new ColorRGBA(.4f, .4f, .4f, 1)); // rootNode.addLight(dl); }