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.
- Include the necessary headers:
#include <osg/MatrixTransform> #include <osgDB/ReadFile> #include <osgViewer/Viewer>
- Load the Cessna model first:
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile( "cessna.osg" );
- The
osg::MatrixTransform
class is derived fromosg::Group
, so it can use theaddChild()
method to add more children. All child nodes will be affected by theosg::MatrixTransform
node and be transformed according to the presetting matrix. Here, we ...
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.