Serializing Plug-in Data
 
 
 

In a Mudbox plug-in you can load or save plug-in data with the scene by overloading the Node::Serialize() method. Mudbox will call Node::Serialize() method with an initialized Stream object. You can then query Stream::IsStoring() to implement the saving or loading application logic, depending on whether the return value is true or false respectively.

Any attributes you create in a plug-in that you wish serialized with the scene will have to be manually serialized. For example:

MyPlugin : Node {
    Attribute A;
    Attribute B;

    public:
        MyPlugin::Serialize(Stream& s) {
            if ( s.IsStoring() ) {
                s << A << B;
            } else {        
                s >> A >> B;
            }
        }
};

The Mudbox SDK also provides an overload of the operator== to mean Node::Serialize(). So alternatively you can write:

MyPlugin : Node {
    Attribute A;
    Attribute B;

    public:
        MyPlugin::Serialize(Stream& s) {
            s == A == B;    
        }
};