root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osgParticle/ModularProgram.cpp @ 11020

Revision 11020, 1.3 kB (checked in by robert, 5 years ago)

From Wang Rui, added osgParticle serializers

Line 
1#include <osgParticle/ModularProgram>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6static bool checkOperators( const osgParticle::ModularProgram& prog )
7{
8    return prog.numOperators()>0;
9}
10
11static bool readOperators( osgDB::InputStream& is, osgParticle::ModularProgram& prog )
12{
13    unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
14    for ( unsigned int i=0; i<size; ++i )
15    {
16        osgParticle::Operator* op = dynamic_cast<osgParticle::Operator*>( is.readObject() );
17        if ( op ) prog.addOperator( op );
18    }
19    is >> osgDB::END_BRACKET;
20    return true;
21}
22
23static bool writeOperators( osgDB::OutputStream& os, const osgParticle::ModularProgram& prog )
24{
25    unsigned int size = prog.numOperators();
26    os << size << osgDB::BEGIN_BRACKET << std::endl;
27    for ( unsigned int i=0; i<size; ++i )
28    {
29        os << prog.getOperator(i);
30    }
31    os << osgDB::END_BRACKET << std::endl;
32    return true;
33}
34
35REGISTER_OBJECT_WRAPPER( osgParticleModularProgram,
36                         new osgParticle::ModularProgram,
37                         osgParticle::ModularProgram,
38                         "osg::Object osg::Node osgParticle::ParticleProcessor osgParticle::Program osgParticle::ModularProgram" )
39{
40    ADD_USER_SERIALIZER( Operators );  // _operators
41}
Note: See TracBrowser for help on using the browser.