canvas3D = new Canvas3D(r);
canvas3D.setDoubleBufferEnable(true);
universe = new SimpleUniverse(canvas3D);
rootGroup = new BranchGroup();
rootGroup.setCapability(BranchGroup.ALLOW_DETACH);
rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
rootGroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
branchgroup = new BranchGroup();
branchgroup.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
branchgroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
branchgroup.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_WRITE);
branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
branchgroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
// TODO use light factories
AmbientLight alight = new AmbientLight(true,new Color3f(0.5f,0.5f,0.5f));
alight.setEnable(true);
rootGroup.addChild(alight);
BoundingSphere bounds = new BoundingSphere (new Point3d (0, 0.0, 0), 1E100);
alight.setInfluencingBounds(bounds);
lights = new DirectionalLight[1];
for (int i=0; i<lights.length; ++i) {
// TODO : position lights around the object
lights[i] = new DirectionalLight(true,new Color3f(1.0f,1.0f,1.0f),new Vector3f(-1,-1,-1));
lights[i].setCapability(DirectionalLight.ALLOW_DIRECTION_READ);
lights[i].setCapability(DirectionalLight.ALLOW_DIRECTION_WRITE);
lights[i].setCapabilityIsFrequent(DirectionalLight.ALLOW_DIRECTION_READ);
lights[i].setCapabilityIsFrequent(DirectionalLight.ALLOW_DIRECTION_WRITE);
lights[i].setEnable(true);
lights[i].setInfluencingBounds(bounds);
rootGroup.addChild(lights[i]);
}
// X axis in blue
axisGroup = new BranchGroup();
float[] axis = AxisMaker.makeAxis(0);
LineArray la = new LineArray(axis.length/3, LineArray.COORDINATES);
la.setCoordinates(0,axis);
Appearance a = new Appearance();