Class RMTrackballControl

All Implemented Interfaces:
RMDocument.DocListener, ImageObserver, MenuContainer, Serializable

public class RMTrackballControl extends RMViewer
This class implements the trackball widget. It is an optional replacement for the Scene3DControl.

Trackball inherits the RMScene3D's behavior, which is that mouse motion in the x direction changes the pitch, and mouse motion in the y direction changes the yaw. The controll adds rotation about the z axis (roll) by clicking on a ring outside the trackball.

Note that this particular behavior quickly goes wrong, since Rotate(y,x,z) * Rotate(dy,dx,dz) != Rotate (y+dy, x+dx, z+dz)

To make the behavior more reasonable, we could try any of : 1. Make Scene3D keep a matrix,instead of the euler angles and just keep rotating that by dx,dy,dz 2. Get the matrix, rotate by dx,dy,dz, decompose into new euler angles and set those 3. Use quaternions (gasp)

See Also:
  • Constructor Details

    • RMTrackballControl

      public RMTrackballControl()
  • Method Details

    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Overrides:
      setBounds in class Component
    • configureScene

      public void configureScene()
    • isOpaque

      public boolean isOpaque()
      Overrides:
      isOpaque in class JComponent
    • drawsBackground

      public boolean drawsBackground()
      Description copied from class: RMViewer
      Returns whether or not the gutter, page background & dropshadow get drawn.
      Overrides:
      drawsBackground in class RMViewer
    • setSceneTool

      public void setSceneTool(Tool st)
      Set the tool which will get callbacks from this control
    • mousePressed

      public void mousePressed(MouseEvent anEvent)
      Handle mouse pressed event.
      Overrides:
      mousePressed in class RMViewer
    • mouseDragged

      public void mouseDragged(MouseEvent anEvent)
      Handle mouse dragged event.
      Overrides:
      mouseDragged in class RMViewer
    • mouseReleased

      public void mouseReleased(MouseEvent anEvent)
      Handle mouse released event.
      Overrides:
      mouseReleased in class RMViewer
    • paintComponent

      public void paintComponent(Graphics g)
      Description copied from class: RMViewer
      Overrides JComponent implementation to paint viewer shapes and page, margin, grid, etc.
      Overrides:
      paintComponent in class RMViewer
    • getMouseAngle

      public double getMouseAngle(Point p)
      Returns the angle from the mousePoint to the center of the control, in radians
    • positionKnob

      public void positionKnob(Point p)
      Move the collar knob to the correct location for the given mouse point
    • getScene

      public RMScene3D getScene()
      Returns the scene in this control.
    • sync

      public void sync(RMScene3D s1, RMScene3D s2)