Time for action - creating a user timer

A timer event is emitted whenever the internal counter reaches a specified interval. This is common in various GUI systems, and allows users to set a customized timer callback to receive the timing message and implement related operations.

Now we are able to realize the same work in OSG. As there are no standard timer events defined in the osgGA::GUIEventAdapter class, we have to make use of the USER event type, as well as an additional data pointer.

  1. Include the necessary headers:
    #include <osg/Switch>
    #include <osgDB/ReadFile>
    #include <osgGA/GUIEventHandler>
    #include <osgViewer/Viewer>
    #include <iostream>
  2. A TimerInfo structure is first defined to manage the parameters (mainly the trigger time of the timer) ...

Get OpenSceneGraph 3.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.