/** * 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 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, 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, * 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); }
@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) { 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.setSpotInnerAngle(5*FastMath.DEG_TO_RAD); 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));
sl.setPosition(new Vector3f(1.2074411f, 10.6868908f, 4.1489987f)); sl.setDirection(sl.getPosition().mult(-1)); sl.setSpotOuterAngle(0.1f);
sl.setPosition(Vector3f.ZERO); sl.setDirection(Vector3f.UNIT_Z); geom.setLocalTranslation(Vector3f.ZERO); sl.setPosition(Vector3f.UNIT_Z.mult(1+FastMath.ZERO_TOLERANCE)); checkFilteredLights(0); sl.setPosition(sl.getDirection().mult(-2f).add(geom.getLocalTranslation())); sl.setPosition(Vector3f.ZERO); sl.setDirection(Vector3f.UNIT_Z); sl.setSpotRange(20);
spot.setSpotInnerAngle(5f * FastMath.DEG_TO_RAD); 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));
spot.setSpotOuterAngle(20f * FastMath.DEG_TO_RAD); // outer light cone (edge of the light) 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.setPosition(new Vector3f(-1f,3f,0f)); spotLight.setSpotOuterAngle(0.5f); spotLight.setColor(ColorRGBA.Green);
spot.setSpotOuterAngle(FastMath.DEG_TO_RAD * 20); spot.setSpotInnerAngle(FastMath.DEG_TO_RAD * 5); spot.setPosition(new Vector3f(10, 10, 20)); rootNode.addLight(spot);
/** * 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); }