private void setSceneAppearance() { AmbientLight lightA = new AmbientLight(); lightA.setColor(new Color3f(255, 0, 100)); _contents.addChild(lightA); Background background = new Background(); background.setColor(EnvSettings.BACKGROUND_COLOR); _bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 0.1); background.setApplicationBounds(_bounds); _contents.addChild(background); }
// // Handle checkboxes and menu choices // public void checkboxChanged(CheckboxMenu menu, int check) { if (menu == backgroundColorMenu) { // Change the background color currentBackgroundColor = check; Color3f color = (Color3f) colors[check].value; background.setColor(color); return; } if (menu == colorMenu) { // Change the fog color currentColor = check; Color3f color = (Color3f) colors[check].value; fog.setColor(color); // If background is coupled, set the background color if (coupledBackgroundOnOff) { currentBackgroundColor = currentColor; backgroundColorMenu.setCurrent(check); background.setColor(color); } return; } if (menu == frontMenu) { // Change the fog front distance currentFront = check; float front = ((Float) fronts[currentFront].value).floatValue(); fog.setFrontDistance(front); return; } if (menu == backMenu) { // Change the fog back distance currentBack = check; float back = ((Float) backs[currentBack].value).floatValue(); fog.setBackDistance(back); return; } // Handle all other checkboxes super.checkboxChanged(menu, check); }
private void initBackground() { Background background = new Background(); background.setColor(getSettings().getRenderSettings3D().getBackground()); background.setCapability(Background.ALLOW_COLOR_WRITE); background.setApplicationBounds(getSettings().getRenderSettings3D().getBounds()); getScene().addChild(background); this.getLogger() .info( "Background initialized to '" + getSettings().getRenderSettings3D().getBackground().toString() + "'."); }
public void createSceneGraph(DrawModel drawing) { // Branch group which can be deattached for changing scene; view = new BranchGroup(); view.setCapability(BranchGroup.ALLOW_DETACH); // BranchGroup for rotation rotation = new TransformGroup(); rotation.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); rotation.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE); view.addChild(rotation); bounds = new BoundingSphere(); DirectionalLight lightD = new DirectionalLight(); lightD.setDirection(new Vector3f(0.0f, 0.0f, -0.7f)); lightD.setInfluencingBounds(bounds); view.addChild(lightD); AmbientLight lightA = new AmbientLight(); lightA.setInfluencingBounds(bounds); view.addChild(lightA); Background background = new Background(); background.setColor(1.0f, 1.0f, 1.0f); background.setApplicationBounds(bounds); view.addChild(background); // MouseRotate myMouseRotate = new MouseRotate(); // myMouseRotate.setTransformGroup(rotation); // myMouseRotate.setSchedulingBounds(bounds); // root.addChild(myMouseRotate); // // MouseTranslate myMouseTranslate = new MouseTranslate(); // myMouseTranslate.setTransformGroup(rotation); // myMouseTranslate.setSchedulingBounds(new BoundingSphere()); // root.addChild(myMouseTranslate); // MouseZoom myMouseZoom = new MouseZoom(); // myMouseZoom.setTransformGroup(rotation); // myMouseZoom.setSchedulingBounds(new BoundingSphere()); // root.addChild(myMouseZoom); // PickMouse pick = new PickMouse(this, view, bounds); view.addChild(pick); addKeyListener(new KeyListener()); angleV = (float) Math.PI / 4; angleH = (float) Math.PI / 5; draw(drawing); zoomAll(); }
// // Build scene // 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); // 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; }
public void itemStateChanged(ItemEvent event) { Object src = event.getSource(); // Check if it is the coupled background choice if (src == coupledBackgroundOnOffMenu) { coupledBackgroundOnOff = coupledBackgroundOnOffMenu.getState(); if (coupledBackgroundOnOff) { currentBackgroundColor = currentColor; backgroundColorMenu.setCurrent(currentColor); Color3f color = (Color3f) colors[currentColor].value; background.setColor(color); backgroundColorMenu.setEnabled(false); } else { backgroundColorMenu.setEnabled(true); } } // Handle all other checkboxes super.itemStateChanged(event); }
public void createBackground(Bounds bounds) { Background background = new Background(); background.setApplicationBounds(bounds); background.setColor(GameColors.BACKGROUND_COLOR); branchGroup.addChild(background); }
public void changeBackgroundColor(Color newColor) { Color3f bgcolor3f = new Color3f(); bgcolor3f.set(newColor); background.setColor(bgcolor3f); }