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 cave ...

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.