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

Revision 11020, 1.4 kB (checked in by robert, 4 years ago)

From Wang Rui, added osgParticle serializers

Line 
1#include <osgParticle/ParticleSystemUpdater>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6static bool checkParticleSystems( const osgParticle::ParticleSystemUpdater& updater )
7{
8    return updater.getNumParticleSystems()>0;
9}
10
11static bool readParticleSystems( osgDB::InputStream& is, osgParticle::ParticleSystemUpdater& updater )
12{
13    unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
14    for ( unsigned int i=0; i<size; ++i )
15    {
16        osgParticle::ParticleSystem* ps = dynamic_cast<osgParticle::ParticleSystem*>( is.readObject() );
17        if ( ps ) updater.addParticleSystem( ps );
18    }
19    is >> osgDB::END_BRACKET;
20    return true;
21}
22
23static bool writeParticleSystems( osgDB::OutputStream& os, const osgParticle::ParticleSystemUpdater& updater )
24{
25    unsigned int size = updater.getNumParticleSystems();
26    os << size << osgDB::BEGIN_BRACKET << std::endl;
27    for ( unsigned int i=0; i<size; ++i )
28    {
29        os << updater.getParticleSystem(i);
30    }
31    os << osgDB::END_BRACKET << std::endl;
32    return true;
33}
34
35REGISTER_OBJECT_WRAPPER( osgParticleParticleSystemUpdater,
36                         new osgParticle::ParticleSystemUpdater,
37                         osgParticle::ParticleSystemUpdater,
38                         "osg::Object osg::Node osgParticle::ParticleSystemUpdater" )
39{
40    ADD_USER_SERIALIZER( ParticleSystems );  // _psv
41}
Note: See TracBrowser for help on using the browser.