Time for action - performing translations of child nodes

Now we are going to make use of the transformation node. The osg::MatrixTransform node, which multiplies the current model-view matrix with a specified one directly, will help to transfer our model to different places in the viewing space.

  1. Include the necessary headers:
    #include <osg/MatrixTransform>
    #include <osgDB/ReadFile>
    #include <osgViewer/Viewer>
  2. Load the Cessna model first:
    osg::ref_ptr<osg::Node> model = osgDB::readNodeFile( "cessna.osg" );
  3. The osg::MatrixTransform class is derived from osg::Group, so it can use the addChild() method to add more children. All child nodes will be affected by the osg::MatrixTransform node and be transformed according to the presetting matrix. Here, ...

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.