Time for action - drawing an octahedron
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: