All Implemented Interfaces:
SceneChangeListener, MouseListener, MouseMotionListener, MouseWheelListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
OpenGLPanel

Viewport is an JPanel that uses a set of RenderPasses to draw the Registry.getScene() from the perspective of the active Camera. Mouse actions in the panel can be used to manipulate the active camera.
See Also:
  • Field Details

  • Constructor Details

    • Viewport

      public Viewport()
    • Viewport

      public Viewport(LayoutManager layout)
  • Method Details

    • saveRenderPassState

      public void saveRenderPassState()
      Save the viewport pass state to the Preferences.
    • addNotify

      public void addNotify()
      Overrides:
      addNotify in class JComponent
    • removeNotify

      public void removeNotify()
      Overrides:
      removeNotify in class JComponent
    • renderAllPasses

      public void renderAllPasses()
    • updateAllNodes

      public void updateAllNodes(double dt)
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseWheelMoved

      public void mouseWheelMoved(MouseWheelEvent e)
      Specified by:
      mouseWheelMoved in interface MouseWheelListener
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • getOrbitChangeFactor

      public double getOrbitChangeFactor()
    • setOrbitChangeFactor

      public void setOrbitChangeFactor(double amount)
      Parameters:
      amount - a value greater than one.
    • getRayThroughPoint

      public Ray getRayThroughPoint(Camera camera, double normalizedX, double normalizedY)

      Return the ray, in world space, that starts at the camera and passes through this viewport at (x,y) in the current projection. x,y should be normalized screen coordinates adjusted for the vertical flip.

      Remember that in OpenGL the camera -Z=forward, +X=right, +Y=up

      Parameters:
      normalizedX - the cursor position in screen coordinates [-1,1]
      normalizedY - the cursor position in screen coordinates [-1,1]
      Returns:
      the ray coming through the viewport in the current projection.
    • getRayThroughPointUntransformed

      public Ray getRayThroughPointUntransformed(Camera camera, double normalizedX, double normalizedY)

      Return the ray, in camera space, that starts at the origin and passes through this viewport at (x,y) in the current projection. x,y should be normalized screen coordinates adjusted for the vertical flip.

      Remember that in OpenGL the camera -Z=forward, +X=right, +Y=up

      Parameters:
      normalizedX - the cursor position in screen coordinates [-1,1]
      normalizedY - the cursor position in screen coordinates [-1,1]
      Returns:
      the ray coming through the viewport in the current projection.
    • getCursorAsNormalized

      public javax.vecmath.Vector3d getCursorAsNormalized()
      In OpenGL camera space +Y is up and in screen space +Y is down so invert the Y value.
      Returns:
      the cursor position as (-1...1,-1...1,0).
    • getCursorAsNormalized

      public javax.vecmath.Vector3d getCursorAsNormalized(double x, double y)
      In OpenGL camera space +Y is up and in screen space +Y is down so invert the Y value.
      Returns:
      the cursor position as (-1...1,-1...1,0).
    • getCursorPosition

      public javax.vecmath.Point2d getCursorPosition()
    • getAspectRatio

      public double getAspectRatio()
    • getNumTools

      public int getNumTools()
    • setActiveToolIndex

      public void setActiveToolIndex(int index)
      Set the active tool by index.
      Parameters:
      index - the index of the tool to activate.
    • getActiveToolIndex

      public int getActiveToolIndex()
    • getTool

      public ViewportTool getTool(int index)
    • getUserMovementScale

      public double getUserMovementScale()
    • setUserMovementScale

      public void setUserMovementScale(double scale)
      Set the scale of user movement. This is used to scale the mouse movement to the camera movement.
      Parameters:
      scale - a value greater than zero.
    • beforeSceneChange

      public void beforeSceneChange(Node oldScene)
      Description copied from interface: SceneChangeListener
      Called before the scene changes. This is a good time to unregister listeners.
      Specified by:
      beforeSceneChange in interface SceneChangeListener
      Parameters:
      oldScene - the scene that is about to be replaced.
    • afterSceneChange

      public void afterSceneChange(Node newScene)
      Description copied from interface: SceneChangeListener
      Called after the scene changes. This is a good time to register listeners.
      Specified by:
      afterSceneChange in interface SceneChangeListener
      Parameters:
      newScene - the scene that has just been added.
    • getActiveCamera

      public Camera getActiveCamera()
    • setActiveCamera

      public void setActiveCamera(Camera camera)
    • isHardwareAccelerated

      public boolean isHardwareAccelerated()
    • setHardwareAccelerated

      public void setHardwareAccelerated(boolean selected)
    • isVerticalSync

      public boolean isVerticalSync()
    • setVerticalSync

      public void setVerticalSync(boolean selected)
    • getFsaaSamples

      public int getFsaaSamples()
    • setFsaaSamples

      public void setFsaaSamples(Integer value)
    • savePrefs

      public void savePrefs()
    • isOriginShift

      public boolean isOriginShift()
    • setOriginShift

      public void setOriginShift(boolean b)
    • addToolChangeListener

      public void addToolChangeListener(ViewportToolChangeListener arg0)
    • removeToolChangeListener

      public void removeToolChangeListener(ViewportToolChangeListener arg0)