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.
- Include necessary headers:
#include <osg/Geometry> #include <osg/Geode> #include <osgUtil/Tessellator> #include <osgViewer/Viewer>
- We will create a concave polygon by using the
osg::Geometryclass. 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 ...