Examples of Canvas3D

The basic Java 3D monoscopic rendering loop is as follows:

In both cases, the entire loop, beginning with clearing the canvas and ending with swapping the buffers, defines a frame. The application is given the opportunity to render immediate-mode geometry at any of the clearly identified spots in the rendering loop. A user specifies his or her own rendering methods by extending the Canvas3D class and overriding the preRender, postRender, postSwap, and/or renderField methods. Updates to live Geometry, Texture, and ImageComponent objects in the scene graph are not allowed from any of these callback methods.

Serialization

Canvas3D does not support serialization. An attempt to serialize a Canvas3D object will result in an UnsupportedOperationException being thrown.

Additional Information

For more information, see the Introduction to the Java 3D API and View Model documents. @see Screen3D @see View @see GraphicsContext3D

  • xenon3d.Canvas3D
    The Canvas3D class provides a drawing canvas for 3D rendering. It is used either for on-screen rendering or off-screen rendering.

    NOTE: the rendering process automatically starts as soon as a the Canvas3D is attached to a Container. By default, the rendering is only done whenever a paint event for the Canvas3D occours. For most 3D applications, it will be more appropriate for the rendering to occour as fast as possible or at fixed time intervalls. Use the start() and stop() methods to turn fast rendering on or off. @author Volker Everts @version 0.1 - 13.08.2011: Created


  • Examples of com.xith3d.scenegraph.Canvas3D

        });
       
        if(peerWindow!=null){
            peerWindow.setLocation(x, y);
        }
        canvas=new Canvas3D();
        canvas.set3DPeer(canvasPeer);
        view = new View();
       
        view.addCanvas3D(canvas);
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

          pos2DX =  in.readInt();
          pos2DY =  in.readInt();
        }
     
            java.awt.GraphicsConfiguration r = SimpleUniverse.getPreferredConfiguration();
            canvas3D = new Canvas3D(r);
           
            canvas3D.setDoubleBufferEnable(true);
            universe = new SimpleUniverse(canvas3D);

            rootGroup = new BranchGroup();
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

                y = (screenSize.height - height) / 2;
            }
            setLocation(x, y);
            setSize(width, height);
            _universe = universe;
            _canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
            _universe.addCanvas(_canvas);
            _viewTransform = new ViewTransform(_universe
                    .getViewingPlatform(_canvas));
            _viewTransform.autoZoom();
            getContentPane().add(_canvas, BorderLayout.CENTER);
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

        private void cleanupViewer(Viewer v) {
            // Get view associated with this SimpleUniverse
            View view = v.getView();
            // 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();
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

        }
        try {
          // Ensure unused canvases are freed
          System.gc();
          // Create a Java 3D canvas 
          return new Canvas3D(this.configuration, offscreen) {
              @Override
              public void preRender() {
                if (renderingObserver != null) {
                  renderingObserver.canvas3DPreRendered(this);
                }
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

       * Returns a new off screen <code>canva3D</code> at the given size.
       * @throws IllegalRenderingStateException  if the canvas 3D couldn't be created.
       *    To avoid this exception, call {@link #isOffScreenImageSupported() isOffScreenImageSupported()} first.
       */
      public Canvas3D getOffScreenCanvas3D(int width, int height) {
        Canvas3D offScreenCanvas = getCanvas3D(true, null);
        // Configure canvas 3D for offscreen
        Screen3D screen3D = offScreenCanvas.getScreen3D();
        screen3D.setSize(width, height);
        screen3D.setPhysicalScreenWidth(2f);
        screen3D.setPhysicalScreenHeight(2f / width * height);
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        ImageComponent2D imageComponent2D = new ImageComponent2D(ImageComponent2D.FORMAT_RGB, image);
        imageComponent2D.setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
        offScreenCanvas.setOffScreenBuffer(imageComponent2D);
        return offScreenCanvas;
      }
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

       * Returns an image at the given size of the 3D <code>view</code>.
       * This image is created with an off screen canvas.
       * @throws IllegalRenderingStateException  if the image couldn't be created.
       */
      public BufferedImage getOffScreenImage(View view, int width, int height)  {
        Canvas3D offScreenCanvas = null;
        RenderingErrorObserver previousRenderingErrorObserver = getRenderingErrorObserver();
        try {
          // Replace current rendering error observer by a listener that counts down
          // a latch to check further if a rendering error happened during off screen rendering
          // (rendering error listener is called from a notification thread)
          final CountDownLatch latch = new CountDownLatch(1);
          setRenderingErrorObserver(new RenderingErrorObserver() {
              public void errorOccured(int errorCode, String errorMessage) {
                latch.countDown();
              }
            });
         
          // Create an off screen canvas and bind it to view
          offScreenCanvas = getOffScreenCanvas3D(width, height);
          view.addCanvas3D(offScreenCanvas);
         
          // Render off screen canvas
          offScreenCanvas.renderOffScreenBuffer();
          offScreenCanvas.waitForOffScreenRendering();
         
          // If latch count becomes equal to 0 during the past instructions or in the coming 10 milliseconds,
          // this means that a rendering error happened
          if (latch.await(10, TimeUnit.MILLISECONDS)) {
            throw new IllegalRenderingStateException("Off screen rendering unavailable");
          }
         
          return offScreenCanvas.getOffScreenBuffer().getImage();
        } catch (InterruptedException ex) {
          IllegalRenderingStateException ex2 =
              new IllegalRenderingStateException("Off screen rendering interrupted");
          ex2.initCause(ex);
          throw ex2;
        } finally {
          if (offScreenCanvas != null) {
            view.removeCanvas3D(offScreenCanvas);
            try {
              // Free off screen buffer and context
              offScreenCanvas.setOffScreenBuffer(null);
            } catch (NullPointerException ex) {
              // Java 3D 1.3 may throw an exception
            }
          }
          // Reset previous rendering error listener
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

        /**
         * Layouts components.
         */
        private void layoutComponents() {
          // Remove default canvas 3D to put it in another place
          Canvas3D defaultCanvas = getCanvas3D();
          remove(defaultCanvas);
          setLayout(new GridBagLayout());
         
          // Place the 4 canvas differently depending on US or other country
          if (Locale.getDefault().equals(Locale.US)) {
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

      */ 
      private Canvas3D createCanvas(boolean b)
      {
      GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
       gc1 = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template);
      return new Canvas3D(gc1,b);
      }
    View Full Code Here

    Examples of javax.media.j3d.Canvas3D

      */ 
      private Canvas3D createCanvas(boolean b)
      {
      GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
       gc1 = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template);
      return new Canvas3D(gc1,b);
      }
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.