//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);
/** * 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(); } }
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 ); }