Time for action—generating a Bezier curve
OpenGL has provided functions to generate Bezier and NURBS curves and surfaces for years, but they are not as good as we wish. Today's geometry shader can do the same work in a more convenient and efficient way. Take the generation of a Cubic Bezier curve as an example. Given two endpoints, and two control points to the shader, it will then produce a smooth curve, with specific segments, that begins and ends at two different endpoints, and be pulled away towards the control points.
- Include the necessary headers. We'd like to change the output line width, so the
osg::LineWidth
class is used here, too:#include <osg/Program> #include <osg/LineWidth> #include <osgDB/ReadFile> #include <osgViewer/Viewer>
- The ...
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.