Customizing your own NodeKits

The most important step in customizing a node and extending new features is to override the virtual method traverse(). This method is called every frame by the OSG rendering backend. The traverse() method has an input parameter, osg::NodeVisitor&, which actually indicates the type of traversals (update, event, or cull). Most OSG NodeKits override traverse() to implement their own functionalities, along with some other exclusive attributes and methods.

Note that overriding the traverse() method is a bit dangerous sometimes, because it affects the traversing process and may lead to the incorrect rendering of results if developers are not careful enough. It is also a little awkward if you want to add the same new feature ...

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.