@Override public void setViewValue(Object o) { // value = o; if (!VGraphicsUtil.NO_3D) { if (shapeGroup != null) { shapeGroup.detach(); } Shape3D shape = (Shape3D) o; shapeGroup = new BranchGroup(); shapeGroup.setCapability(BranchGroup.ENABLE_PICK_REPORTING); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); shapeGroup.setCapability(BranchGroup.ALLOW_DETACH); shapeGroup.addChild(shape); universeCreator.getRootGroup().addChild(shapeGroup); getCanvas().postRenderTask(); } }
/** * Ajoute une Branche l'arbre de la scene, apres l'avoir compile. * * @param _bg BranchGroup ajouter */ public void addBranchGraph(final BranchGroup _bg) { if (!_bg.isCompiled()) { _bg.compile(); } locale_.addBranchGraph(_bg); }
private static void render3D () { rootGroup.addChild(offscreenGroup); if (clear3D) { clear3D = false; rootGroup.removeChild(onscreenGroup); onscreenGroup = offscreenGroup; } else { Enumeration children = offscreenGroup.getAllChildren(); while(children.hasMoreElements()) { Node child = (Node)children.nextElement(); offscreenGroup.removeChild(child); onscreenGroup.addChild(child); } } offscreenGroup = createBranchGroup(); //System.out.println("off = " + offscreenGroup.numChildren()); //System.out.println("on = " + onscreenGroup.numChildren()); rootGroup.removeChild(offscreenGroup); //StdOut.println("showed once = true"); } /* ***************************************************************
/** * Creates a blank BranchGroup with the proper capabilities. */ private static BranchGroup createBranchGroup () { BranchGroup bg = new BranchGroup(); bg.setCapability(BranchGroup.ALLOW_CHILDREN_READ); bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); bg.setCapability(BranchGroup.ALLOW_DETACH); bg.setPickable(false); bg.setCollidable(false); return bg; }
shapeGroup = new BranchGroup(); shapeGroup.setCapability(BranchGroup.ENABLE_PICK_REPORTING); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ); shapeGroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); shapeGroup.setCapability(BranchGroup.ALLOW_DETACH); switchGroup.setCapability(BranchGroup.ALLOW_DETACH); shapeGroup.addChild(switchGroup); BranchGroup g = new BranchGroup(); g.setCapability(BranchGroup.ENABLE_PICK_REPORTING); g.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); g.setCapability(BranchGroup.ALLOW_CHILDREN_READ); g.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); g.setCapability(BranchGroup.ALLOW_DETACH); g.addChild(shape); switchGroup.addChild(g);
public void unhide () { hide(); offscreenGroup.addChild(bg); }
/** * 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); }
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); for (int i = 0; i < bg.numChildren(); i++) { Node child = bg.getChild(i); if (child instanceof Shape3D) { Shape3D shape = (Shape3D) child; transGroup.addChild(bg); BranchGroup bg2 = createBranchGroup(); bg2.addChild(transGroup); offscreenGroup.addChild(bg2); return new Shape(bg2, transGroup); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); }
public BranchGroup createSceneGraph(final Canvas3D canvas) { objRoot = new BranchGroup(); objRoot.setCapability(Group.ALLOW_CHILDREN_EXTEND); objRoot.setCapability(Group.ALLOW_CHILDREN_WRITE); objRoot.addChild(objScale); lgt2.setInfluencingBounds(bounds); ambient.setInfluencingBounds(bounds); objRoot.addChild(lgt2); objRoot.addChild(ambient); objRoot.compile();
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; }
BranchGroup objRoot = new BranchGroup(); objRoot.addChild(rootGroup); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); lgt1.setInfluencingBounds(bounds); objRoot.addChild(lgt1); DirectionalLight lgt2 = new DirectionalLight(lColor2, lDir2); lgt2.setInfluencingBounds(bounds); objRoot.addChild(lgt2); objRoot.addChild(rotateBehavior); rotateBehavior.setSchedulingBounds(bounds); rotateBehavior.setFactor(0.01); zoomBehavior.setTransformGroup(rootGroup); zoomBehavior.setSchedulingBounds(bounds); objRoot.addChild(zoomBehavior); zoomBehavior.setFactor(0.05); translateBehavior.setTransformGroup(rootGroup); translateBehavior.setSchedulingBounds(bounds); objRoot.addChild(translateBehavior); background.setColor(0.285f, 0.285f, 0.3f); background.setApplicationBounds(bounds); objRoot.addChild(background);
((BranchGroup) e.nextElement()).detach(); BranchGroup emptyGroup = new BranchGroup(); emptyGroup.setCapability(BranchGroup.ALLOW_DETACH); locale_.addBranchGraph(emptyGroup); locale_.removeBranchGraph(emptyGroup);
/** * Removes all current lighting from the scene. */ public static void clearLight () { lightGroup.removeAllChildren(); }
@Override public void emptyView() { if (!VGraphicsUtil.NO_3D) { if (shapeGroup != null) { shapeGroup.detach(); } if (canvas != null) { getCanvas().contentChanged(); getCanvas().postRenderTask(); } } }
@Override public void init(VCanvas3D canvas) { GraphicsConfigTemplate3D gct = new GraphicsConfigTemplate3D(); gct.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED); this.canvas = canvas; canvas.setDoubleBuffered(true); // 12.05.2015 define default size since offscreencanvas will be null // otherwise // see: https://java.net/jira/browse/JAVA3D-386 canvas.setSize(100, 100); canvas.getOffscreenCanvas3D().setDoubleBufferEnable(true); canvas.setResizeMode(JCanvas3D.RESIZE_IMMEDIATELY); offscreenCanvas = new VOffscreenCanvas3D( SimpleUniverse.getPreferredConfiguration()); universe = new SimpleUniverse(getCanvas().getOffscreenCanvas3D()); universe.getViewer().getView().addCanvas3D(offscreenCanvas); // offscreen rendering does not work with sceneantialiasing enabled! // universe.getViewer().getView().setSceneAntialiasingEnable(true); universe.getViewingPlatform().setNominalViewingTransform(); universe.getViewer().getView().setMinimumFrameCycleTime(0); universe.getViewer().getView().setFrontClipDistance(0.1); universe.getViewer().getView().setBackClipDistance(100); BranchGroup scene = createSceneGraph(); scene.compile(); universe.addBranchGraph(scene); }
public void hide () { offscreenGroup.removeChild(bg); onscreenGroup.removeChild(bg); }
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_); }
public void unhide () { hide(); offscreenGroup.addChild(bg); }
/** * Creates a blank BranchGroup with the proper capabilities. */ private static BranchGroup createBranchGroup () { BranchGroup bg = new BranchGroup(); bg.setCapability(BranchGroup.ALLOW_CHILDREN_READ); bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); bg.setCapability(BranchGroup.ALLOW_DETACH); bg.setPickable(false); bg.setCollidable(false); return bg; }
/** * 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); }