Bunker lighting


#21

but i provided you almost full testcase, where i do nothing else… here is file i were making tests:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.LightNode;
import com.jme3.scene.shape.Box;

/**
 * This is the Main Class of your Game. You should only do initialization here.
 * Move your Logic into AppStates or Controls
 * @author normenhansen
 */
public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        Box b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        mat.setColor("Diffuse",ColorRGBA.White);
        mat.setColor("Specular",ColorRGBA.White);
        geom.setMaterial(mat);
        geom.setLocalTranslation(-2, -2, -2);
        
//        PointLight lightR = new PointLight(new Vector3f(0, -2, -2), ColorRGBA.Red, 30);
//        rootNode.addLight(lightR);
//        PointLight lightB = new PointLight(new Vector3f(-2, 0, -2), ColorRGBA.Blue, 30);
//        rootNode.addLight(lightB);
//        PointLight lightG = new PointLight(new Vector3f(-2, -2, 0), ColorRGBA.Green, 30);
//        rootNode.addLight(lightG);
        
        
//        PointLight lightR2 = new PointLight(new Vector3f(0, -2, -2), ColorRGBA.Red, 30);
//        rootNode.addLight(lightR2);
//        PointLight lightB2 = lightR2.clone();
//        lightB2.setPosition(new Vector3f(-2, 0, -2));
//        lightB2.setColor(ColorRGBA.Blue);
//        rootNode.addLight(lightB2);
//        PointLight lightG2 = lightR2.clone();
//        lightG2.setPosition(new Vector3f(-2, -2, 0));
//        lightG2.setColor(ColorRGBA.Green);
//        rootNode.addLight(lightG2);
        
        PointLight light = new PointLight(new Vector3f(0, 0, 0), ColorRGBA.Brown, 30);

        LightNode lnode = new LightNode("test", light);
        lnode.setLocalTranslation(new Vector3f(0, -2, -2));
        lnode.getLight().setColor(ColorRGBA.Red);
        rootNode.attachChild(lnode);
        rootNode.removeLight(lnode.getLight());
        rootNode.addLight(lnode.getLight());
        rootNode.removeLight(lnode.getLight());
        //rootNode.addLight(lnode.getLight());

        LightNode lnode2 = (LightNode)lnode.clone();
        lnode2.setLocalTranslation(new Vector3f(-2, 0, -2));
        lnode2.getLight().setColor(ColorRGBA.Blue);
        rootNode.attachChild(lnode2);
        rootNode.removeLight(lnode2.getLight());
        //rootNode.addLight(lnode2.getLight());

        rootNode.detachAllChildren();

        
        LightNode lnode3 = (LightNode)lnode.clone();
        lnode3.setLocalTranslation(new Vector3f(-2, -2, 0));
        lnode3.getLight().setColor(ColorRGBA.Green);
        rootNode.attachChild(lnode3);
        rootNode.removeLight(lnode3.getLight());
        rootNode.addLight(lnode3.getLight());
        rootNode.removeLight(lnode3.getLight());
        rootNode.addLight(lnode3.getLight());
        
        //rootNode.attachChild(lnode);
        //rootNode.attachChild(lnode2);
        rootNode.addLight(lnode.getLight());
        rootNode.addLight(lnode2.getLight());
        
        rootNode.attachChild(geom);
    }

    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
}

see it yourself. you said it should not move light on remove, then see below and tell me why it look like this. earlier i noticed i had only one very bright light, so for me it just move lights on remove to same(light origin?) position.


#22

Update would never have been called for any of those LightNodes so there never would have been a chance for the control to update the light’s position.


#23

right, sometimes i write too quick before think. then i still dont know what caused my earlier issue, because there it was removing, but later(so it was able to update)