| | |
- Trackball
class Trackball |
| |
Class implementing classic trackball mechanism for specifying rotations
Use the trackball utility to rotate ourselves around some point
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)
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. |
| |
- __init__(self, position, quaternion, center, originalX, originalY, width, height, dragAngle=6.2831853071795862)
- cancel(self)
- Cancel drag rotation, return original values
- update(self, newX, newY)
- Given new x,y drag coordinates, return a new position and orientation
newX, newY -- the new screen coordinates for the drag
| |