Question

I am attempting to get a custom Shape3D to be affected by a DirectedLight in java 3D, but nothing I do seems to work.

The Shape has a geometry that is an IndexedQuadArray, with the NORMAL flag set and applied, ensuring the normal vectors are applied to the correct vertices - using indexed vectors

I have given the Appearance a Material (both with specified colors and shininess, and without)
I have also put the light on the same BranchGroup as the Shape, but it still does not work.

In fact, when I add in the normals to the shape, the object appears to disappear - without them, it's flat shaded, so that all faces are the same shade.

I can only think that I am forgetting to include something ridiculously simple, or have done something wrong.

To test the lights were actually, I put in a Sphere beside the Shape, and the sphere was affected and lit correctly, but the shape still wasn't. Both were on the same BranchGroup

[Small oddity too - if I translate the sphere, it vanishes if I move it greater than 31 in any direction... [my view is set about 700 back as I'm dealing with objects of sizes up to 600 in width]


Edit: found this in the official tutorials that is probably related

A visual object properly specified for shading (i.e., one with a Material object) in a live scene graph but outside the influencing bounds of all light source objects renders black.

Was it helpful?

Solution

The light's setInfluencingBounds() was not set correctly, so that the shapes in the scene were not being included in the bounds.

This was corrected by setting a BoundingBox to encompass the entire area, and assigning that into the influencing bounds

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top