University of illinois Urbana-Champaign

Syzygy Advanced Topics

Syzygy Advanced Topics

Input Classes

There are three basic types of input classes: sources, nodes, and sinks. An arInputSource receives events and feeds them to an arInputNode, which in turn relays them to one or more arInputSinks after optionally filtering them. An arInputSink may transmit the events to some other location or may perform arbitrary operations based on the input stream. The arInputNode maintains a list of arInputSources and arInputSinks.

Two important arInputSource subclasses are the arNetInputSource, which receives a stream of input events from a remote computer and makes it available to the local process, and the arFileSource, which reads an event stream from a file and feeds it to the local process, using the internal event time stamps to control the pace. Corresponding arInputSink classes are the arNetInputSink and arFileSink, which make an input stream available over the network or write it to a file, respectively.

An arInputNode processes events using two subsidiary classes, the arInputEventQueue and the arInputState. The arInputNode receives an arStructuredData record from an input source and unpacks it into an arInputEventQueue. It then passes each event in the queue through its list of arIOFilters. For each stage in this filtering chain it maintains an arInputState representing the most recent values of all received events; this allows the filter to perform computations based on the current event and the most recent state of all other events. Finally, it packs the filtered event queue into a new arStructuredData record and passes it to each of its arInputSinks.

Input Event Filters

Input event filters are all subclasses of the arIOFilter class. Filters are attached to an arInputNode (generally by the DeviceServer program, see the Input Devices chapter), which maintains a list of them and passes any events it receives through them.

Creating filter subclasses is quite simple. You need only override the protected virtual method

virtual bool arIOFilter::processEvent( arInputEvent& inputEvent );

 

This method will be called by the arInputNode for each event in the input stream. Is is passed the current event, and can do the following things:

  • Get the current event's type, index, or value using the appropriate methods of the arInputEvent class.
  • Get the most recent value of any other event using the arIOFilter's get...() methods.

     

  • Modify the current event's index or value (<span >not its type) using the arInput.set...() methods.
  • Set the current event's value to the default (0 or the identity matrix) using its zero() method.

     

  • Flag the current event for deletion using its trash() method.
  • Insert a new event of any type, index, and value into the input stream using the arIOFilter's insertNewEvent() method.

That is all. For examples of working filters, see src/drivers/arTrackCalFilter.cpp (which applies the calibration correction for our Ascension MotionStar tracker--note that this is specific to our setup) and thePForth filter, src/drivers/arPForthFilter.cpp.