/** * Sets a view attach policy appropriate for a window eyepoint policy. * * @param v Viewer to which the ViewingPlatform will be attached * @param vp ViewingPlatform to which the Viewer will be attached */ private void setDerivedAttachPolicy(Viewer v, ViewingPlatform vp) { if (v.getView().getWindowEyepointPolicy() != View.RELATIVE_TO_FIELD_OF_VIEW) { vp.getViewPlatform().setViewAttachPolicy(View.NOMINAL_SCREEN); } }
private void createFramesAndPanels( boolean setVisible ) { j3dJFrames = new JFrame[canvases.length]; j3dJPanels = new JPanel[canvases.length]; j3dWindows = new Window[canvases.length]; for (int i = 0; i < canvases.length; i++) { j3dWindows[i] = j3dJFrames[i] = new JFrame(); j3dJFrames[i].getContentPane().setLayout(new BorderLayout()); j3dJFrames[i].setSize(256, 256); // Put the Canvas3D into a JPanel. j3dJPanels[i] = new JPanel(); j3dJPanels[i].setLayout(new BorderLayout()); j3dJPanels[i].add("Center", canvases[i]); j3dJFrames[i].getContentPane().add("Center", j3dJPanels[i]); if (setVisible) { j3dJFrames[i].setVisible(true); } addWindowCloseListener(j3dJFrames[i]); } }
/** * Returns the canvas associated with this Viewer object. * @deprecated superceded by getCanvas3D() */ public Canvas3D getCanvases() { return getCanvas3D(); }
/** * Cleanup memory references used by ConfiguredUniverse. * @since Java 3D 1.3.1 */ @Override public void cleanup() { if (viewer != null) { for (int i = 0 ; i < viewer.length ; i++) { viewer[i].getView().removeAllCanvas3Ds(); viewer[i].setViewingPlatform(null); viewer[i] = null; } } locale = null; removeAllLocales(); configContainer.clear(); configContainer = null; } }
viewer = new Viewer[1]; viewer[0] = new Viewer(canvas); viewer[0].setViewingPlatform(vwp);
addWindowCloseListener(j3dWindows[i]); setVisible(true);
/** * Returns the ViewingPlatform object associated with this scene graph. * * @return The ViewingPlatform object of this scene graph. */ public ViewingPlatform getViewingPlatform() { return viewer[0].getViewingPlatform(); }
/** * Sets the ViewingPlatform for this behavior. This method is * called by the ViewingPlatform. * If a sub-calls overrides this method, it must call * super.setViewingPlatform(vp). * NOTE: Applications should <i>not</i> call this method. */ @Override public void setViewingPlatform(ViewingPlatform vp) { super.setViewingPlatform( vp ); if (vp==null) { enableListeners( false ); } else { if (canvases != null) { // May be switching canvases here. enableListeners(false); } // Use the canvases associated with viewer[0]; if no viewer is // available yet, see if a canvas was provided with a constructor. Viewer[] viewers = vp.getViewers(); if (viewers != null && viewers[0] != null) canvases = viewers[0].getCanvas3Ds(); if (canvases == null || canvases[0] == null) throw new IllegalStateException("No canvases available"); if (getEnable()) { enableListeners(true); } } }
/** * 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 ); }
screens.toArray(cs) ; j3dViewer = new Viewer(cs, this, setVisible) ; return j3dViewer ;
/** * 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(); } }
viewer[0] = new Viewer(canvases, null, null, setVisible); createDefaultViewingPlatform(transformCount); setDerivedAttachPolicy(viewer[0], vp) ; viewer[0].setViewingPlatform(vp);
/** * Returns the Universe to which this Viewer is attached * * @return the Universe to which this Viewer is attached * @since Java 3D 1.3 */ public SimpleUniverse getUniverse() { return getViewingPlatform().getUniverse(); }
canvases[0] = new Canvas3D(config); canvases[0].setFocusable(true); createFramesAndPanels(setVisible);
if (viewers[i].getView().getWindowEyepointPolicy() != View.RELATIVE_TO_FIELD_OF_VIEW) { nominalHead = false ; viewers[i].setViewingPlatform(viewingPlatform) ;
/** * Returns the Canvas3D object at the specified index associated with * this Java 3D Universe. * * @param canvasNum The index of the Canvas3D object to retrieve. * If there is no Canvas3D object for the given index, null is returned. * * @return A reference to the Canvas3D object associated with the * Viewer object. */ public Canvas3D getCanvas(int canvasNum) { return viewer[0].getCanvas3D(canvasNum); }
View view = viewer.getView(); fieldOfView = view.getFieldOfView();