use of com.jme3.light.PointLight in project jmonkeyengine by jMonkeyEngine.
the class LightSortTest method testSceneGraphSort.
@Test
public void testSceneGraphSort() {
Node n = new Node("node");
Geometry g = new Geometry("geom", new Mesh());
SpotLight spot = new SpotLight(Vector3f.ZERO, Vector3f.UNIT_X);
PointLight point = new PointLight(Vector3f.UNIT_X);
DirectionalLight directional = new DirectionalLight(Vector3f.UNIT_X);
AmbientLight ambient = new AmbientLight();
// Some lights are on the node
n.addLight(spot);
n.addLight(point);
// .. and some on the geometry.
g.addLight(directional);
g.addLight(ambient);
n.attachChild(g);
n.updateGeometricState();
LightList list = g.getWorldLightList();
// check the sorting (when geom is at 0,0,0)
assert list.get(0) instanceof AmbientLight;
assert list.get(1) instanceof DirectionalLight;
assert list.get(2) instanceof SpotLight;
assert list.get(3) instanceof PointLight;
// move the geometry closer to the point light
g.setLocalTranslation(Vector3f.UNIT_X);
n.updateGeometricState();
assert list.get(0) instanceof AmbientLight;
assert list.get(1) instanceof DirectionalLight;
assert list.get(2) instanceof PointLight;
assert list.get(3) instanceof SpotLight;
// now move the point light away from the geometry
// and the spot light closer
// XXX: doesn't work! jME can't detect that the light moved!
// point.setPosition(Vector3f.ZERO);
// spot.setPosition(Vector3f.UNIT_X);
// n.updateGeometricState();
//
// assert list.get(0) instanceof AmbientLight;
// assert list.get(1) instanceof DirectionalLight;
// assert list.get(2) instanceof SpotLight;
// assert list.get(3) instanceof PointLight;
}
use of com.jme3.light.PointLight in project jmonkeyengine by jMonkeyEngine.
the class TestMultiRenderTarget method simpleInitApp.
@Override
public void simpleInitApp() {
viewPort.addProcessor(this);
// flyCam.setEnabled(false);
cam.setLocation(new Vector3f(4.8037705f, 4.851632f, 10.789033f));
cam.setRotation(new Quaternion(-0.05143692f, 0.9483723f, -0.21131563f, -0.230846f));
Node tank = (Node) assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
//tankMesh.getMaterial().setColor("Specular", ColorRGBA.Black);
rootNode.attachChild(tank);
display1 = new Picture("Picture");
// make it appear behind stats view
display1.move(0, 0, -1);
display2 = (Picture) display1.clone();
display3 = (Picture) display1.clone();
display4 = (Picture) display1.clone();
display = (Picture) display1.clone();
ColorRGBA[] colors = new ColorRGBA[] { ColorRGBA.White, ColorRGBA.Blue, ColorRGBA.Cyan, ColorRGBA.DarkGray, ColorRGBA.Green, ColorRGBA.Magenta, ColorRGBA.Orange, ColorRGBA.Pink, ColorRGBA.Red, ColorRGBA.Yellow };
pls = new PointLight[3];
for (int i = 0; i < pls.length; i++) {
PointLight pl = new PointLight();
pl.setColor(colors[i % colors.length]);
pl.setRadius(5);
display.addLight(pl);
pls[i] = pl;
}
}
use of com.jme3.light.PointLight in project jmonkeyengine by jMonkeyEngine.
the class TestMultiRenderTarget method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
//To change body of generated methods, choose Tools | Templates.
super.simpleUpdate(tpf);
for (int i = 0; i < 3; i++) {
PointLight pl = pls[i];
// 3s for full loop
float angle = (float) Math.PI * (i + (timer.getTimeInSeconds() % 6) / 3);
pl.setPosition(new Vector3f(FastMath.cos(angle) * 3f, 0, FastMath.sin(angle) * 3f));
}
}
use of com.jme3.light.PointLight in project jmonkeyengine by jMonkeyEngine.
the class TestMonkeyHead method simpleInitApp.
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
Spatial bumpy = (Spatial) assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
rootNode.attachChild(bumpy);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(lightMdl);
// flourescent main light
pl = new PointLight();
pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f));
rootNode.addLight(pl);
// sunset light
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
dl.setColor(new ColorRGBA(0.44f, 0.30f, 0.20f, 1.0f));
rootNode.addLight(dl);
// skylight
dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.6f, -1, -0.6f).normalizeLocal());
dl.setColor(new ColorRGBA(0.10f, 0.22f, 0.44f, 1.0f));
rootNode.addLight(dl);
// white ambient light
dl = new DirectionalLight();
dl.setDirection(new Vector3f(1, -0.5f, -0.1f).normalizeLocal());
dl.setColor(new ColorRGBA(0.50f, 0.40f, 0.50f, 1.0f));
rootNode.addLight(dl);
}
use of com.jme3.light.PointLight in project jmonkeyengine by jMonkeyEngine.
the class TestSimpleBumps method simpleInitApp.
@Override
public void simpleInitApp() {
Quad quadMesh = new Quad(1, 1);
Geometry sphere = new Geometry("Rock Ball", quadMesh);
Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m");
sphere.setMaterial(mat);
TangentBinormalGenerator.generate(sphere);
rootNode.attachChild(sphere);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(lightMdl);
pl = new PointLight();
pl.setColor(ColorRGBA.White);
pl.setPosition(new Vector3f(0f, 0f, 4f));
rootNode.addLight(pl);
// DirectionalLight dl = new DirectionalLight();
// dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
// dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
// rootNode.addLight(dl);
}
Aggregations