public void unhide () { hide(); offscreenGroup.addChild(bg); }
public void unhide () { hide(); offscreenGroup.addChild(bg); }
/** * Returns an identical copy of a Shape that can be controlled independently. * Much more efficient than redrawing a specific shape or model. */ public static Shape copy (Shape shape) { TransformGroup tg = shape.tg; BranchGroup bg = shape.bg; TransformGroup tg2 = (TransformGroup)tg.cloneTree(); BranchGroup bg2 = createBranchGroup(); bg2.addChild(tg2); offscreenGroup.addChild(bg2); return new Shape(bg2, tg2); }
/** * Returns an identical copy of a Shape that can be controlled independently. * Much more efficient than redrawing a specific shape or model. */ public static Shape copy (Shape shape) { TransformGroup tg = shape.tg; BranchGroup bg = shape.bg; TransformGroup tg2 = (TransformGroup)tg.cloneTree(); BranchGroup bg2 = createBranchGroup(); bg2.addChild(tg2); offscreenGroup.addChild(bg2); return new Shape(bg2, tg2); }
/** * Creates a PickMouseBehavior given current canvas, root of the tree to * operate on, and the bounds. */ public PickMouseBehavior(Canvas3D canvas, BranchGroup root, Bounds bounds){ super(); currGrp = new TransformGroup(); currGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); currGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); root.addChild(currGrp); pickCanvas = new PickCanvas(canvas, root); }
public PickSphereBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){ super(root, canvas, bounds); setCanvas(canvas); this.setSchedulingBounds(bounds); root.addChild(this); pickCanvas.setMode(PickTool.GEOMETRY); pickCanvas.setTolerance(0.f); }
/** * Combines any number of shapes into one shape and returns it. */ public static Shape combine (Shape... shapes) { BranchGroup combinedGroup = createBranchGroup(); TransformGroup combinedTransform = new TransformGroup(); for (int i = 0; i < shapes.length; i++) { BranchGroup bg = shapes[i].bg; TransformGroup tg = shapes[i].tg; offscreenGroup.removeChild(bg); onscreenGroup.removeChild(bg); bg.removeChild(tg); combinedTransform.addChild(shapes[i].tg); } combinedGroup.addChild(combinedTransform); offscreenGroup.addChild(combinedGroup); return new Shape(combinedGroup, combinedTransform); }
/** * Combines any number of shapes into one shape and returns it. */ public static Shape combine (Shape... shapes) { BranchGroup combinedGroup = createBranchGroup(); TransformGroup combinedTransform = new TransformGroup(); for (int i = 0; i < shapes.length; i++) { BranchGroup bg = shapes[i].bg; TransformGroup tg = shapes[i].tg; offscreenGroup.removeChild(bg); onscreenGroup.removeChild(bg); bg.removeChild(tg); combinedTransform.addChild(shapes[i].tg); } combinedGroup.addChild(combinedTransform); offscreenGroup.addChild(combinedGroup); return new Shape(combinedGroup, combinedTransform); }
/** * Sets the background color to the given color. * * @param color The color to set the background as. */ public static void setBackground (Color color) { if (!color.equals(bgColor)) { bgColor = color; rootGroup.removeChild(bgGroup); bgGroup.removeChild(background); background = createBackground(); background.setColor(new Color3f(bgColor)); bgGroup.addChild(background); rootGroup.addChild(bgGroup); } }
/** * Sets the background color to the given color. * * @param color The color to set the background as. */ public static void setBackground (Color color) { if (!color.equals(bgColor)) { bgColor = color; rootGroup.removeChild(bgGroup); bgGroup.removeChild(background); background = createBackground(); background.setColor(new Color3f(bgColor)); bgGroup.addChild(background); rootGroup.addChild(bgGroup); } }
/** * Adds ambient light of color col. */ public static Light ambientLight (Color col) { Color3f lightColor = new Color3f(col); AmbientLight light = new AmbientLight(lightColor); light.setInfluencingBounds(INFINITE_BOUNDS); light.setCapability(AmbientLight.ALLOW_STATE_WRITE); light.setCapability(AmbientLight.ALLOW_COLOR_WRITE); BranchGroup bg = createBranchGroup(); TransformGroup tg = createTransformGroup(); tg.addChild(light); bg.addChild(tg); lightGroup.addChild(bg); return new Light(bg, tg, light); }
private static void playAmbientSound (String filename, double volume, boolean loop) { MediaContainer mc = new MediaContainer("file:" + filename); mc.setCacheEnable(true); BackgroundSound sound = new BackgroundSound(); sound.setInitialGain((float)volume); sound.setSoundData(mc); sound.setBounds(INFINITE_BOUNDS); sound.setSchedulingBounds(INFINITE_BOUNDS); if (loop == true) sound.setLoop(Sound.INFINITE_LOOPS); sound.setEnable(true); BranchGroup bg = createBranchGroup(); bg.addChild(sound); soundGroup.addChild(bg); }
/** * Adds ambient light of color col. */ public static Light ambientLight (Color col) { Color3f lightColor = new Color3f(col); AmbientLight light = new AmbientLight(lightColor); light.setInfluencingBounds(INFINITE_BOUNDS); light.setCapability(AmbientLight.ALLOW_STATE_WRITE); light.setCapability(AmbientLight.ALLOW_COLOR_WRITE); BranchGroup bg = createBranchGroup(); TransformGroup tg = createTransformGroup(); tg.addChild(light); bg.addChild(tg); lightGroup.addChild(bg); return new Light(bg, tg, light); }
private static Shape drawLWS (String filename) { Lw3dLoader loader = new Lw3dLoader(); try { BranchGroup bg = loader.load(filename).getSceneGroup(); bg.setCapability(BranchGroup.ALLOW_CHILDREN_READ); bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); bg.setCapability(BranchGroup.ALLOW_DETACH); TransformGroup transGroup = new TransformGroup(); transGroup.addChild(bg); BranchGroup bg2 = createBranchGroup(); bg2.addChild(transGroup); offscreenGroup.addChild(bg2); return new Shape(bg2, transGroup); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } return null; }
private static void playAmbientSound (String filename, double volume, boolean loop) { MediaContainer mc = new MediaContainer("file:" + filename); mc.setCacheEnable(true); BackgroundSound sound = new BackgroundSound(); sound.setInitialGain((float)volume); sound.setSoundData(mc); sound.setBounds(INFINITE_BOUNDS); sound.setSchedulingBounds(INFINITE_BOUNDS); if (loop == true) sound.setLoop(Sound.INFINITE_LOOPS); sound.setEnable(true); BranchGroup bg = createBranchGroup(); bg.addChild(sound); soundGroup.addChild(bg); }
private static Shape drawLWS (String filename) { Lw3dLoader loader = new Lw3dLoader(); try { BranchGroup bg = loader.load(filename).getSceneGroup(); bg.setCapability(BranchGroup.ALLOW_CHILDREN_READ); bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); bg.setCapability(BranchGroup.ALLOW_DETACH); TransformGroup transGroup = new TransformGroup(); transGroup.addChild(bg); BranchGroup bg2 = createBranchGroup(); bg2.addChild(transGroup); offscreenGroup.addChild(bg2); return new Shape(bg2, transGroup); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } return null; }
public void start() { trajectoire_ = new RotPosPathInterpolator(new Alpha(nbCycles_, temps_), univers_.getTransformGroup(), axe_, pourcentAtIndex_, directions_, positions_); trajectoire_.setSchedulingBounds(new BoundingSphere()); bg_ = new BranchGroup(); bg_.setCapability(BranchGroup.ALLOW_DETACH); bg_.addChild(trajectoire_); univers_.addBranchGraph(bg_); }
private void buildFond(Color3f _c) { if (background_ == null) { background_ = _c == null ? new Background(0F, 0F, 0F) : new Background(_c); background_.setCapability(Background.ALLOW_COLOR_WRITE); background_.setCapability(Background.ALLOW_COLOR_READ); background_.setCapability(Background.ALLOW_APPLICATION_BOUNDS_READ); background_.setCapability(Background.ALLOW_APPLICATION_BOUNDS_WRITE); // background_.setApplicationBounds(new BoundingSphere(new Point3d(0, 0, 0), 1E12)); background_.setBoundsAutoCompute(true); final BranchGroup fond = new BranchGroup(); fond.addChild(background_); fond.setCapability(BranchGroup.ALLOW_DETACH); addBranchGraph(fond); } }