Shadows

Hi,



I’m sorry for this easy questin, but I can’t find an answer in examples.



I have many boxes in my scene and all are blue. But I can’t see edges, becase, there are no shadows. Hope, you’ll understand, what I mean.

I’ve tried Directional light, but without any success. What I need is make objects look natural. Do I need use materials or some light?



I don’t want to project shadow of one box to another box. Just want see edges. It should visualize bar chart.



Thanks a lot and please forgive my english :slight_smile:

You probably don’t want shadows but lighting. A directional light should normally do the trick. You probably only forgot to add a light state to the node(s) you want to be lighted, or you forgot to attach the light - or to call updateRenderState for the node, where you added the light state after doing so.



If you still have probs, post your code here.

Thanks for reply… but I’m still having problem.



This screenshot show how it looks after start (I’m extending SimpleGame and therefore lightState is defined and assigned to rootNode):

http://www.proof.cz/ot/screenshot_bw.png

This is exactly what I want, but I need colors (and transparency in the future)…



This screenshot show how it looks when I press the “L” key:

http://www.proof.cz/ot/screenshot.png


        DirectionalLight sun = new DirectionalLight();
        sun.setDiffuse(new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f));
        sun.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
        sun.setSpecular(new ColorRGBA(0.0f, 0.3f, 0.0f, 1.0f));
        sun.setDirection(new Vector3f(1, 1, -1));
        sun.setEnabled(true);

        //LightState lightState = display.getRenderer().createLightState();
        lightState.setEnabled(true);
        lightState.attach(sun);
        //rootNode.setRenderState(lightState);
        rootNode.updateRenderState();


        Box b = new Box(name, new Vector3f(x, 0, y), new Vector3f(x + size - space, (float) value, y + size - space));

        ColorRGBA[] color = b.getColors();
        for (int i = 0; i < color.length; i++) {
                color[i] = ColorRGBA.blue;
        }
        b.setColors(color);

        rootNode.attachChild(b);

color is not used when lighting is enabled, you must create a Material state and apply it to the nodes.