Lighting having no effect

D

Dave

I am trying to add lighting to a simple 4x4 QuadArray terrain mesh.

However all that seems to happen is that the color I have specified for the
Shape3D object is displayed purely i.e. no shading at all just 100% the same
color all over the object. The only effect the light seems to be having is
direction i.e. you can only see the shape at all when one surface is
pointing down the way.

I have tried both AmbientLight and DirectionalLight and they are both having
no effect. My addLight method and Terrain class constructor is below.

public void addLight(Color3f color)
{
// Creates a bounding sphere for the lights
BoundingSphere bounds = new BoundingSphere();
bounds.setRadius(1000d);
AmbientLight lightA = new AmbientLight(true, color);
lightA.setInfluencingBounds(bounds);
// Then add it to the root BranchGroup
rootBranchGroup.addChild(lightA);
}

public Terrain(float[ ][ ] hf, Appearance app)
{
heightField = hf;
appearance = app;
geometryInfo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);

Point3f[ ] coordinates = new Point3f[64];

//... "coordinates" generated here ...

geometryInfo.setCoordinates(coordinates);
NormalGenerator normalGenerator = new NormalGenerator();
normalGenerator.generateNormals(geometryInfo);
geometryArray = geometryInfo.getGeometryArray();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top