Time for action—improving the "Hello World" example

The included headers, <osgDB/ReadFile> and <osgViewer/Viewer>, do not need to be modified. We only add a root variable that provides the runtime access to the Cessna model and assigns it to the setSceneData() method.

  1. In the main entry, record the Cessna model with a variable named root:
    osg::ref_ptr<osg::Node> root = osgDB::readNodeFile("cessna.osg");
    osgViewer::Viewer viewer;
    viewer.setSceneData( root.get() );
    return viewer.run();
  2. Build and run it at once:
    Time for action—improving the "Hello World" example
  3. You will see no difference between this example and the previous "Hello World". So what actually happened?

What just happened?

In this example, 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.