O.K., I 've figured it out.  AmbientLight color combines with the Ambient color of the material to give a color to the object.  I was under the (wrong) impression that it also combined with the Diffuse color of the material.  So its working as it should.
 
Cheers,
Bob Gray
-----Original Message-----
From: Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]]On Behalf Of RWGRAY
Sent: Saturday, November 30, 2002 5:54 PM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] AmbientLight trouble

I am having trouble finding the cause of a problem with AmbientLight. 
 
The problem is that I have a couple of spheres in the scene (and some lines) and the spheres are black.   (Lines are white, but I used ColoringAttributes to color the lines, not Material.)
 
When I add a PointLight to the scene, the spheres then have color.  And I can change Diffuse  color and Transparency of the spheres, so I know I am working with a good Appearance (with Material, no ColoringAttributes) applied to the spheres.
 
But I only get black spheres with just the AmbientLight in the scene.
 
I extend the AmbientLight class and add it to my scene graph.  Here is the init() method called when MyAmbientLight object is created.
 
  void init()
  {
    Color3f lightColor = new Color3f(1.0f, 1.0f, 1.0f);
    setColor(lightColor);
    nch7.insertAnimationValueColor3f(0, vLightColor, 1.0f, 1.0f, 1.0f);
 
    setCapability(AmbientLight.ALLOW_COLOR_WRITE);
    setCapability(AmbientLight.ALLOW_STATE_READ);
    setCapability(AmbientLight.ALLOW_STATE_WRITE);
    setCapability(AmbientLight.ALLOW_INFLUENCING_BOUNDS_READ);
 
    worldBounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100000.0);
 
    setInfluencingBounds(worldBounds);
 
    setEnable(true);
 
  } // init()
 
I know the AmbientLight is in the scene because I printed out the isLive() and it returned true.
 
And the influencing bounding sphere is set correctly because I print getInfluencingBounds:
AmbientLight: BoundingSphere: Center=(0.0, 0.0, 0.0)  Radius=100000.0
 
What am I missing?  Why would the objects (spheres) have color when I add a PointLight but not with the AmbientLight?
 
I am trying to narrow down what the problem could be:
1) Not an Appearance/Material problem because colors are just fine with a point light,
2) AmbientLight is in the scene (isLive),
3) AmbientLight has a large influencing bounds which includes the sphere locations (0,0,3), (0,2,0),
4) Explicitly set AmbientLight enabled (getEnabled() returns true),
5) AmbientColor  (getColor()) set to  Color3f: (1.0, 1.0, 1.0).

 
It is not obvious to me what else I should check.  Any suggestions?
 
 
Cheers,
Bob Gray
 
 

Reply via email to