Time for action—creating serializers for user-defined classes
To create serializers for a class and make it accessible from OSG native formats, there are some preconditions: firstly, the class must be derived from osg::Object
, either directly or indirectly; secondly, the class must be declared in a namespace, and uses META_Object
to define the correct namespace and class names; finally and most importantly, the class must have at least a getter and a setter method for each member property, which makes it serializable, that is, it can be stored to OSG native scene files and deserialized to a cloned scene object at any time.
- Include the necessary headers:
#include <osg/Node> #include <osgDB/ObjectWrapper> #include <osgDB/Registry> #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.