 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dave Guest
|
Posted: Thu Apr 13, 2006 7:12 pm Post subject: Lighting having no effect |
|
|
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();
} |
|
| Back to top |
|
 |
Nick Wiedenbrück Guest
|
Posted: Thu Apr 13, 2006 11:12 pm Post subject: Re: Lighting having no effect |
|
|
Hi Dave again,
i don't understand lightning in Java3D well, either.
But i've got some hints.
The first thing you need is a Material for your Shape3D
object, that you can create using the Appearance class:
app.setMaterial(new Material()); (That is a sufficient Material)
Possibly, this is all that is missing.
A second hint is to use the SpotLight class.
Good luck,
Nick |
|
| Back to top |
|
 |
Dave Guest
|
Posted: Sat Apr 15, 2006 2:12 pm Post subject: Re: Lighting having no effect |
|
|
"Nick Wiedenbrück" <nick-w (AT) web (DOT) de> wrote in message
news:e1ml03$s10$1 (AT) news01 (DOT) versatel.de...
| Quote: | Hi Dave again,
i don't understand lightning in Java3D well, either.
But i've got some hints.
The first thing you need is a Material for your Shape3D
object, that you can create using the Appearance class:
app.setMaterial(new Material()); (That is a sufficient Material)
Possibly, this is all that is missing.
|
This fixed it, thanks again.  |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|