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

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

From Wang Rui, added osgParticle serializers

Line 
1#include <osgParticle/RadialShooter>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6#define RADIALSHOOTER_FLOAT_FUNCTION( PROP ) \
7    static bool check##PROP( const osgParticle::RadialShooter& obj ) { return true; } \
8    static bool read##PROP( osgDB::InputStream& is, osgParticle::RadialShooter& obj ) { \
9        float min, max; is >> min >> max; \
10        obj.set##PROP( min, max ); return true; \
11    } \
12    static bool write##PROP( osgDB::OutputStream& os, const osgParticle::RadialShooter& obj ) { \
13        const osgParticle::rangef& range = obj.get##PROP(); \
14        os << range.minimum << range.maximum << std::endl; \
15        return true; \
16    }
17
18#define RADIALSHOOTER_VEC3_FUNCTION( PROP ) \
19    static bool check##PROP( const osgParticle::RadialShooter& obj ) { return true; } \
20    static bool read##PROP( osgDB::InputStream& is, osgParticle::RadialShooter& obj ) { \
21        osg::Vec3d min, max; is >> min >> max; \
22        obj.set##PROP( min, max ); return true; \
23    } \
24    static bool write##PROP( osgDB::OutputStream& os, const osgParticle::RadialShooter& obj ) { \
25        const osgParticle::rangev3& range = obj.get##PROP(); \
26        os << osg::Vec3d(range.minimum) << osg::Vec3d(range.maximum) << std::endl; \
27        return true; \
28    }
29
30RADIALSHOOTER_FLOAT_FUNCTION( ThetaRange )
31RADIALSHOOTER_FLOAT_FUNCTION( PhiRange )
32RADIALSHOOTER_FLOAT_FUNCTION( InitialSpeedRange )
33RADIALSHOOTER_VEC3_FUNCTION( InitialRotationalSpeedRange )
34
35REGISTER_OBJECT_WRAPPER( osgParticleRadialShooter,
36                         new osgParticle::RadialShooter,
37                         osgParticle::RadialShooter,
38                         "osg::Object osgParticle::Shooter osgParticle::RadialShooter" )
39{
40    ADD_USER_SERIALIZER( ThetaRange );  // _theta_range
41    ADD_USER_SERIALIZER( PhiRange );  // _phi_range
42    ADD_USER_SERIALIZER( InitialSpeedRange );  // _speed_range
43    ADD_USER_SERIALIZER( InitialRotationalSpeedRange );  // _rot_speed_range
44}
Note: See TracBrowser for help on using the browser.