Time for action—driving the Cessna

We have learnt how to change the transformation matrix of a model with the osg::MatrixTransform nodes. With the help of the osg::AnimationPath class and the osgAnimation namespace, we can even create animation effects on these transformable objects. But this is not enough for an interactive scene. Our further requirement is to control scene graph nodes with user input devices. Imagine that we have a submarine, a tank, or a familiar Cessna in a modern warfare game. It will be really exciting if we can simulate driving it with the keyboard, mouse, or even joysticks.

  1. Include the necessary headers:
    #include <osg/MatrixTransform> #include <osgDB/ReadFile> #include <osgGA/GUIEventHandler> #include <osgViewer/Viewer> ...

Get OpenSceneGraph 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.