List of usage examples for javax.media.j3d Fog ALLOW_COLOR_WRITE
int ALLOW_COLOR_WRITE
To view the source code for javax.media.j3d Fog ALLOW_COLOR_WRITE.
Click Source Link
From source file:ExDepthCue.java
public Group buildScene() { // Get the current color Color3f color = (Color3f) colors[currentColor].value; // Turn off the example headlight setHeadlightEnable(false);//from w ww . j a v a2 s .co m // Create the scene group Group scene = new Group(); // Create a switch group to hold the fog node. This enables // us to turn the fog node on and off via the GUI. fogSwitch = new Switch(); fogSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE); // Create influencing bounds Bounds worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // Set the fog color, density, and its influencing bounds fog = new LinearFog(); fog.setColor(color); // front and back distances set below fog.setCapability(Fog.ALLOW_COLOR_WRITE); fog.setCapability(Fog.ALLOW_INFLUENCING_BOUNDS_WRITE); fog.setInfluencingBounds(worldBounds); fogSwitch.addChild(fog); scene.addChild(fogSwitch); if (depthCueOnOff) fogSwitch.setWhichChild(0); // on else fogSwitch.setWhichChild(Switch.CHILD_NONE); // off // Set the background color and its application bounds // Usually, the background color should match the fog color // or the results look odd. background = new Background(); background.setColor(color); background.setApplicationBounds(worldBounds); background.setCapability(Background.ALLOW_COLOR_WRITE); scene.addChild(background); // Build foreground geometry Group content = buildIsoline(); scene.addChild(content); // Automatically compute good front and back distances for // fog to get good depth-cueing. To do this, first get the // dimensions of the bounds around the content. Then, // set the front distance to be at the center of the content // (or closer by a tad) and the back distance at the front // distance PLUS half the depth of the content's bounding box BoundingSphere sampleSphere = new BoundingSphere(); BoundingBox sampleBox = new BoundingBox(); Bounds bounds = content.getBounds(); double deltaDistance = 0.0; double centerZ = 0.0; if (bounds == null) { // No bounds available. Estimate the values knowing // that the above content is what it is. centerZ = 0.5; // 0.5 closer than true center deltaDistance = 2.0; } else if (bounds.getClass() == sampleSphere.getClass()) { BoundingSphere sphereBounds = (BoundingSphere) bounds; deltaDistance = Math.abs(sphereBounds.getRadius()); Point3d center = new Point3d(); sphereBounds.getCenter(center); centerZ = center.z + 0.5; // 0.5 closer than true center } else if (bounds.getClass() == sampleBox.getClass()) { BoundingBox boxBounds = (BoundingBox) bounds; Point3d p1 = new Point3d(); Point3d p2 = new Point3d(); boxBounds.getLower(p1); boxBounds.getUpper(p2); deltaDistance = p2.z - p1.z; if (deltaDistance < 0.0) deltaDistance *= -1.0; if (p1.z > p2.z) centerZ = p1.z - deltaDistance / 2.0; else centerZ = p2.z - deltaDistance / 2.0; centerZ += 0.5; // 0.5 closer than true center } else { System.err.println("Unknown bounds type"); } // Set front distance to the distance from the default // viewing position (0,0,10) to the center of the bounds. fog.setFrontDistance(10.0f - (float) centerZ); // Set back distance to the distance from the default // viewing position (0,0,10) to the back of the bounds. fog.setBackDistance(10.0f - (float) centerZ + (float) deltaDistance); return scene; }
From source file:ExExponentialFog.java
public Group buildScene() { // Get the current color Color3f color = (Color3f) colors[currentColor].value; float density = ((Float) densities[currentDensity].value).floatValue(); // Turn off the example headlight setHeadlightEnable(false);//w w w . j av a 2 s . c om // Default to walk navigation setNavigationType(Walk); // Create the scene group Group scene = new Group(); // BEGIN EXAMPLE TOPIC // Create influencing bounds BoundingSphere worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // Set the fog color, density, and its influencing bounds fog = new ExponentialFog(); fog.setColor(color); fog.setDensity(density); fog.setCapability(Fog.ALLOW_COLOR_WRITE); fog.setCapability(ExponentialFog.ALLOW_DENSITY_WRITE); fog.setInfluencingBounds(worldBounds); scene.addChild(fog); // END EXAMPLE TOPIC // Set the background color and its application bounds // Usually, the background color should match the fog color // or the results look odd. background = new Background(); background.setColor(color); background.setApplicationBounds(worldBounds); background.setCapability(Background.ALLOW_COLOR_WRITE); scene.addChild(background); // Build foreground geometry scene.addChild(new ColumnScene(this)); return scene; }
From source file:ExLinearFog.java
public Group buildScene() { // Get the current color Color3f color = (Color3f) colors[currentColor].value; float front = ((Float) fronts[currentFront].value).floatValue(); float back = ((Float) backs[currentBack].value).floatValue(); // Turn off the example headlight setHeadlightEnable(false);//from ww w .j ava2 s .com // Default to walk navigation setNavigationType(Walk); // Create the scene group Group scene = new Group(); // BEGIN EXAMPLE TOPIC // Create influencing bounds BoundingSphere worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // Set the fog color, front & back distances, and // its influencing bounds fog = new LinearFog(); fog.setColor(color); fog.setFrontDistance(front); fog.setBackDistance(back); fog.setCapability(Fog.ALLOW_COLOR_WRITE); fog.setCapability(LinearFog.ALLOW_DISTANCE_WRITE); fog.setInfluencingBounds(worldBounds); scene.addChild(fog); // END EXAMPLE TOPIC // Set the background color and its application bounds // Usually, the background color should match the fog color // or the results look odd. background = new Background(); background.setColor(color); background.setApplicationBounds(worldBounds); background.setCapability(Background.ALLOW_COLOR_WRITE); scene.addChild(background); // Build foreground geometry scene.addChild(new ColumnScene(this)); return scene; }
From source file:ExClip.java
public Group buildScene() { // Get the current color Color3f color = (Color3f) colors[currentColor].value; float front = ((Float) fronts[currentFront].value).floatValue(); float back = ((Float) backs[currentBack].value).floatValue(); // Turn off the example headlight setHeadlightEnable(false);//from w ww . j a v a 2 s .c om // Default to walk navigation setNavigationType(Walk); // Create the scene group Group scene = new Group(); // BEGIN EXAMPLE TOPIC // Create influencing bounds BoundingSphere worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // Set the fog color, front & back distances, and // its influencing bounds fog = new LinearFog(); fog.setColor(color); fog.setFrontDistance(front); fog.setBackDistance(back); fog.setCapability(Fog.ALLOW_COLOR_WRITE); fog.setCapability(LinearFog.ALLOW_DISTANCE_WRITE); fog.setInfluencingBounds(worldBounds); scene.addChild(fog); // Add a clip node with it's clip distance (back // distance) set to the fog's back distance. This // insures that shapes are clipped off, and not drawn, // from the fog back (maximum density) onwards into // the distance. clip = new Clip(); clip.setBackDistance(back); clip.setCapability(Clip.ALLOW_BACK_DISTANCE_WRITE); clip.setApplicationBounds(worldBounds); scene.addChild(clip); // END EXAMPLE TOPIC // Set the background color and its application bounds // Usually, the background color should match the fog color // or the results look odd. background = new Background(); background.setColor(color); background.setApplicationBounds(worldBounds); background.setCapability(Background.ALLOW_COLOR_WRITE); scene.addChild(background); // Build foreground geometry scene.addChild(new ColumnScene(this)); return scene; }