Scene appearance problem

Hi, all

I built some polyhedrons using IndexedTriangleArray, the normal for each

vertex point is (0.0, -1.0, 0.0). I used the following code to set the

appearance:

PolygonAttributes pa = new PolygonAttributes();

pa.setCullFace(PolygonAttributes.CULL_NONE);

pa.setBackFaceNormalFlip(true);

Appearance app = new Appearance();

app.setPolygonAttributes(pa);

I also applied the lights and MouseZoom to my TransformGroup object using

the following code:

//add AmbientLight and DirectionalLight to objScale

AmbientLight lightA = new AmbientLight(new Color3f(0.2f,0.2f,0.2f));

lightA.setInfluencingBounds(new BoundingSphere());

objScale.addChild(lightA);

DirectionalLight lightD1 = new DirectionalLight();

lightD1.setInfluencingBounds(new BoundingSphere());

Vector3f direction = new Vector3f(0.0f, -1.0f, 0.0f);

direction.normalize();

lightD1.setDirection(direction);

lightD1.setColor(new Color3f(0.0f, 1.0f, 0.0f));

objScale.addChild(lightD1);

MouseZoom behavior2 = new MouseZoom();

behavior2.setTransformGroup(objScale);

objScale.addChild(behavior2);

behavior2.setSchedulingBounds(bounds);

Now my trouble is, if I keep zooming in, I can not see some sides of the

polyhedrons. It seems that the normals changed. I do not have this trouble

if I keep zooming out. I am not sure if this is normal, lighting, or appearance

problem.

Any help will be highly appreciated.

Gaoming

[1604 byte] By [gaoming_fu] at [2007-9-26 1:33:47]
# 1

gaoming,

It's unlikely your normal orientation has changed.

The Java3D API Specification, Appendix E, Equations, specifies that lights do not illuminate the "back sides" of surfaces, i.e. if the dot product of the vertex normal and the unit vector from the vertex to the light is negative.This leaves the back sides of meshes dark.

Since you state that the problem is only for "some" of the polygons while zooming, I assume we're not talking about a clipping plane issue here.

So put two directional lights in the scene, pointing in opposite directions.

You have one already:

DirectionalLight lightD1 = new DirectionalLight();

lightD1.setInfluencingBounds(new BoundingSphere());

Vector3f direction = new Vector3f(0.0f, -1.0f, 0.0f);

direction.normalize();

lightD1.setDirection(direction);

Now create another thusly:

DirectionalLight lightD2 = new DirectionalLight();

lightD2.setInfluencingBounds(new BoundingSphere());

direction.negate();

lightD2.setDirection(direction);

This may solve your problem, provided that your mesh has been generated correctly.

Jim

jbutler at 2007-6-29 2:16:02 > top of Java-index,Security,Cryptography...
# 2
Java3D has a default viewer position, when you zoom in the scene, your scene may go out of scope of viewer. So you cannot see this part of scene. The solution is that updating viewer position when the scene goes out of the bound of viewer.
LouisGL at 2007-6-29 2:16:02 > top of Java-index,Security,Cryptography...