OpenGLContext.trackball
index
p:\openglcontext\trackball.py

Classic trackball mechanism for interactive rotation

 
Modules
            
Numeric
copy
copy_reg
OpenGLContext.dragwatcher
math
multiarray
pickle
OpenGLContext.quaternion
string
types
 
Classes
            
Trackball
 
class Trackball
      Trackball mechanism for interactive rotation
 
Use the trackball utility to rotate a viewpoint
around a fixed world-space coordinate (center).
 
This trackball is a simple x/y grid of polar
coordinates.  Dragging to the left rotates the
eye around the object to view the left side,
similarly for right, top, bottom.
 
   Methods defined here:
__init__(self, position, quaternion, center, originalX, originalY, width, height, dragAngle=6.2831853071795862)
Initialise the Trackball
 
position -- object-space original position (camera pos)
 
quaternion -- camera orientation as a quaternion
 
originalX, originalY -- the initial screen
        coordinates of the drag
 
width, height -- the dimensions of the screen
        (newX-originalX)/(fractional width) used by
        trackball algorithm
        
center -- the x,y,z world coordinates around which
        we are to rotate the application will need to
        use some heuristic to determine the most appropriate
        center of rotation.  For instance, when the user
        first clicks, check for an object in the "center" of
        the display, use the center of that object (or
        possibly the midpoint between the greatest and least
        Z-buffer values) projected back into world space
        coordinates.  If there is no available object,
        potentially use the maximum and minimum of the whole
        Z buffer. If there are no rendered elements at all
        then use some multiple of the near frustum (20 or
        30, for example)
dragAngle -- maximum rotation angle for a drag
cancel(self)
Cancel drag rotation, return pos,quat to original values
update(self, newX, newY)
Update with new x,y drag coordinates
 
newX, newY -- the new screen coordinates for the drag
 
returns a new position and quaternion orientation

Data and non-method functions defined here:
__doc__ = 'Trackball mechanism for interactive rotation\n\t\n\t...e left side,\n\tsimilarly for right, top, bottom.\n\t'
__module__ = 'OpenGLContext.trackball'