- OpenSceneGraph 3.0: Beginner's Guide
- Rui Wang Xuelei Qian
- 168字
- 2021-03-27 00:35:41
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.
- 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();
- Build and run it at once:
- You will see no difference between this example and the previous "Hello World". So what actually happened?
What just happened?
In this example, we introduced two new OSG classes: osg::ref_ptr<>
and osg::Node
. The osg::Node
class represents the basic element of a scene graph. The variable root
stands for the root node of a Cessna model, which is used as the scene data to be visualized.
Meanwhile, an instance of the osg::ref_ptr<>
class template is created to manage the node object. It is a smart pointer, which provides additional features for the purpose of efficient memory management.
推薦閱讀
- Creo Parametric 8.0中文版基礎入門一本通
- AutoCAD 2010中文版基礎教程(第2版)
- HTML5 Multimedia Development Cookbook
- Adobe Photoshop 網頁設計與制作標準實訓教程(CS5修訂版)
- Moodle 2 for Teaching 4/9 Year Olds Beginner's Guide
- 詳解AutoCAD 2022建筑設計(第6版)
- ADOBE FLASH PROFESSIONAL CS6 標準培訓教材
- Premiere視頻編輯項目教程:Premiere Pro 2020(微課版)
- Adobe創意大學Illustrator CS5 產品專家認證標準教材
- Google App Engine Java and GWT Application Development
- Instant Testing with QUnit
- 從零開始:Illustrator CC中文版基礎培訓教程
- Premiere Pro CC 2015中文版基礎與實例教程(第4版)
- LaTeX論文寫作教程
- Photoshop CC 平面設計