Skip to main content

Problem rendering colored spheres on Mac

2 replies [Last post]
ali
Offline
Joined: 2003-06-12

I am rendering colored spheres. The code is an follows:

...
material[i].setEmissiveColor(R, G, B);
material[i].setShininess(128.0f);
appearance[i].setMaterial(material[i]);
sphere[i].setAppearance(appearance[i]);
transformGroup[i].addChild(sphere[i]);
branchGroup.addChild(transformGroup[i]);
...

The above works fine on a Windows platform i.e. I get the desired color for each sphere. But, when I run the same application on a Mac, all the spheres are rendered as black (which is not what I want).

Any help/insight would be higly appreciated.

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fhmiv
Offline
Joined: 2004-12-10

Did you ever figure this one out? I run in to the same issue you see.
Here's the full example code, a slightly modified tutorial example to try to color the sphere. Please, someone let me know if I'm doing something wrong, or if there is a bug in the mac version of J3D.

import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class Ball {

public Ball() {
SimpleUniverse universe = new SimpleUniverse();

BranchGroup group = new BranchGroup();

Sphere sphere = new Sphere(0.5f);

Material material = new Material();
material.setEmissiveColor(new Color3f(1.0f, 1.0f, 0.0f));
material.setLightingEnable(true);
Appearance appearance = new Appearance();
appearance.setMaterial(material);
sphere.setAppearance(appearance);
group.addChild(sphere);
Color3f light1Color = new Color3f(1.0f, 1.0f, 1.0f);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,
0.0, 0.0), 100.0);

Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
DirectionalLight light1 = new DirectionalLight(light1Color,
light1Direction);

light1.setInfluencingBounds(bounds);

group.addChild(light1);

universe.getViewingPlatform().setNominalViewingTransform();

universe.addBranchGraph(group);

}
public static void main(String[] args) {
new Ball();
}
}

fhmiv
Offline
Joined: 2004-12-10

Seems like Emissive light is what isn't working on the Mac in this example.
Change material.setEmissiveColor() to material.setDiffuseColor() and you get a colored sphere as you would expect.