Package javax.media.j3d

Examples of javax.media.j3d.Canvas3D$EvaluateLock


      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


            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

    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

    }
    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

   * 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

   * 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

    /**
     * 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

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

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

    //Mechanism for closing the window and ending the program.
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


    //Default settings for the viewer parameters.
    myCanvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());


    //Construct the SimpleUniverse:
    //First generate it using the Canvas.
    SimpleUniverse simpUniv = new SimpleUniverse(myCanvas3D);
View Full Code Here

TOP

Related Classes of javax.media.j3d.Canvas3D$EvaluateLock

Copyright © 2018 www.massapicom. 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.