Newbie lighting question

Hello all.

I just started using Xith3D, while looking for alternatives to Java3D (which, I also just started using along with 3D programming as a whole). :wink: Using the HelloXith3D code as a starting point, I added in a call to New Dawn Software’s AC3D loader for a scene I had created earlier in the week.

The scene does load, but it is all dark! I can see a black outline of everything on a dark-gray background… that’s all. :frowning:

Do I need to add a light source somewhere? Did I miss something in my code, or in the AC3D file? All I’m concerned about now is a flood of light – I don’t want any shadows.

Thanks for any help!

Hi ,

There are a few lighting methods in Xith3D
I tend to use Directional light but you could also use ambient lighting.

eg.
BranchGroup root = new BranchGroup();
locale.addBranchGraph(root);

Color3f ambientColor = new Color3f(0.5f, 0.5f, 0.5f);
  AmbientLight ambientLightNode = new AmbientLight(ambientColor);
  root.addChild(ambientLightNode);

or

DirectionalLight light = new DirectionalLight(true,new Color3f(1f,1f,1f),new Vector3f(0,0,1));
root.addChild(light);

or you could add something like this to your rendering loop:

lightAngle=lightAngle+0.004;

        Vector3f dir = new Vector3f((float) -Math.cos(lightAngle),(float) Math.cos(3.120),(float) Math.sin(lightAngle));
        light.setDirection(dir);

which would give the impression that the light is moving over your enviornment - like the SUN
play around with the Vector3fs values to see what suits you

hope this helps
cheers

rmdire

Also - Im not sure if AC3D files provide model specularity etc. Ive never used AC3D.

But for example - if you are using Kevin Glass wonderful
OBJLoader for Loading in your models - the Models material file contains shading and lighting settings.

These can be changed to give the various model parts different shading.

Cheers

rmdire

Many thanks rmdire. The AmbientLight works exactly the way I want it to! I seem to remember not trying that because of the description in my Java3D book… sigh ::slight_smile:

I was playing with DirectionalLight, but it caused a change in shading when I moved the scene. Everything shows up nice and bright now with the AL though. cheer

Can you help me understand the values inside the Color3f for the AmbientLight. I’ve been playing with them and have them all set to 10 right now, a good value for me during testing at least. Is there a standard ā€œnormā€ to these values if I want the images to appear with their natural color and luminance?

Thanks for your help!

Nick

I’m not sure if there is a standard ā€œnormā€ for the color3f settings -
but float values in color3f refer to the RGB value of the light.

so if you set the values to color3f(0.1f,0.1f,10.0f)

you would get mostly blue light.

rmdire