A SERVICE OF

logo

140
Chapter 12: User Interface Mechanisms
When csWindow::setFreeRun() is TRUE, callbacks are invoked only when the main loop
goes idle, similar to the CONTINUE mode. Otherwise, callbacks occur with every event
but nothing happens when the main loop is idle.
With the either of these event callback mechanisms, the event information, returned by
getEvents(), is extracted from the csEvent objects. The application, however, does not
need to call resetEvents(); it is called automatically.
Querying Devices
In addition to the above csEvent-centered model, you can use the methods getMouseX(),
getMouseY(), getMouseButtons(), and getDevice() to query the current value of each
user input device. This approach is discouraged.
Selecting Screen Objects
Cosmo 3D enables the selection of screen objects in the following ways:
csIsectActionselects the shape closest to the origin of a ray that is intersected by
that ray.
csCamera::pick()selects the shape closest to the camera based on window
coordinates.
These methods use a csHit object for storing the selected objects.
Using csIsectAction
csIsectAction, when applied to the root node selects all graphical objects intersected by
a ray stored in a csSeg, as shown in Figure 12-1.