Package snap.gfx3d

Class Trackball

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable

public class Trackball extends ParentView
This class implements the trackball widget. It is an optional replacement for the Scene3DControl. Trackball encapsulates the Scene3D'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)
  • Constructor Details

    • Trackball

      public Trackball()
      Creates a Trackball.
  • Method Details

    • getYaw

      public double getYaw()
      Returns the rotation about the Y axis in degrees.
    • setYaw

      public void setYaw(double aValue)
      Sets the rotation about the Y axis in degrees.
    • getPitch

      public double getPitch()
      Returns the rotation about the X axis in degrees.
    • setPitch

      public void setPitch(double aValue)
      Sets the rotation about the X axis in degrees.
    • getRoll

      public double getRoll()
      Returns the rotation about the Z axis in degrees.
    • setRoll

      public void setRoll(double aValue)
      Sets the rotation about the Z axis in degrees.
    • setWidth

      public void setWidth(double aValue)
      Override to add scuff marks.
      Overrides:
      setWidth in class View
    • addScuffMarks

      protected void addScuffMarks()
      Adds scuffmark polygons at random points on the trackball.
    • paintAbove

      protected void paintAbove(Painter aPntr)
      Override to paint scene.
      Overrides:
      paintAbove in class ParentView
    • processEvent

      protected void processEvent(ViewEvent anEvent)
      Handle events.
      Overrides:
      processEvent in class View
    • mousePressed

      protected void mousePressed(ViewEvent anEvent)
      Handle mouse press.
    • mouseDragged

      protected void mouseDragged(ViewEvent anEvent)
      Handle mouse drag.
    • mouseReleased

      protected void mouseReleased(ViewEvent anEvent)
      Handle mouse release.
    • syncFrom

      public void syncFrom(Camera aScene)
      Sync from given camera to this trackball.
    • syncTo

      public void syncTo(Camera aScene)
      Sync to a given camera from this trackball.