public DefaultUniverse() { super( createVWorldPlatform(), new Viewer(new Canvas3D(SimpleUniverse.getPreferredConfiguration()))); // some useful parts of this universe // Viewer viewer = getViewer(); // ViewingPlatform viewingPlatform = getViewingPlatform(); // View view = viewer.getView(); // ViewPlatform viewPlatform = viewingPlatform.getViewPlatform(); // TransformGroup viewTransGroup = getViewingPlatform().getViewPlatformTransform(); // set up the view getViewer().getView().setFrontClipPolicy(View.VIRTUAL_EYE); getViewer().getView().setBackClipDistance(BACK_CLIP); getViewer().getView().setFrontClipDistance(FRONT_CLIP); // set max frame rate to 50 so server can get in getViewer().getView().setMinimumFrameCycleTime(2); // TODO: I believe I can remove these calls PlatformGeometry pg = new PlatformGeometry(); pg.setCapability(Group.ALLOW_CHILDREN_EXTEND); getViewingPlatform().setPlatformGeometry(pg); getViewer().createAudioDevice(); // set capabilities for the various branch groups mainSceneGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND); mainSceneGroup.setCapability(Group.ALLOW_CHILDREN_WRITE); environmentGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND); environmentGroup.setCapability(Group.ALLOW_CHILDREN_WRITE); behaviorGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND); behaviorGroup.setCapability(Group.ALLOW_CHILDREN_WRITE); terrainGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND); terrainGroup.setCapability(Group.ALLOW_CHILDREN_WRITE); terrainGroup.setCapability(BranchGroup.ALLOW_DETACH); terrainGroup.setUserData("Terrain Group"); // initialise the sound system // SoundEngine mt = new SoundEngine(); // behaviorGroup.addChild(mt); // put a sky in place sky.setApplicationBounds(Utils3D.defaultBounds); environmentGroup.addChild(sky); // Create ambient light and add it Color3f alColor = new Color3f(0.6f, 0.6f, 0.6f); ambLight = new AmbientLight(true, alColor); ambLight.setCapability(Light.ALLOW_INFLUENCING_BOUNDS_WRITE); ambLight.setInfluencingBounds(Utils3D.defaultBounds); environmentGroup.addChild(ambLight); // Create sun light and add it Color3f slColor = new Color3f(1.0f, 1.0f, 1.0f); sunLight = new DirectionalLight(slColor, new Vector3f(0.2f, -1.0f, -0.2f)); sunLight.setCapability(Light.ALLOW_INFLUENCING_BOUNDS_WRITE); sunLight.setInfluencingBounds(Utils3D.defaultBounds); environmentGroup.addChild(sunLight); // Add the fog fog.setCapability(Fog.ALLOW_INFLUENCING_BOUNDS_WRITE); environmentGroup.addChild(fog); nightClip.setApplicationBounds(Utils3D.defaultBounds); fogClip.setApplicationBounds(Utils3D.defaultBounds); nightClipGroup.addChild(nightClip); nightClipGroup.setCapability(BranchGroup.ALLOW_DETACH); fogClipGroup.addChild(fogClip); fogClipGroup.setCapability(BranchGroup.ALLOW_DETACH); // initialise the rain model // Color3f rainColor = new Color3f(0.6f, 0.6f, 0.65f); // Vector3f windVector = new Vector3f(0.2f, 0f, 0f); // rainyModel = new RainyArea(14, 0, 25000, rainColor, 4.5f, 0.8f, 50, windVector, 80f, 80f, // 20f, 20000); // rainyModel.hoverOver(getViewingPlatform().getViewPlatformTransform()); // environmentGroup.addChild(rainyModel); mainSceneGroup.setCapability(BranchGroup.ALLOW_DETACH); environmentGroup.setCapability(BranchGroup.ALLOW_DETACH); behaviorGroup.setCapability(BranchGroup.ALLOW_DETACH); addBranchGraph(mainSceneGroup); addBranchGraph(environmentGroup); addBranchGraph(behaviorGroup); addBranchGraph(terrainGroup); }
public void setFogOff() { fog.setInfluencingBounds(null); sky.setDaySky(); environmentGroup.removeChild(fogClipGroup); }
public void setDayTime() { sunLight.setInfluencingBounds(Utils3D.defaultBounds); sky.setDaySky(); environmentGroup.removeChild(nightClipGroup); }
public void setFogOn() { fog.setInfluencingBounds(Utils3D.defaultBounds); sky.setFogSky(); environmentGroup.addChild(fogClipGroup); }
public void setNightTime() { sunLight.setInfluencingBounds(null); sky.setNightSky(); environmentGroup.addChild(nightClipGroup); }