-
Book Overview & Buying
-
Table Of Contents
OpenSceneGraph 3.0: Beginner's Guide
An octahedron is a polyhedron having eight triangle faces. It is really a nice example to show why primitive indexing is important. We will first sketch the octahedron structure, as shown in the following image:

The octahedron has six vertices, each shared by four triangles. We would have to create a vertex array with 24 elements to render all eight faces when using osg::DrawArrays. However, with the help of an index array and the osg::DrawElementsUInt class, we can allocate a vertex array with only six elements and thus improve the efficiency of drawing the geometry.
Include the necessary headers:
#include <osg/Geometry> #include <osg/Geode> #include <osgUtil/SmoothingVisitor> #include <osgViewer/Viewer>
As we have discussed before, the osg::Vec3Array class inherits the characteristics of std::vector and can construct using a predetermined size parameter and work with operator[] directly.
osg::ref_ptr<osg::Vec3Array> vertices...
Change the font size
Change margin width
Change background colour