root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osgParticle/ParticleSystem.cpp @ 13041

Revision 13041, 3.3 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1#include <osgParticle/ParticleSystem>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6extern bool readParticle( osgDB::InputStream& is, osgParticle::Particle& p );
7extern bool writeParticle( osgDB::OutputStream& os, const osgParticle::Particle& p );
8
9// _def_bbox
10static bool checkDefaultBoundingBox( const osgParticle::ParticleSystem& ps )
11{
12    return ps.getDefaultBoundingBox().valid();
13}
14
15static bool readDefaultBoundingBox( osgDB::InputStream& is, osgParticle::ParticleSystem& ps )
16{
17    osg::Vec3d min, max;
18    is >> osgDB::BEGIN_BRACKET;
19    is >> osgDB::PROPERTY("Minimum") >> min;
20    is >> osgDB::PROPERTY("Maximum") >> max;
21    is >> osgDB::END_BRACKET;
22    ps.setDefaultBoundingBox( osg::BoundingBox(min, max) );
23    return true;
24}
25
26static bool writeDefaultBoundingBox( osgDB::OutputStream& os, const osgParticle::ParticleSystem& ps )
27{
28    const osg::BoundingBox& bb = ps.getDefaultBoundingBox();
29    os << osgDB::BEGIN_BRACKET << std::endl;
30    os << osgDB::PROPERTY("Minimum") << osg::Vec3d(bb._min) << std::endl;
31    os << osgDB::PROPERTY("Maximum") << osg::Vec3d(bb._max) << std::endl;
32    os << osgDB::END_BRACKET;
33    os << std::endl;
34    return true;
35}
36
37// _defaultParticleTemplate
38static bool checkDefaultParticleTemplate( const osgParticle::ParticleSystem& ps )
39{
40    return true;
41}
42
43static bool readDefaultParticleTemplate( osgDB::InputStream& is, osgParticle::ParticleSystem& ps )
44{
45    osgParticle::Particle p;
46    readParticle( is, p );
47    ps.setDefaultParticleTemplate( p );
48    return true;
49}
50
51static bool writeDefaultParticleTemplate( osgDB::OutputStream& os, const osgParticle::ParticleSystem& ps )
52{
53    const osgParticle::Particle& p = ps.getDefaultParticleTemplate();
54    writeParticle( os, p );
55    return true;
56}
57
58REGISTER_OBJECT_WRAPPER( osgParticleParticleSystem,
59                         new osgParticle::ParticleSystem,
60                         osgParticle::ParticleSystem,
61                         "osg::Object osg::Drawable osgParticle::ParticleSystem" )
62{
63    ADD_USER_SERIALIZER( DefaultBoundingBox );  // _def_bbox
64
65    BEGIN_ENUM_SERIALIZER2( ParticleAlignment, osgParticle::ParticleSystem::Alignment, BILLBOARD );
66        ADD_ENUM_VALUE( BILLBOARD );
67        ADD_ENUM_VALUE( FIXED );
68    END_ENUM_SERIALIZER();  // _alignment
69
70    ADD_VEC3_SERIALIZER( AlignVectorX, osg::Vec3() );  // _align_X_axis
71    ADD_VEC3_SERIALIZER( AlignVectorY, osg::Vec3() );  // _align_Y_axis
72
73    BEGIN_ENUM_SERIALIZER( ParticleScaleReferenceFrame, WORLD_COORDINATES );
74        ADD_ENUM_VALUE( LOCAL_COORDINATES );
75        ADD_ENUM_VALUE( WORLD_COORDINATES );
76    END_ENUM_SERIALIZER();  // _particleScaleReferenceFrame
77
78    ADD_BOOL_SERIALIZER( UseVertexArray, false );  // _useVertexArray
79    ADD_BOOL_SERIALIZER( UseShaders, false );  // _useShaders
80    ADD_BOOL_SERIALIZER( DoublePassRendering, false );  // _doublepass
81    ADD_BOOL_SERIALIZER( Frozen, false );  // _frozen
82    ADD_USER_SERIALIZER( DefaultParticleTemplate );  // _def_ptemp
83    ADD_BOOL_SERIALIZER( FreezeOnCull, false );  // _freeze_on_cull
84
85    BEGIN_ENUM_SERIALIZER( SortMode, NO_SORT );
86        ADD_ENUM_VALUE( NO_SORT );
87        ADD_ENUM_VALUE( SORT_FRONT_TO_BACK );
88        ADD_ENUM_VALUE( SORT_BACK_TO_FRONT );
89    END_ENUM_SERIALIZER();  // _sortMode
90
91    ADD_DOUBLE_SERIALIZER( VisibilityDistance, -1.0 );  // _visibilityDistance
92}
Note: See TracBrowser for help on using the browser.