/** * Creates a SpotLight at the given position and with the given direction. * @param position the position in world space. * @param direction the direction of the light. */ public SpotLight(Vector3f position, Vector3f direction) { this(); setPosition(position); setDirection(direction); }
/** * Creates a SpotLight at the given position, with the given direction, and the * given range. * @param position the position in world space. * @param direction the direction of the light. * @param range the spot light range */ public SpotLight(Vector3f position, Vector3f direction, float range) { this(); setPosition(position); setDirection(direction); setSpotRange(range); }
/** * Creates a SpotLight at the given position, with the given direction and * the given color. * @param position the position in world space. * @param direction the direction of the light. * @param color the light's color. */ public SpotLight(Vector3f position, Vector3f direction, ColorRGBA color) { super(color); computeAngleParameters(); setPosition(position); setDirection(direction); }
/** * Creates a SpotLight at the given position, with the given direction, * the given range and the given color. * @param position the position in world space. * @param direction the direction of the light. * @param range the spot light range * @param color the light's color. */ public SpotLight(Vector3f position, Vector3f direction, float range, ColorRGBA color) { super(color); computeAngleParameters(); setPosition(position); setDirection(direction); setSpotRange(range); }
private void parseLightNormal(Attributes attribs) throws SAXException { checkTopNode("light"); // SpotLight will be supporting a direction-normal, too. if (light instanceof DirectionalLight) { ((DirectionalLight) light).setDirection(parseVector3(attribs)); } else if (light instanceof SpotLight) { ((SpotLight) light).setDirection(parseVector3(attribs)); } }
@Override public void simpleUpdate(float tpf) { super.simpleUpdate(tpf); sl.setDirection(cam.getDirection()); sl.setPosition(cam.getLocation()); }
/** * Creates a SpotLight at the given position, with the given direction, * the given color and the given inner and outer angles * (controls the falloff of the light) * * @param position the position in world space. * @param direction the direction of the light. * @param range the spot light range * @param color the light's color. * @param innerAngle the inner angle of the spot light. * @param outerAngle the outer angle of the spot light. * * @see SpotLight#setSpotInnerAngle(float) * @see SpotLight#setSpotOuterAngle(float) */ public SpotLight(Vector3f position, Vector3f direction, float range, ColorRGBA color, float innerAngle, float outerAngle) { super(color); this.spotInnerAngle = innerAngle; this.spotOuterAngle = outerAngle; computeAngleParameters(); setPosition(position); setDirection(direction); setSpotRange(range); }
@Override public void simpleUpdate(float tpf) { timeElapsed += tpf; lightNode.setLocalTranslation(FastMath.cos(timeElapsed), lightNode.getLocalTranslation().y, FastMath.sin(timeElapsed)); spotLight.setDirection(new Vector3f(FastMath.cos(-timeElapsed*.7f), -1.0f, FastMath.sin(-timeElapsed*.7f))); } }
Vector3f dir = sl.getDirection(); q.multLocal(dir); sl.setDirection(dir);
@Override public void simpleUpdate(float tpf) { super.simpleUpdate(tpf); angle += tpf; angle %= FastMath.TWO_PI; spot.setPosition(new Vector3f(FastMath.cos(angle) * 30f, 34.013165f, FastMath.sin(angle) * 30f)); lightMdl.setLocalTranslation(spot.getPosition()); spot.setDirection(lightTarget.subtract(spot.getPosition())); }
@Override public void simpleUpdate(float tpf) { if (!stop) { super.simpleUpdate(tpf); angle += tpf; angle %= FastMath.TWO_PI; spot.setPosition(new Vector3f(FastMath.cos(angle) * 30f, 34.013165f, FastMath.sin(angle) * 30f)); lightMdl.setLocalTranslation(spot.getPosition()); spot.setDirection(lightTarget.subtract(spot.getPosition())); } } }
@Override public void simpleInitApp() { makeTerrain(); flyCam.setMoveSpeed(50); sl = new SpotLight(); sl.setSpotRange(100); sl.setSpotOuterAngle(20 * FastMath.DEG_TO_RAD); sl.setSpotInnerAngle(15 * FastMath.DEG_TO_RAD); sl.setDirection(new Vector3f(-0.39820394f, -0.73094344f, 0.55421597f)); sl.setPosition(new Vector3f(-64.61567f, -87.615425f, -202.41328f)); rootNode.addLight(sl); AmbientLight ambLight = new AmbientLight(); ambLight.setColor(ColorRGBA.Black); rootNode.addLight(ambLight); cam.setLocation(new Vector3f(-41.219646f, 0.8363f, -171.67267f)); cam.setRotation(new Quaternion(-0.04562731f, 0.89917684f, -0.09668826f, -0.4243236f)); sl.setDirection(cam.getDirection()); sl.setPosition(cam.getLocation()); }
private void spatialToLight(Light light) { final Vector3f worldTranslation = spatial.getWorldTranslation(); if (light instanceof PointLight) { ((PointLight) light).setPosition(worldTranslation); return; } final TempVars vars = TempVars.get(); final Vector3f vec = vars.vect1; if (light instanceof DirectionalLight) { ((DirectionalLight) light).setDirection(vec.set(worldTranslation).multLocal(-1.0f)); } if (light instanceof SpotLight) { final SpotLight spotLight = (SpotLight) light; spotLight.setPosition(worldTranslation); spotLight.setDirection(spatial.getWorldRotation().multLocal(vec.set(Vector3f.UNIT_Y).multLocal(-1))); } vars.release(); }
spot.setSpotOuterAngle(10*FastMath.DEG_TO_RAD); spot.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f)); spot.setDirection(lightTarget.subtract(spot.getPosition())); spot.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(spot);
sl.setDirection(new Vector3f(0.316f, 0, 0.948f).normalizeLocal()); checkFilteredLights(0); sl.setDirection(Vector3f.UNIT_Z); geom.setLocalTranslation(Vector3f.ZERO); geom.setModelBound(new BoundingSphere(1f, Vector3f.ZERO)); sl.setDirection(new Vector3f(1, 1, 0).normalizeLocal()); geom.setLocalTranslation(0, 0, 10); sl.setPosition(sl.getDirection().mult(-2f).add(geom.getLocalTranslation())); sl.setDirection(Vector3f.UNIT_Z); sl.setSpotRange(20); checkFilteredLights(1); sl.setDirection(new Vector3f(0, 0.3f, 0.7f).normalizeLocal()); checkFilteredLights(0);
sl.setColor(ColorRGBA.White.mult(1.0f)); sl.setPosition(new Vector3f(1.2074411f, 10.6868908f, 4.1489987f)); sl.setDirection(sl.getPosition().mult(-1)); sl.setSpotOuterAngle(0.1f); sl.setSpotInnerAngle(0.004f);
spot.setSpotOuterAngle(10 * FastMath.DEG_TO_RAD); spot.setPosition(new Vector3f(70.70334f, 34.013165f, 27.1017f)); spot.setDirection(lightTarget.subtract(spot.getPosition()).normalizeLocal()); spot.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(spot);
spot.setColor(ColorRGBA.White.mult(1.3f)); // light color spot.setPosition(new Vector3f(192.0f, -1f, 192f)); spot.setDirection(new Vector3f(1, -0.5f, 1)); rootNode.addLight(spot);
spotLight.setDirection(new Vector3f(1f,-1f,0f)); spotLight.setPosition(new Vector3f(-1f,3f,0f)); spotLight.setSpotOuterAngle(0.5f);
spot.setDirection(new Vector3f(-1f, -1f, -1f).normalizeLocal()); spot.setColor(ColorRGBA.Blue.mult(5)); spot.setSpotOuterAngle(FastMath.DEG_TO_RAD * 20);