List of usage examples for javax.media.j3d AlternateAppearance ALLOW_INFLUENCING_BOUNDS_WRITE
int ALLOW_INFLUENCING_BOUNDS_WRITE
To view the source code for javax.media.j3d AlternateAppearance ALLOW_INFLUENCING_BOUNDS_WRITE.
Click Source Link
From source file:AlternateAppearanceBoundsTest.java
BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
// Create an alternate appearance
otherApp = new Appearance();
altMat = new Material();
altMat.setCapability(Material.ALLOW_COMPONENT_WRITE);
altMat.setDiffuseColor(new Color3f(0.0f, 1.0f, 0.0f));
otherApp.setMaterial(altMat);/*from w ww . ja v a 2 s.com*/
altApp = new AlternateAppearance();
altApp.setAppearance(otherApp);
altApp.setCapability(AlternateAppearance.ALLOW_BOUNDS_WRITE);
altApp.setCapability(AlternateAppearance.ALLOW_INFLUENCING_BOUNDS_WRITE);
altApp.setInfluencingBounds(worldBounds);
objRoot.addChild(altApp);
// Build foreground geometry
Appearance app1 = new Appearance();
mat1 = new Material();
mat1.setCapability(Material.ALLOW_COMPONENT_WRITE);
mat1.setDiffuseColor(new Color3f(1.0f, 0.0f, 0.0f));
app1.setMaterial(mat1);
content1 = new SphereGroup(0.05f, // radius of spheres
0.15f, // x spacing
0.15f, // y spacing
5, // number of spheres in X
5, // number of spheres in Y
app1, // appearance
true); // alt app override = true
objRoot.addChild(content1);
shapes1 = ((SphereGroup) content1).getShapes();
// Add lights
light1 = new DirectionalLight();
light1.setEnable(true);
light1.setColor(new Color3f(0.2f, 0.2f, 0.2f));
light1.setDirection(new Vector3f(1.0f, 0.0f, -1.0f));
light1.setInfluencingBounds(worldBounds);
light1.setCapability(DirectionalLight.ALLOW_INFLUENCING_BOUNDS_WRITE);
light1.setCapability(DirectionalLight.ALLOW_BOUNDS_WRITE);
objRoot.addChild(light1);
// Add an ambient light to dimly illuminate the rest of
// the shapes in the scene to help illustrate that the
// directional lights are being scoped... otherwise it looks
// like we're just removing shapes from the scene
AmbientLight ambient = new AmbientLight();
ambient.setEnable(true);
ambient.setColor(new Color3f(1.0f, 1.0f, 1.0f));
ambient.setInfluencingBounds(worldBounds);
objRoot.addChild(ambient);
// Define a bounding leaf
leafBounds = new BoundingLeaf(allBounds[currentBounds]);
leafBounds.setCapability(BoundingLeaf.ALLOW_REGION_WRITE);
objRoot.addChild(leafBounds);
if (boundingLeafOn) {
altApp.setInfluencingBoundingLeaf(leafBounds);
} else {
altApp.setInfluencingBounds(allBounds[currentBounds]);
}
return objRoot;
}