Time for action - tessellating a polygon

Complex primitives will not be rendered correctly by the OpenGL API directly. This includes concave polygons, self-intersecting polygons, and polygons with holes. Only after being subdivided into convex polygons, these non-convex polygons can be accepted by the OpenGL rendering pipeline. The osgUtil::Tessellator class can be used for the tessellation work in this case.

  1. Include necessary headers:
    #include <osg/Geometry>
    #include <osg/Geode>
    #include <osgUtil/Tessellator>
    #include <osgViewer/Viewer>
    
  2. We will create a concave polygon by using the osg::Geometry class. A simple polygon is concave if any of its internal edge angles is greater than 180 degrees. Here, the example geometry represents a quad with a ...

Get OpenSceneGraph 3.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.