simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene);
SimpleUniverse u=new SimpleUniverse(); u.addBranchGraph(group); u.getViewingPlatform().setNominalViewingTransform();
public Panel createPanel() { Panel p = new Panel(); p.setPreferredSize(new Dimension(512, 512)); p.setLayout(new BorderLayout()); Canvas3D canvas3D = new Canvas3D( SimpleUniverse.getPreferredConfiguration()); p.add("Center", canvas3D); BranchGroup scene = createSceneGraph(); scene.compile(); SimpleUniverse simpleU = new SimpleUniverse(canvas3D); simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene); return p; } // end of HelloJava3Dd (constructor)
simpleU.getViewingPlatform().setNominalViewingTransform(); scene.addChild(new ColorCube(0.4)); scene.compile(); simpleU.addBranchGraph(scene); simpleU.cleanup();
/** * Called once IO is complete, attaches all the branchgroups to the locales */ public void buildGraph() { Locale locale; Enumeration<Locale> e = universe.getAllLocales(); for( int i=0; i<localeBGs.size(); i++) { locale = e.nextElement(); int[] bgs = (int[])localeBGs.get(i); for(int j=0; j<bgs.length; j++) { SymbolTableData symbol = control.getSymbolTable().getBranchGraphRoot( bgs[j] ); locale.addBranchGraph((BranchGroup)symbol.j3dNode ); } } if (viewerAvatar!=null) { viewerAvatar.buildGraph(); universe.getViewer().setAvatar( (ViewerAvatar)viewerAvatar.getNode()); } if (platformGeom!=null) { universe.getViewingPlatform().setPlatformGeometry( (PlatformGeometry)platformGeom.getNode() ); platformGeom.buildGraph(); } }
//Create a Simple Universe object using a 3d canvas object you have SimpleUniverse simpleU = new SimpleUniverse(Your3dCanvasHere); //add in your compiled branch group simpleU.addBranchGraph(YourBranchGroupHere); //Increase the render distance with setBackClipDistance simpleU.getViewer().getView().setBackClipDistance(1000);
public void writeObject( DataOutput out ) throws IOException { MultiTransformGroup mtg = universe.getViewingPlatform().getMultiTransformGroup(); int mtgSize = mtg.getNumTransforms(); out.writeInt( mtgSize ); // Store the matrix from each MTG transform Transform3D trans = new Transform3D(); Matrix4d matrix = new Matrix4d(); for(int i=0; i<mtgSize; i++) { TransformGroup tg = mtg.getTransformGroup( i ); tg.getTransform( trans ); trans.get( matrix ); control.writeMatrix4d( out, matrix ); } control.writeObject( out, control.createState( universe.getViewingPlatform().getPlatformGeometry() )); control.writeObject( out, control.createState( universe.getViewer().getAvatar() )); writeLocales( out ); }
@Override public void cleanup() { UniverseSettings.save(); if (win != null) { fireUniverseClosed(); while (!listeners.isEmpty()) listeners.remove(0); final ImageWindow3D win2 = win; win = null; if (null != mouseBehavior) mouseBehavior.setExternalBehaviours(null); } // Flush native resources used by this universe: super.removeAllLocales(); super.cleanup(); }
public ImageCanvas3D(final int width, final int height, final UIAdapter uia) { super(SimpleUniverse.getPreferredConfiguration()); this.ui = uia; setPreferredSize(new Dimension(width, height)); final ByteProcessor ip = new ByteProcessor(width, height); roiImagePlus = new RoiImagePlus("RoiImage", ip); roiImageCanvas = new ImageCanvas(roiImagePlus) { /* prevent ROI to enlarge/move on mouse click */ @Override public void mousePressed(final MouseEvent e) { if (!ui.isMagnifierTool() && !ui.isPointTool()) super.mousePressed(e); } }; roiImageCanvas.removeKeyListener(ij.IJ.getInstance()); roiImageCanvas.removeMouseListener(roiImageCanvas); roiImageCanvas.removeMouseMotionListener(roiImageCanvas); roiImageCanvas.disablePopupMenu(true); background = new Background(new Color3f(UniverseSettings.defaultBackground)); background.setCapability(Background.ALLOW_COLOR_WRITE); addListeners(); }
public void readObject( DataInput in, Canvas3D canvas ) throws IOException { int mtgSize = in.readInt(); // MultiTransformGroup size if ( canvas!=null) { universe = new ConfiguredUniverse( canvas, mtgSize); } else { universe = new ConfiguredUniverse( ConfiguredUniverse.getConfigURL(), mtgSize); } MultiTransformGroup mtg = universe.getViewingPlatform().getMultiTransformGroup(); // Read and set the matrix for each MTG transfrom Matrix4d matrix = new Matrix4d(); for(int i=0; i<mtgSize; i++) { TransformGroup tg = mtg.getTransformGroup( i ); matrix = control.readMatrix4d( in ); Transform3D trans = new Transform3D( matrix ); tg.setTransform( trans ); } SceneGraphObjectState tmp = control.readObject(in); if (tmp instanceof PlatformGeometryState) platformGeom = (PlatformGeometryState)tmp; else platformGeom = null; tmp = control.readObject(in); if (tmp instanceof ViewerAvatarState) viewerAvatar = (ViewerAvatarState)tmp; else viewerAvatar = null; readLocales( in ); }
SimpleUniverse u = new SimpleUniverse(); // create a BranchGroup. A BranchGroup is a node in // a Tree data structure that can have child nodes BranchGroup bgRoot = new BranchGroup(); // create the Background node and add it to the SimpleUniverse u.addBranchGraph( createBackground() );
private void writeLocales( DataOutput out ) throws IOException { Enumeration<Locale> allLocales = universe.getAllLocales(); out.writeInt( universe.numLocales() ); localeBGs = new ArrayList( universe.numLocales() ); int currentLocale = 0; int graphID = 0;
/** * Cleanup memory use and reference by SimpleUniverse. * Typically it should be invoked by the applet's destroy method. */ public void cleanup() { // Get view associated with this SimpleUniverse View view = viewer[0].getView(); // Issue 134: cleanup all off-screen canvases for (int i = view.numCanvas3Ds() - 1; i >= 0; i--) { Canvas3D c = view.getCanvas3D(i); if (c.isOffScreen()) { c.setOffScreenBuffer(null); } } // Remove all canvases from view; remove the viewing platform from // this viewer; remove all locales to cleanup the scene graph view.removeAllCanvas3Ds(); viewer[0].setViewingPlatform(null); removeAllLocales(); Primitive.clearGeometryCache(); } }
/** * Constructor for use by Configured Universe */ SimpleUniverse( HiResCoord origin, LocaleFactory localeFactory ) { createLocale( origin, localeFactory ); }
/** * Reattach each BranchGraph to the Locale(s) */ public void attachAllGraphs() { Enumeration<Locale> e = universe.getAllLocales(); Locale locale; for( int i=0; i<localeBGs.size(); i++) { locale = e.nextElement(); int[] bgs = (int[])localeBGs.get(i); for(int j=0; j<bgs.length; j++) { SymbolTableData symbol = control.getSymbolTable().getBranchGraphRoot( bgs[j] ); locale.addBranchGraph(((BranchGroup)symbol.j3dNode)); } } }
public Test() { SimpleUniverse universe = new SimpleUniverse(); BranchGroup group = new BranchGroup(); TransformGroup rootTransformGroup = new TransformGroup(); group.addChild(rootTransformGroup); rootTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); rootTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); ColorCube colorCube = new ColorCube(.3); rootTransformGroup.addChild(colorCube); BoundingSphere boundingSphere = new BoundingSphere(new Point3d(0, 0, 0), 1000); MouseRotate mouseRotate = new MouseRotate(); mouseRotate.setTransformGroup(rootTransformGroup); mouseRotate.setSchedulingBounds(boundingSphere); group.addChild(mouseRotate); MouseTranslate mouseTrans = new MouseTranslate(); mouseTrans.setTransformGroup(rootTransformGroup); mouseTrans.setSchedulingBounds(boundingSphere); group.addChild(mouseTrans); universe.getViewingPlatform().setNominalViewingTransform(); universe.addBranchGraph(group); }
SimpleUniverse.getPreferredConfiguration();
/** * Creates the "view" side of the scene graph. The passed in parameters * override the default values where appropriate. * * @param viewingPlatform The viewingPlatform to use to create * the "view" side of the scene graph. * @param viewer The viewer object to use to create * the "view" side of the scene graph. * @param localeFactory The factory used to create the Locale Object */ public SimpleUniverse(ViewingPlatform viewingPlatform, Viewer viewer, LocaleFactory localeFactory ) { createLocale( null, localeFactory ); viewingPlatform.setUniverse( this ); // Assign object references. this.viewer = new Viewer[1]; this.viewer[0] = viewer; // Add the ViewingPlatform to the Viewer object. this.viewer[0].setViewingPlatform(viewingPlatform); // Add the ViewingPlatform to the locale - the scene // graph is now "live". locale.addBranchGraph(viewingPlatform); }
simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene);
SimpleUniverse u=new SimpleUniverse(); u.addBranchGraph(group); u.getViewingPlatform().setNominalViewingTransform();