Howdy everybody.
If I were to have many objects, say 300-500 characters, "standing" on top of another object, say a 64x64 TerrainBlock stretched to the scale 10,1,10 and wanted to have each of those characters have a PointLight on them, how would I accomplish this?
Think about a StarCraft Terran base. Now, imagine each character having it's own little light source. Cool, right? Right. They wouldn't need to be able to generate shadows, I don't think, but I do want to have the areas around characters lit.
Unfortunately, the TestManyLights.java demo doesn't accomplish what I'm looking for. That basically ignores lights that are far away, if I am understanding correctly.
Here's a simple test which illuminates the problem.
What are possible workarounds to having the same object lit by so many lights?
package com.trussell.genesis;
import com.jme.app.SimpleGame;
import com.jme.light.PointLight;
import com.jme.light.SimpleLightNode;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.shape.Sphere;
import com.jmex.terrain.TerrainBlock;
public class TestLights extends SimpleGame
{
public static void main(String[] args) {
TestLights tl = new TestLights();
tl.setConfigShowMode(ConfigShowMode.AlwaysShow);
tl.start();
}
@Override
protected void simpleInitGame() {
makeGround();
makeLights();
}
@Override
protected void simpleUpdate() {
rootNode.sortLights();
}
private void makeGround() {
TerrainBlock tb = new TerrainBlock("terrain", 16,
new Vector3f(10,1,10), new float[16*16], new Vector3f(0,0,0));
rootNode.attachChild(tb);
}
private void makeLights() {
lightState.detachAll();
for(int i=0; i<160; i+=10) {
for(int j=0; j<160; j+=10) {
PointLight pl = new PointLight();
pl.setEnabled(true);
pl.setAttenuate(true);
pl.setLinear(.1f);
pl.setQuadratic(.4f);
pl.setConstant(.5f);
pl.setDiffuse(ColorRGBA.randomColor());
lightState.attach(pl);
Sphere s = new Sphere("light"+i, 10, 10, 1);
SimpleLightNode ln = new SimpleLightNode("light"+i+"node", pl);
ln.attachChild(s);
rootNode.attachChild(ln);
ln.setLocalTranslation(new Vector3f(i, 1, j));
}
}
}
}