From Wang Rui, added osgParticle serializers

This commit is contained in:
Robert Osfield
2010-01-28 08:53:48 +00:00
parent 13531757c4
commit db275d7c26
38 changed files with 855 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
#include <osgParticle/AccelOperator>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleAccelOperator,
new osgParticle::AccelOperator,
osgParticle::AccelOperator,
"osg::Object osgParticle::Operator osgParticle::AccelOperator" )
{
ADD_VEC3_SERIALIZER( Acceleration, osg::Vec3() ); // _accel
}

View File

@@ -0,0 +1,12 @@
#include <osgParticle/AngularAccelOperator>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleAngularAccelOperator,
new osgParticle::AngularAccelOperator,
osgParticle::AngularAccelOperator,
"osg::Object osgParticle::Operator osgParticle::AngularAccelOperator" )
{
ADD_VEC3_SERIALIZER( AngularAcceleration, osg::Vec3() ); // _angul_araccel
}

View File

@@ -0,0 +1,30 @@
#include <osgParticle/BoxPlacer>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
#define BOXPLACER_FUNCTION( PROP ) \
static bool check##PROP( const osgParticle::BoxPlacer& obj ) { return true; } \
static bool read##PROP( osgDB::InputStream& is, osgParticle::BoxPlacer& obj ) { \
float min, max; is >> min >> max; \
obj.set##PROP( min, max ); return true; \
} \
static bool write##PROP( osgDB::OutputStream& os, const osgParticle::BoxPlacer& obj ) { \
const osgParticle::rangef& range = obj.get##PROP(); \
os << range.minimum << range.maximum << std::endl; \
return true; \
}
BOXPLACER_FUNCTION( XRange )
BOXPLACER_FUNCTION( YRange )
BOXPLACER_FUNCTION( ZRange )
REGISTER_OBJECT_WRAPPER( osgParticleBoxPlacer,
new osgParticle::BoxPlacer,
osgParticle::BoxPlacer,
"osg::Object osgParticle::Placer osgParticle::CenteredPlacer osgParticle::BoxPlacer" )
{
ADD_USER_SERIALIZER( XRange ); // _x_range
ADD_USER_SERIALIZER( YRange ); // _y_range
ADD_USER_SERIALIZER( ZRange ); // _z_range
}

View File

@@ -0,0 +1,7 @@
FILE(GLOB TARGET_SRC *.cpp)
FILE(GLOB TARGET_H *.h)
SET(TARGET_ADDED_LIBRARIES osgParticle )
#### end var setup ###
SETUP_PLUGIN(osgparticle)

View File

@@ -0,0 +1,12 @@
#include <osgParticle/CenteredPlacer>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleCenteredPlacer,
/*new osgParticle::CenteredPlacer*/NULL,
osgParticle::CenteredPlacer,
"osg::Object osgParticle::Placer osgParticle::CenteredPlacer" )
{
ADD_VEC3_SERIALIZER( Center, osg::Vec3() ); // center_
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/ConnectedParticleSystem>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleConnectedParticleSystem,
new osgParticle::ConnectedParticleSystem,
osgParticle::ConnectedParticleSystem,
"osg::Object osg::Drawable osgParticle::ParticleSystem osgParticle::ConnectedParticleSystem" )
{
}

View File

@@ -0,0 +1,13 @@
#include <osgParticle/ConstantRateCounter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleConstantRateCounter,
new osgParticle::ConstantRateCounter,
osgParticle::ConstantRateCounter,
"osg::Object osgParticle::Counter osgParticle::ConstantRateCounter" )
{
ADD_INT_SERIALIZER( MinimumNumberOfParticlesToCreate, 0 ); // _minimumNumberOfParticlesToCreate
ADD_DOUBLE_SERIALIZER( NumberOfParticlesPerSecondToCreate, 0.0 ); // _numberOfParticlesPerSecondToCreate
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/Counter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleCounter,
/*new osgParticle::Counter*/NULL,
osgParticle::Counter,
"osg::Object osgParticle::Counter" )
{
}

View File

@@ -0,0 +1,36 @@
#include <osgParticle/Emitter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
extern bool readParticle( osgDB::InputStream& is, osgParticle::Particle& p );
extern bool writeParticle( osgDB::OutputStream& os, const osgParticle::Particle& p );
static bool checkParticleTemplate( const osgParticle::Emitter& emitter )
{
return !emitter.getUseDefaultTemplate();
}
static bool readParticleTemplate( osgDB::InputStream& is, osgParticle::Emitter& emitter )
{
osgParticle::Particle p;
readParticle( is, p );
emitter.setParticleTemplate( p );
return true;
}
static bool writeParticleTemplate( osgDB::OutputStream& os, const osgParticle::Emitter& emitter )
{
const osgParticle::Particle& p = emitter.getParticleTemplate();
writeParticle( os, p );
return true;
}
REGISTER_OBJECT_WRAPPER( osgParticleEmitter,
/*new osgParticle::Emitter*/NULL,
osgParticle::Emitter,
"osg::Object osg::Node osgParticle::ParticleProcessor osgParticle::Emitter" )
{
ADD_BOOL_SERIALIZER( UseDefaultTemplate, true ); // _usedeftemp
ADD_USER_SERIALIZER( ParticleTemplate ); // _ptemp
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/ExplosionDebrisEffect>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleExplosionDebrisEffect,
new osgParticle::ExplosionDebrisEffect,
osgParticle::ExplosionDebrisEffect,
"osg::Object osg::Node osg::Group osgParticle::ParticleEffect osgParticle::ExplosionDebrisEffect" )
{
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/ExplosionEffect>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleExplosionEffect,
new osgParticle::ExplosionEffect,
osgParticle::ExplosionEffect,
"osg::Object osg::Node osg::Group osgParticle::ParticleEffect osgParticle::ExplosionEffect" )
{
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/FireEffect>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleFireEffect,
new osgParticle::FireEffect,
osgParticle::FireEffect,
"osg::Object osg::Node osg::Group osgParticle::ParticleEffect osgParticle::FireEffect" )
{
}

View File

@@ -0,0 +1,15 @@
#include <osgParticle/FluidFrictionOperator>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleFluidFrictionOperator,
new osgParticle::FluidFrictionOperator,
osgParticle::FluidFrictionOperator,
"osg::Object osgParticle::Operator osgParticle::FluidFrictionOperator" )
{
ADD_FLOAT_SERIALIZER( FluidDensity, 0.0f ); // _density
ADD_FLOAT_SERIALIZER( FluidDensity, 0.0f ); // _viscosity
ADD_VEC3_SERIALIZER( Wind, osg::Vec3() ); // _wind
ADD_FLOAT_SERIALIZER( OverrideRadius, 0.0f ); // _ovr_rad
}

View File

@@ -0,0 +1,15 @@
#include <osgParticle/FluidProgram>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleFluidProgram,
new osgParticle::FluidProgram,
osgParticle::FluidProgram,
"osg::Object osg::Node osgParticle::ParticleProcessor osgParticle::Program osgParticle::FluidProgram" )
{
ADD_VEC3_SERIALIZER( Acceleration, osg::Vec3() ); // _acceleration
ADD_FLOAT_SERIALIZER( FluidViscosity, 0.0f ); // _viscosity
ADD_FLOAT_SERIALIZER( FluidDensity, 0.0f ); // _density
ADD_VEC3_SERIALIZER( Wind, osg::Vec3() ); // _wind
}

View File

@@ -0,0 +1,12 @@
#include <osgParticle/ForceOperator>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleForceOperator,
new osgParticle::ForceOperator,
osgParticle::ForceOperator,
"osg::Object osgParticle::Operator osgParticle::ForceOperator" )
{
ADD_VEC3_SERIALIZER( Force, osg::Vec3() ); // _force
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/Interpolator>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleInterpolator,
/*new osgParticle::Interpolator*/NULL,
osgParticle::Interpolator,
"osg::Object osgParticle::Interpolator" )
{
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/LinearInterpolator>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleLinearInterpolator,
new osgParticle::LinearInterpolator,
osgParticle::LinearInterpolator,
"osg::Object osgParticle::Interpolator osgParticle::LinearInterpolator" )
{
}

View File

@@ -0,0 +1,14 @@
#include <osgParticle/ModularEmitter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleModularEmitter,
new osgParticle::ModularEmitter,
osgParticle::ModularEmitter,
"osg::Object osg::Node osgParticle::ParticleProcessor osgParticle::Emitter osgParticle::ModularEmitter" )
{
ADD_OBJECT_SERIALIZER( Counter, osgParticle::Counter, NULL ); // _counter
ADD_OBJECT_SERIALIZER( Placer, osgParticle::Placer, NULL ); // _placer
ADD_OBJECT_SERIALIZER( Shooter, osgParticle::Shooter, NULL ); // _shooter
}

View File

@@ -0,0 +1,41 @@
#include <osgParticle/ModularProgram>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
static bool checkOperators( const osgParticle::ModularProgram& prog )
{
return prog.numOperators()>0;
}
static bool readOperators( osgDB::InputStream& is, osgParticle::ModularProgram& prog )
{
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
osgParticle::Operator* op = dynamic_cast<osgParticle::Operator*>( is.readObject() );
if ( op ) prog.addOperator( op );
}
is >> osgDB::END_BRACKET;
return true;
}
static bool writeOperators( osgDB::OutputStream& os, const osgParticle::ModularProgram& prog )
{
unsigned int size = prog.numOperators();
os << size << osgDB::BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
os << prog.getOperator(i);
}
os << osgDB::END_BRACKET << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( osgParticleModularProgram,
new osgParticle::ModularProgram,
osgParticle::ModularProgram,
"osg::Object osg::Node osgParticle::ParticleProcessor osgParticle::Program osgParticle::ModularProgram" )
{
ADD_USER_SERIALIZER( Operators ); // _operators
}

View File

@@ -0,0 +1,42 @@
#include <osgParticle/MultiSegmentPlacer>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
static bool checkVertices( const osgParticle::MultiSegmentPlacer& placer )
{
return placer.numVertices()>0;
}
static bool readVertices( osgDB::InputStream& is, osgParticle::MultiSegmentPlacer& placer )
{
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
osg::Vec3d vec; is >> vec;
placer.addVertex( vec );
}
is >> osgDB::END_BRACKET;
return true;
}
static bool writeVertices( osgDB::OutputStream& os, const osgParticle::MultiSegmentPlacer& placer )
{
unsigned int size = placer.numVertices();
os << size << osgDB::BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
os << osg::Vec3d(placer.getVertex(i));
}
os << std::endl;
os << osgDB::END_BRACKET << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( osgParticleMultiSegmentPlacer,
new osgParticle::MultiSegmentPlacer,
osgParticle::MultiSegmentPlacer,
"osg::Object osgParticle::Placer osgParticle::MultiSegmentPlacer" )
{
ADD_USER_SERIALIZER( Vertices ); // _vx
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/Operator>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleOperator,
/*new osgParticle::Operator*/NULL,
osgParticle::Operator,
"osg::Object osgParticle::Operator" )
{
}

View File

@@ -0,0 +1,107 @@
#include <osgParticle/Particle>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
BEGIN_USER_TABLE( Shape, osgParticle::Particle );
ADD_USER_VALUE( POINT );
ADD_USER_VALUE( QUAD );
ADD_USER_VALUE( QUAD_TRIANGLESTRIP );
ADD_USER_VALUE( HEXAGON );
ADD_USER_VALUE( LINE );
END_USER_TABLE()
USER_READ_FUNC( Shape, readShapeValue )
USER_WRITE_FUNC( Shape, writeShapeValue )
bool readParticle( osgDB::InputStream& is, osgParticle::Particle& p )
{
is >> osgDB::BEGIN_BRACKET;
is >> osgDB::PROPERTY("Shape");
p.setShape( static_cast<osgParticle::Particle::Shape>(readShapeValue(is)) );
double lifeTime; is >> osgDB::PROPERTY("LifeTime") >> lifeTime;
p.setLifeTime( lifeTime );
float min, max; osg::Vec4d minV, maxV;
is >> osgDB::PROPERTY("SizeRange") >> min >> max; p.setSizeRange( osgParticle::rangef(min, max) );
is >> osgDB::PROPERTY("AlphaRange") >> min >> max; p.setAlphaRange( osgParticle::rangef(min, max) );
is >> osgDB::PROPERTY("ColorRange") >> minV >> maxV; p.setColorRange( osgParticle::rangev4(minV, maxV) );
bool hasInterpolator = false;
is >> osgDB::PROPERTY("SizeInterpolator") >> hasInterpolator;
if ( hasInterpolator )
{
is >> osgDB::BEGIN_BRACKET;
p.setSizeInterpolator( static_cast<osgParticle::Interpolator*>(is.readObject()) );
is >> osgDB::END_BRACKET;
}
is >> osgDB::PROPERTY("AlphaInterpolator") >> hasInterpolator;
if ( hasInterpolator )
{
is >> osgDB::BEGIN_BRACKET;
p.setAlphaInterpolator( static_cast<osgParticle::Interpolator*>(is.readObject()) );
is >> osgDB::END_BRACKET;
}
is >> osgDB::PROPERTY("ColorInterpolator") >> hasInterpolator;
if ( hasInterpolator )
{
is >> osgDB::BEGIN_BRACKET;
p.setColorInterpolator( static_cast<osgParticle::Interpolator*>(is.readObject()) );
is >> osgDB::END_BRACKET;
}
float radius; is >> osgDB::PROPERTY("Radius") >> radius;
float mass; is >> osgDB::PROPERTY("Mass") >> mass;
osg::Vec3d pos; is >> osgDB::PROPERTY("Position") >> pos;
osg::Vec3d vel; is >> osgDB::PROPERTY("Velocity") >> vel;
osg::Vec3d angle; is >> osgDB::PROPERTY("Angle") >> angle;
osg::Vec3d angleV; is >> osgDB::PROPERTY("AngularVelocity") >> angleV;
int s, t, num; is >> osgDB::PROPERTY("TextureTile") >> s >> t >> num;
p.setRadius( radius );
p.setMass( mass );
p.setPosition( pos );
p.setVelocity( vel );
p.setAngle( angle );
p.setAngularVelocity( angleV );
p.setTextureTile( s, t, num );
is >> osgDB::END_BRACKET;
return true;
}
bool writeParticle( osgDB::OutputStream& os, const osgParticle::Particle& p )
{
os << osgDB::BEGIN_BRACKET << std::endl;
os << osgDB::PROPERTY("Shape"); writeShapeValue( os, (int)p.getShape() ); os << std::endl;
os << osgDB::PROPERTY("LifeTime") << p.getLifeTime() << std::endl;
os << osgDB::PROPERTY("SizeRange") << p.getSizeRange().minimum << p.getSizeRange().maximum << std::endl;
os << osgDB::PROPERTY("AlphaRange") << p.getAlphaRange().minimum << p.getAlphaRange().maximum << std::endl;
os << osgDB::PROPERTY("ColorRange") << osg::Vec4d(p.getColorRange().minimum)
<< osg::Vec4d(p.getColorRange().maximum) << std::endl;
os << osgDB::PROPERTY("SizeInterpolator") << (p.getSizeInterpolator()!=NULL);
if ( p.getSizeInterpolator()!=NULL )
os << osgDB::BEGIN_BRACKET << std::endl << p.getSizeInterpolator() << osgDB::END_BRACKET << std::endl;
os << osgDB::PROPERTY("AlphaInterpolator") << (p.getAlphaInterpolator()!=NULL);
if ( p.getAlphaInterpolator()!=NULL )
os << osgDB::BEGIN_BRACKET << std::endl << p.getAlphaInterpolator() << osgDB::END_BRACKET << std::endl;
os << osgDB::PROPERTY("ColorInterpolator") << (p.getColorInterpolator()!=NULL);
if ( p.getColorInterpolator()!=NULL )
os << osgDB::BEGIN_BRACKET << std::endl << p.getColorInterpolator() << osgDB::END_BRACKET << std::endl;
os << osgDB::PROPERTY("Radius") << p.getRadius() << std::endl;
os << osgDB::PROPERTY("Mass") << p.getMass() << std::endl;
os << osgDB::PROPERTY("Position") << osg::Vec3d(p.getPosition()) << std::endl;
os << osgDB::PROPERTY("Velocity") << osg::Vec3d(p.getVelocity()) << std::endl;
os << osgDB::PROPERTY("Angle") << osg::Vec3d(p.getAngle()) << std::endl;
os << osgDB::PROPERTY("AngularVelocity") << osg::Vec3d(p.getAngularVelocity()) << std::endl;
os << osgDB::PROPERTY("TextureTile") << p.getTileS() << p.getTileT() << p.getNumTiles() << std::endl;
os << osgDB::END_BRACKET << std::endl;
return true;
}

View File

@@ -0,0 +1,42 @@
#include <osgParticle/ParticleEffect>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
// _particleSystem
static bool checkParticleSystem( const osgParticle::ParticleEffect& effect )
{
return (!effect.getUseLocalParticleSystem()) && (effect.getParticleSystem()!=NULL);
}
static bool readParticleSystem( osgDB::InputStream& is, osgParticle::ParticleEffect& effect )
{
is >> osgDB::BEGIN_BRACKET;
effect.setUseLocalParticleSystem( false );
effect.setParticleSystem( static_cast<osgParticle::ParticleSystem*>(is.readObject()) );
is >> osgDB::END_BRACKET;
return true;
}
static bool writeParticleSystem( osgDB::OutputStream& os, const osgParticle::ParticleEffect& effect )
{
os << osgDB::BEGIN_BRACKET << std::endl;
os << effect.getParticleSystem();
os << osgDB::END_BRACKET << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( osgParticleParticleEffect,
/*new osgParticle::ParticleEffect*/NULL,
osgParticle::ParticleEffect,
"osg::Object osg::Node osg::Group osgParticle::ParticleEffect" )
{
ADD_USER_SERIALIZER( ParticleSystem ); // _particleSystem
ADD_STRING_SERIALIZER( TextureFileName, "" ); // _textureFileName
ADD_VEC3_SERIALIZER( Position, osg::Vec3() ); // _position
ADD_FLOAT_SERIALIZER( Scale, 0.0f ); // _scale
ADD_FLOAT_SERIALIZER( Intensity, 0.0f ); // _intensity
ADD_DOUBLE_SERIALIZER( StartTime, 0.0 ); // _startTime
ADD_DOUBLE_SERIALIZER( EmitterDuration, 0.0 ); // _emitterDuration
ADD_VEC3_SERIALIZER( Wind, osg::Vec3() ); // _wind
}

View File

@@ -0,0 +1,23 @@
#include <osgParticle/ParticleProcessor>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleParticleProcessor,
/*new osgParticle::ParticleProcessor*/NULL,
osgParticle::ParticleProcessor,
"osg::Object osg::Node osgParticle::ParticleProcessor" )
{
BEGIN_ENUM_SERIALIZER( ReferenceFrame, RELATIVE_RF );
ADD_ENUM_VALUE( RELATIVE_RF );
ADD_ENUM_VALUE( ABSOLUTE_RF );
END_ENUM_SERIALIZER(); // _rf
ADD_BOOL_SERIALIZER( Enabled, true ); // _enabled
ADD_OBJECT_SERIALIZER( ParticleSystem, osgParticle::ParticleSystem, NULL ); // _ps
ADD_BOOL_SERIALIZER( Endless, true ); // _endless
ADD_DOUBLE_SERIALIZER( LifeTime, 0.0 ); // _lifeTime
ADD_DOUBLE_SERIALIZER( StartTime, 0.0 ); // _startTime
ADD_DOUBLE_SERIALIZER( CurrentTime, 0.0 ); // _currentTime
ADD_DOUBLE_SERIALIZER( ResetTime, 0.0 ); // _resetTime
}

View File

@@ -0,0 +1,82 @@
#include <osgParticle/ParticleSystem>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
extern bool readParticle( osgDB::InputStream& is, osgParticle::Particle& p );
extern bool writeParticle( osgDB::OutputStream& os, const osgParticle::Particle& p );
// _def_bbox
static bool checkDefaultBoundingBox( const osgParticle::ParticleSystem& ps )
{
return ps.getDefaultBoundingBox().valid();
}
static bool readDefaultBoundingBox( osgDB::InputStream& is, osgParticle::ParticleSystem& ps )
{
osg::Vec3d min, max;
is >> osgDB::BEGIN_BRACKET;
is >> osgDB::PROPERTY("Minimum") >> min;
is >> osgDB::PROPERTY("Maximum") >> max;
is >> osgDB::END_BRACKET;
ps.setDefaultBoundingBox( osg::BoundingBox(min, max) );
return true;
}
static bool writeDefaultBoundingBox( osgDB::OutputStream& os, const osgParticle::ParticleSystem& ps )
{
const osg::BoundingBox& bb = ps.getDefaultBoundingBox();
os << osgDB::BEGIN_BRACKET << std::endl;
os << osgDB::PROPERTY("Minimum") << osg::Vec3d(bb._min) << std::endl;
os << osgDB::PROPERTY("Maximum") << osg::Vec3d(bb._max) << std::endl;
os << osgDB::END_BRACKET;
os << std::endl;
return true;
}
// _defaultParticleTemplate
static bool checkDefaultParticleTemplate( const osgParticle::ParticleSystem& ps )
{
return true;
}
static bool readDefaultParticleTemplate( osgDB::InputStream& is, osgParticle::ParticleSystem& ps )
{
osgParticle::Particle p;
readParticle( is, p );
ps.setDefaultParticleTemplate( p );
return true;
}
static bool writeDefaultParticleTemplate( osgDB::OutputStream& os, const osgParticle::ParticleSystem& ps )
{
const osgParticle::Particle& p = ps.getDefaultParticleTemplate();
writeParticle( os, p );
return true;
}
REGISTER_OBJECT_WRAPPER( osgParticleParticleSystem,
new osgParticle::ParticleSystem,
osgParticle::ParticleSystem,
"osg::Object osg::Drawable osgParticle::ParticleSystem" )
{
ADD_USER_SERIALIZER( DefaultBoundingBox ); // _def_bbox
BEGIN_ENUM_SERIALIZER2( ParticleAlignment, osgParticle::ParticleSystem::Alignment, BILLBOARD );
ADD_ENUM_VALUE( BILLBOARD );
ADD_ENUM_VALUE( FIXED );
END_ENUM_SERIALIZER(); // _alignment
ADD_VEC3_SERIALIZER( AlignVectorX, osg::Vec3() ); // _align_X_axis
ADD_VEC3_SERIALIZER( AlignVectorY, osg::Vec3() ); // _align_Y_axis
BEGIN_ENUM_SERIALIZER( ParticleScaleReferenceFrame, WORLD_COORDINATES );
ADD_ENUM_VALUE( LOCAL_COORDINATES );
ADD_ENUM_VALUE( WORLD_COORDINATES );
END_ENUM_SERIALIZER(); // _particleScaleReferenceFrame
ADD_BOOL_SERIALIZER( DoublePassRendering, false ); // _doublepass
ADD_BOOL_SERIALIZER( Frozen, false ); // _frozen
ADD_USER_SERIALIZER( DefaultParticleTemplate ); // _def_ptemp
ADD_BOOL_SERIALIZER( FreezeOnCull, false ); // _freeze_on_cull
}

View File

@@ -0,0 +1,41 @@
#include <osgParticle/ParticleSystemUpdater>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
static bool checkParticleSystems( const osgParticle::ParticleSystemUpdater& updater )
{
return updater.getNumParticleSystems()>0;
}
static bool readParticleSystems( osgDB::InputStream& is, osgParticle::ParticleSystemUpdater& updater )
{
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
osgParticle::ParticleSystem* ps = dynamic_cast<osgParticle::ParticleSystem*>( is.readObject() );
if ( ps ) updater.addParticleSystem( ps );
}
is >> osgDB::END_BRACKET;
return true;
}
static bool writeParticleSystems( osgDB::OutputStream& os, const osgParticle::ParticleSystemUpdater& updater )
{
unsigned int size = updater.getNumParticleSystems();
os << size << osgDB::BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
os << updater.getParticleSystem(i);
}
os << osgDB::END_BRACKET << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( osgParticleParticleSystemUpdater,
new osgParticle::ParticleSystemUpdater,
osgParticle::ParticleSystemUpdater,
"osg::Object osg::Node osgParticle::ParticleSystemUpdater" )
{
ADD_USER_SERIALIZER( ParticleSystems ); // _psv
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/Placer>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticlePlacer,
/*new osgParticle::Placer*/NULL,
osgParticle::Placer,
"osg::Object osgParticle::Placer" )
{
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/PointPlacer>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticlePointPlacer,
new osgParticle::PointPlacer,
osgParticle::PointPlacer,
"osg::Object osgParticle::Placer osgParticle::CenteredPlacer osgParticle::PointPlacer" )
{
}

View File

@@ -0,0 +1,21 @@
#include <osgParticle/PrecipitationEffect>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticlePrecipitationEffect,
new osgParticle::PrecipitationEffect,
osgParticle::PrecipitationEffect,
"osg::Object osg::Node osgParticle::PrecipitationEffect" )
{
ADD_VEC3_SERIALIZER( Wind, osg::Vec3() ); // _wind
ADD_FLOAT_SERIALIZER( ParticleSpeed, 0.0f ); // _particleSpeed
ADD_FLOAT_SERIALIZER( ParticleSize, 0.0f ); // _particleSize
ADD_VEC4_SERIALIZER( ParticleColor, osg::Vec4() ); // _particleColor
ADD_FLOAT_SERIALIZER( MaximumParticleDensity, 0.0f ); // _maximumParticleDensity
ADD_VEC3_SERIALIZER( CellSize, osg::Vec3() ); // _cellSize
ADD_FLOAT_SERIALIZER( NearTransition, 0.0f ); // _nearTransition
ADD_FLOAT_SERIALIZER( FarTransition, 0.0f ); // _farTransition
ADD_BOOL_SERIALIZER( UseFarLineSegments, false ); // _useFarLineSegments
ADD_OBJECT_SERIALIZER( Fog, osg::Fog, NULL ); // _fog
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/Program>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleProgram,
/*new osgParticle::Program*/NULL,
osgParticle::Program,
"osg::Object osg::Node osgParticle::ParticleProcessor osgParticle::Program" )
{
}

View File

@@ -0,0 +1,44 @@
#include <osgParticle/RadialShooter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
#define RADIALSHOOTER_FLOAT_FUNCTION( PROP ) \
static bool check##PROP( const osgParticle::RadialShooter& obj ) { return true; } \
static bool read##PROP( osgDB::InputStream& is, osgParticle::RadialShooter& obj ) { \
float min, max; is >> min >> max; \
obj.set##PROP( min, max ); return true; \
} \
static bool write##PROP( osgDB::OutputStream& os, const osgParticle::RadialShooter& obj ) { \
const osgParticle::rangef& range = obj.get##PROP(); \
os << range.minimum << range.maximum << std::endl; \
return true; \
}
#define RADIALSHOOTER_VEC3_FUNCTION( PROP ) \
static bool check##PROP( const osgParticle::RadialShooter& obj ) { return true; } \
static bool read##PROP( osgDB::InputStream& is, osgParticle::RadialShooter& obj ) { \
osg::Vec3d min, max; is >> min >> max; \
obj.set##PROP( min, max ); return true; \
} \
static bool write##PROP( osgDB::OutputStream& os, const osgParticle::RadialShooter& obj ) { \
const osgParticle::rangev3& range = obj.get##PROP(); \
os << osg::Vec3d(range.minimum) << osg::Vec3d(range.maximum) << std::endl; \
return true; \
}
RADIALSHOOTER_FLOAT_FUNCTION( ThetaRange )
RADIALSHOOTER_FLOAT_FUNCTION( PhiRange )
RADIALSHOOTER_FLOAT_FUNCTION( InitialSpeedRange )
RADIALSHOOTER_VEC3_FUNCTION( InitialRotationalSpeedRange )
REGISTER_OBJECT_WRAPPER( osgParticleRadialShooter,
new osgParticle::RadialShooter,
osgParticle::RadialShooter,
"osg::Object osgParticle::Shooter osgParticle::RadialShooter" )
{
ADD_USER_SERIALIZER( ThetaRange ); // _theta_range
ADD_USER_SERIALIZER( PhiRange ); // _phi_range
ADD_USER_SERIALIZER( InitialSpeedRange ); // _speed_range
ADD_USER_SERIALIZER( InitialRotationalSpeedRange ); // _rot_speed_range
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/RandomRateCounter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleRandomRateCounter,
new osgParticle::RandomRateCounter,
osgParticle::RandomRateCounter,
"osg::Object osgParticle::Counter osgParticle::VariableRateCounter osgParticle::RandomRateCounter" )
{
}

View File

@@ -0,0 +1,28 @@
#include <osgParticle/SectorPlacer>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
#define SECTORPLACER_FUNCTION( PROP ) \
static bool check##PROP( const osgParticle::SectorPlacer& obj ) { return true; } \
static bool read##PROP( osgDB::InputStream& is, osgParticle::SectorPlacer& obj ) { \
float min, max; is >> min >> max; \
obj.set##PROP( min, max ); return true; \
} \
static bool write##PROP( osgDB::OutputStream& os, const osgParticle::SectorPlacer& obj ) { \
const osgParticle::rangef& range = obj.get##PROP(); \
os << range.minimum << range.maximum << std::endl; \
return true; \
}
SECTORPLACER_FUNCTION( RadiusRange )
SECTORPLACER_FUNCTION( PhiRange )
REGISTER_OBJECT_WRAPPER( osgParticleSectorPlacer,
new osgParticle::SectorPlacer,
osgParticle::SectorPlacer,
"osg::Object osgParticle::Placer osgParticle::CenteredPlacer osgParticle::SectorPlacer" )
{
ADD_USER_SERIALIZER( RadiusRange ); // _rad_range
ADD_USER_SERIALIZER( PhiRange ); // _phi_range
}

View File

@@ -0,0 +1,13 @@
#include <osgParticle/SegmentPlacer>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleSegmentPlacer,
new osgParticle::SegmentPlacer,
osgParticle::SegmentPlacer,
"osg::Object osgParticle::Placer osgParticle::SegmentPlacer" )
{
ADD_VEC3_SERIALIZER( VertexA, osg::Vec3() ); // _vertexA
ADD_VEC3_SERIALIZER( VertexB, osg::Vec3() ); // _vertexB
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/Shooter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleShooter,
/*new osgParticle::Shooter*/NULL,
osgParticle::Shooter,
"osg::Object osgParticle::Shooter" )
{
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/SmokeEffect>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleSmokeEffect,
new osgParticle::SmokeEffect,
osgParticle::SmokeEffect,
"osg::Object osg::Node osg::Group osgParticle::ParticleEffect osgParticle::SmokeEffect" )
{
}

View File

@@ -0,0 +1,11 @@
#include <osgParticle/SmokeTrailEffect>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgParticleSmokeTrailEffect,
new osgParticle::SmokeTrailEffect,
osgParticle::SmokeTrailEffect,
"osg::Object osg::Node osg::Group osgParticle::ParticleEffect osgParticle::SmokeTrailEffect" )
{
}

View File

@@ -0,0 +1,28 @@
#include <osgParticle/VariableRateCounter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
static bool checkRateRange( const osgParticle::VariableRateCounter& obj )
{ return true; }
static bool readRateRange( osgDB::InputStream& is, osgParticle::VariableRateCounter& obj )
{
float min, max; is >> min >> max;
obj.setRateRange( min, max ); return true;
}
static bool writeRateRange( osgDB::OutputStream& os, const osgParticle::VariableRateCounter& obj )
{
const osgParticle::rangef& range = obj.getRateRange();
os << range.minimum << range.maximum << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( osgParticleVariableRateCounter,
/*new osgParticle::VariableRateCounter*/NULL,
osgParticle::VariableRateCounter,
"osg::Object osgParticle::Counter osgParticle::VariableRateCounter" )
{
ADD_USER_SERIALIZER( RateRange ); // _rate_range
}