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.
- Include the necessary headers:
#include <osg/Switch> #include <osgDB/ReadFile> #include <osgGA/GUIEventHandler> #include <osgViewer/Viewer> #include <iostream>
TimerInfostructure is first defined to manage the parameters (mainly the trigger time of the timer) ...