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();
}
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();
}