Esempio n. 1
0
  public View(Frame frame, int resolutionX, int resolutionY, int colorDepth, boolean fullscreen) {
    this.frame = frame;

    // *** set up graphics configuration ***
    if (fullscreen) {
      frame.setUndecorated(true);

      if (GraphicsEnvironment.getLocalGraphicsEnvironment()
          .getDefaultScreenDevice()
          .isFullScreenSupported()) {
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .setFullScreenWindow(frame);
      }

      if (GraphicsEnvironment.getLocalGraphicsEnvironment()
          .getDefaultScreenDevice()
          .isDisplayChangeSupported()) {
        DisplayMode displayMode =
            new DisplayMode(resolutionX, resolutionY, colorDepth, DisplayMode.REFRESH_RATE_UNKNOWN);
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .setDisplayMode(displayMode);
      }
    }
    graphicsConfiguration = SimpleUniverse.getPreferredConfiguration();
    canvas3D = new MyCanvas3D(graphicsConfiguration);
    canvas3D.setDoubleBufferEnable(true);
    canvas3D.getGraphicsContext3D().setBufferOverride(false);

    // *** create universe ***
    universe = new SimpleUniverse(canvas3D);
    universe.getViewer().getView().setSceneAntialiasingEnable(true);
    canvas3D.getView().setFrontClipDistance(0.1f);
    canvas3D.getView().setBackClipDistance(50000f);
    // universe.setJ3DThreadPriority(Thread.MIN_PRIORITY);

    // *** create camera ***
    TransformGroup cameraTransformGroup =
        universe.getViewingPlatform().getMultiTransformGroup().getTransformGroup(0);
    camera = new Camera(cameraTransformGroup);

    canvas3D.startRenderer();
  }