| 1 | #include <osgParticle/ModularProgram> |
|---|
| 2 | #include <osgDB/ObjectWrapper> |
|---|
| 3 | #include <osgDB/InputStream> |
|---|
| 4 | #include <osgDB/OutputStream> |
|---|
| 5 | |
|---|
| 6 | static bool checkOperators( const osgParticle::ModularProgram& prog ) |
|---|
| 7 | { |
|---|
| 8 | return prog.numOperators()>0; |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | static 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 | |
|---|
| 23 | static 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 | |
|---|
| 35 | REGISTER_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 ); |
|---|
| 41 | } |
|---|