Time for action—clicking and selecting geometries
Our task this time is to implement a very common task in 3D software—clicking to select an object in the world and showing a selection box around the object. The bounding box of the selected geometry should be good for representing a selection box, and the osg::ShapeDrawable
class can quickly generate a simple box for display purposes. The osg::PolygonMode
attribute will then make the rendering pipeline only draw the wireframes of the box, which helps to show the selection box as brackets. These are all we need to produce practical picking object functionalities.
- Include the necessary headers:
#include <osg/MatrixTransform> #include <osg/ShapeDrawable> #include <osg/PolygonMode> #include <osgDB/ReadFile> ...
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.