Class RMTrackballControl

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Scrollable

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()
      Creates a new trackball control
  • Method Details

    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Description copied from class: RMViewer
      Overrides to update ZoomFactor if dynamic.
      Overrides:
      setBounds in class RMViewer
    • configureScene

      public void configureScene()
      Reconfigure scene.
    • getDrawsBackground

      public boolean getDrawsBackground()
      Tell RM not to erase the background.
      Overrides:
      getDrawsBackground in class RMViewer
    • 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
    • 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.
    • syncFrom

      public void syncFrom(RMScene3D aScene)
      Sync from given scene to this scene control.
    • syncTo

      public void syncTo(RMScene3D aScene)
      Sync to a given scene from this scene control.