To create truly interactive object graphics, you must allow the user to transform the position or orientation of objects using the mouse. One way to do this is to provide a virtual trackball that lets the user manipulate objects interactively on the screen.
The procedure file
trackball__define.pro, found in the
lib directory of the IDL distribution, contains the object definition procedure for a virtual trackball object. This trackball object is used in several of the examples presented later in this volume, and is also used by other example and demonstration code included with IDL. The trackball object has three methods: Init, Update, and Reset. These methods allow you to retrieve mouse movement events and alter your model transformations accordingly.
The trackball object behaves as if there were an invisible trackball, centered at a position you specify, overlaid on a draw widget. The widget application's event handler uses the widget event information to update both the trackball's state and the model transformation of the objects displayed in the draw widget's window object. When the user clicks and drags in the draw widget, objects in the draw widget rotate as if the user were manipulating them with a physical trackball.
See TrackBall for details on creating and using trackball objects. Several of the other example files located in the
examples/visual subdirectory of the IDL distribution include trackball objects, and may be studied for further insight into the mechanics of transforming object hierarchies based on user input.