Problem is that light passes wall. I do something wrong or is this bug of JME?
This is code example. For run need include jme3-test-data.jar.
[java]
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.bounding.BoundingBox;
import com.jme3.light.AmbientLight;
import com.jme3.light.SpotLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.LightControl;
import com.jme3.scene.shape.Box;
import com.jme3.terrain.geomipmap.TerrainLodControl;
import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.terrain.geomipmap.lodcalc.DistanceLodCalculator;
public class Example extends SimpleApplication {
private TerrainQuad gameLevel;
public static void main(String[] args) {
Example app = new Example();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(200);
Material mat = assetManager.loadMaterial(“Textures/BumpMapTest/Tangent.j3m”);
gameLevel = new TerrainQuad(“terrain”, 65, 513, null);
TerrainLodControl control = new TerrainLodControl(gameLevel, cam);
control.setLodCalculator(new DistanceLodCalculator(65, 2.7f) );
gameLevel.addControl(control);
gameLevel.setMaterial(mat);
gameLevel.setModelBound(new BoundingBox());
gameLevel.updateModelBound();
gameLevel.setLocalTranslation(0, -100, 0);
gameLevel.setLocalScale(1f, 1f, 1f);
rootNode.attachChild(gameLevel);
Box box = new Box(Vector3f.ZERO, 30, 6.5f , 1);
Spatial wall = new Geometry(“Wall”, box);
wall.setMaterial(mat);
wall.setLocalTranslation(0, 2.5f, 0);
gameLevel.attachChild(wall);
Spatial light = new Geometry(“Light”, new Box(1, 1, 1));
light.setMaterial(assetManager.loadMaterial(“Common/Materials/RedColor.j3m”));
light.setLocalTranslation(10, 5, 10);
gameLevel.attachChild(light);
SpotLight myLight = new SpotLight();
myLight.setSpotRange(400);
myLight.setDirection(new Vector3f(0, -1, 0));
myLight.setPosition(light.getLocalTranslation().add(0, -100, 0));
myLight.setSpotOuterAngle(80 * FastMath.DEG_TO_RAD);
myLight.setSpotInnerAngle(75 * FastMath.DEG_TO_RAD);
myLight.setColor(ColorRGBA.Blue);
rootNode.addLight(myLight);
LightControl lightControl = new LightControl(myLight);
light.addControl(lightControl);
AmbientLight ambLight = new AmbientLight();
ambLight.setColor(new ColorRGBA(0.2f, 0.2f, 0.2f, 0.2f));
rootNode.addLight(ambLight);
}
}
[/java]