Moved the IO support for the osgText and osgParticle libraries into seperate

plugin libraries.
This commit is contained in:
Robert Osfield
2002-08-20 11:27:08 +00:00
parent 05573d553d
commit df9a899d9e
34 changed files with 498 additions and 1637 deletions

View File

@@ -1,48 +0,0 @@
#include <osgParticle/AccelOperator>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <osg/Vec3>
#include <iostream>
bool AccelOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool AccelOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy AccelOperator_Proxy
(
osgNew osgParticle::AccelOperator,
"AccelOperator",
"Object Operator AccelOperator",
AccelOperator_readLocalData,
AccelOperator_writeLocalData
);
bool AccelOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::AccelOperator &aop = static_cast<osgParticle::AccelOperator &>(obj);
bool itAdvanced = false;
osg::Vec3 a;
if (fr[0].matchWord("acceleration")) {
if (fr[1].getFloat(a.x()) && fr[2].getFloat(a.y()) && fr[3].getFloat(a.z())) {
aop.setAcceleration(a);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
bool AccelOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::AccelOperator &aop = static_cast<const osgParticle::AccelOperator &>(obj);
osg::Vec3 a = aop.getAcceleration();
fw.indent() << "acceleration " << a.x() << " " << a.y() << " " << a.z() << std::endl;
return true;
}

View File

@@ -1,49 +0,0 @@
#include <osgParticle/CenteredPlacer>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <osg/Vec3>
#include <iostream>
bool CenteredPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool CenteredPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy CenteredPlacer_Proxy
(
0,
"CenteredPlacer",
"Object Placer CenteredPlacer",
CenteredPlacer_readLocalData,
CenteredPlacer_writeLocalData
);
bool CenteredPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::CenteredPlacer &myobj = static_cast<osgParticle::CenteredPlacer &>(obj);
bool itAdvanced = false;
osg::Vec3 v;
if (fr[0].matchWord("center")) {
if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) {
myobj.setCenter(v);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
bool CenteredPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::CenteredPlacer &myobj = static_cast<const osgParticle::CenteredPlacer &>(obj);
osg::Vec3 v = myobj.getCenter();
fw.indent() << "center " << v.x() << " " << v.y() << " " << v.z() << std::endl;
return true;
}

View File

@@ -1,70 +0,0 @@
#include <osgParticle/Emitter>
#include <iostream>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
extern bool read_particle(osgDB::Input &fr, osgParticle::Particle &P);
extern void write_particle(const osgParticle::Particle &P, osgDB::Output &fw);
bool Emitter_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool Emitter_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy Emitter_Proxy
(
0,
"Emitter",
"Object Node ParticleProcessor Emitter",
Emitter_readLocalData,
Emitter_writeLocalData
);
bool Emitter_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::Emitter &myobj = static_cast<osgParticle::Emitter &>(obj);
bool itAdvanced = false;
if (fr[0].matchWord("useDefaultTemplate")) {
if (fr[1].matchWord("TRUE")) {
myobj.setUseDefaultTemplate(true);
fr += 2;
itAdvanced = true;
}
if (fr[1].matchWord("FALSE")) {
myobj.setUseDefaultTemplate(false);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("particleTemplate")) {
++fr;
itAdvanced = true;
osgParticle::Particle P;
if (read_particle(fr, P)) {
myobj.setParticleTemplate(P);
}
}
return itAdvanced;
}
bool Emitter_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::Emitter &myobj = static_cast<const osgParticle::Emitter &>(obj);
fw.indent() << "useDefaultTemplate ";
if (!myobj.getUseDefaultTemplate()) {
fw << "FALSE" << std::endl;
fw.indent() << "particleTemplate ";
write_particle(myobj.getParticleTemplate(), fw);
fw << std::endl;
} else {
fw << "TRUE" << std::endl;
}
return true;
}

View File

@@ -1,63 +0,0 @@
#include <osgParticle/FluidFrictionOperator>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <iostream>
bool FluidFrictionOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool FluidFrictionOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy FluidFrictionOperator_Proxy
(
osgNew osgParticle::FluidFrictionOperator,
"FluidFrictionOperator",
"Object Operator FluidFrictionOperator",
FluidFrictionOperator_readLocalData,
FluidFrictionOperator_writeLocalData
);
bool FluidFrictionOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::FluidFrictionOperator &aop = static_cast<osgParticle::FluidFrictionOperator &>(obj);
bool itAdvanced = false;
float f;
if (fr[0].matchWord("fluidDensity")) {
if (fr[1].getFloat(f)) {
aop.setFluidDensity(f);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("fluidViscosity")) {
if (fr[1].getFloat(f)) {
aop.setFluidViscosity(f);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("overrideRadius")) {
if (fr[1].getFloat(f)) {
aop.setOverrideRadius(f);
fr += 2;
itAdvanced = true;
}
}
return itAdvanced;
}
bool FluidFrictionOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::FluidFrictionOperator &aop = static_cast<const osgParticle::FluidFrictionOperator &>(obj);
fw.indent() << "fluidDensity " << aop.getFluidDensity() << std::endl;
fw.indent() << "fluidViscosity " << aop.getFluidViscosity() << std::endl;
fw.indent() << "overrideRadius " << aop.getOverrideRadius();
return true;
}

View File

@@ -1,48 +0,0 @@
#include <osgParticle/ForceOperator>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <osg/Vec3>
#include <iostream>
bool ForceOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool ForceOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy ForceOperator_Proxy
(
osgNew osgParticle::ForceOperator,
"ForceOperator",
"Object Operator ForceOperator",
ForceOperator_readLocalData,
ForceOperator_writeLocalData
);
bool ForceOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::ForceOperator &fop = static_cast<osgParticle::ForceOperator &>(obj);
bool itAdvanced = false;
osg::Vec3 f;
if (fr[0].matchWord("force")) {
if (fr[1].getFloat(f.x()) && fr[2].getFloat(f.y()) && fr[3].getFloat(f.z())) {
fop.setForce(f);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
bool ForceOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::ForceOperator &fop = static_cast<const osgParticle::ForceOperator &>(obj);
osg::Vec3 f = fop.getForce();
fw.indent() << "force " << f.x() << " " << f.y() << " " << f.z() << std::endl;
return true;
}

View File

@@ -1,28 +0,0 @@
#include <osgParticle/LinearInterpolator>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool LinearInterpolator_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool LinearInterpolator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy LinearInterpolator_Proxy
(
osgNew osgParticle::LinearInterpolator,
"LinearInterpolator",
"Object Interpolator LinearInterpolator",
LinearInterpolator_readLocalData,
LinearInterpolator_writeLocalData
);
bool LinearInterpolator_readLocalData(osg::Object &, osgDB::Input &)
{
return false;
}
bool LinearInterpolator_writeLocalData(const osg::Object &, osgDB::Output &)
{
return false;
}

View File

@@ -1,62 +0,0 @@
#include <osgParticle/ModularEmitter>
#include <osgParticle/Counter>
#include <osgParticle/Placer>
#include <osgParticle/Shooter>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool ModularEmitter_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool ModularEmitter_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy ModularEmitter_Proxy
(
osgNew osgParticle::ModularEmitter,
"ModularEmitter",
"Object Node ParticleProcessor Emitter ModularEmitter",
ModularEmitter_readLocalData,
ModularEmitter_writeLocalData
);
bool ModularEmitter_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::ModularEmitter &myobj = static_cast<osgParticle::ModularEmitter &>(obj);
bool itAdvanced = false;
// we cannot use readObjectOfType() because the Coutner, Placer and Shooter classes are
// abstract and we can't create instances to use as prototypes.
// So, we call readObject() and then dynamic cast to the desired class.
osgParticle::Counter *counter = dynamic_cast<osgParticle::Counter *>(fr.readObject());
if (counter) {
myobj.setCounter(counter);
itAdvanced = true;
}
osgParticle::Placer *placer = dynamic_cast<osgParticle::Placer *>(fr.readObject());
if (placer) {
myobj.setPlacer(placer);
itAdvanced = true;
}
osgParticle::Shooter *shooter = dynamic_cast<osgParticle::Shooter *>(fr.readObject());
if (shooter) {
myobj.setShooter(shooter);
itAdvanced = true;
}
return itAdvanced;
}
bool ModularEmitter_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::ModularEmitter &myobj = static_cast<const osgParticle::ModularEmitter &>(obj);
if (myobj.getCounter()) fw.writeObject(*myobj.getCounter());
if (myobj.getPlacer()) fw.writeObject(*myobj.getPlacer());
if (myobj.getShooter()) fw.writeObject(*myobj.getShooter());
return true;
}

View File

@@ -1,46 +0,0 @@
#include <osgParticle/ModularProgram>
#include <osgParticle/Operator>
#include <iostream>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool ModularProgram_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool ModularProgram_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy ModularProgram_Proxy
(
osgNew osgParticle::ModularProgram,
"ModularProgram",
"Object Node ParticleProcessor Program ModularProgram",
ModularProgram_readLocalData,
ModularProgram_writeLocalData
);
bool ModularProgram_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::ModularProgram &myobj = static_cast<osgParticle::ModularProgram &>(obj);
bool itAdvanced = false;
osgParticle::Operator *op = dynamic_cast<osgParticle::Operator *>(fr.readObject());
if (op) {
myobj.addOperator(op);
itAdvanced = true;
}
return itAdvanced;
}
bool ModularProgram_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::ModularProgram &myobj = static_cast<const osgParticle::ModularProgram &>(obj);
for (int i=0; i<myobj.numOperators(); ++i) {
fw.writeObject(*myobj.getOperator(i));
}
return true;
}

View File

@@ -1,54 +0,0 @@
#include <osgParticle/MultiSegmentPlacer>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <osg/Vec3>
#include <iostream>
bool MultiSegmentPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool MultiSegmentPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy MultiSegmentPlacer_Proxy
(
osgNew osgParticle::MultiSegmentPlacer,
"MultiSegmentPlacer",
"Object Placer MultiSegmentPlacer",
MultiSegmentPlacer_readLocalData,
MultiSegmentPlacer_writeLocalData
);
bool MultiSegmentPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::MultiSegmentPlacer &myobj = static_cast<osgParticle::MultiSegmentPlacer &>(obj);
bool itAdvanced = false;
osg::Vec3 v;
if (fr[0].matchWord("vertex")) {
if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) {
myobj.addVertex(v);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
bool MultiSegmentPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::MultiSegmentPlacer &myobj = static_cast<const osgParticle::MultiSegmentPlacer &>(obj);
int n = myobj.numVertices();
for (int i=0; i<n; ++i) {
const osg::Vec3 &v = myobj.getVertex(i);
fw.indent() << "vertex " << v.x() << " " << v.y() << " " << v.z() << std::endl;
}
return true;
}

View File

@@ -1,205 +0,0 @@
#include <osgParticle/Particle>
#include <osgParticle/Interpolator>
#include <osgParticle/range>
#include <iostream>
#include <string>
#include <osg/Vec3>
#include <osg/Vec4>
#include <osg/Notify>
#include <osgDB/Input>
#include <osgDB/Output>
bool read_particle(osgDB::Input &fr, osgParticle::Particle &P)
{
if (fr[0].matchString("{")) {
++fr;
int entry = fr[0].getNoNestedBrackets();
bool itAdvanced = true;
while (!fr.eof() && fr[0].getNoNestedBrackets() >= entry && itAdvanced) {
itAdvanced = false;
if (fr[0].matchWord("shape")) {
const char *ptstr = fr[1].getStr();
if (ptstr) {
if (std::string(ptstr) == "QUAD") {
P.setShape(osgParticle::Particle::QUAD);
} else if (std::string(ptstr) == "HEXAGON") {
P.setShape(osgParticle::Particle::HEXAGON);
} else if (std::string(ptstr) == "POINT") {
P.setShape(osgParticle::Particle::POINT);
} else if (std::string(ptstr) == "QUAD_TRIANGLESTRIP") {
P.setShape(osgParticle::Particle::QUAD_TRIANGLESTRIP);
} else {
osg::notify(osg::WARN) << "Particle reader warning: invalid shape: " << ptstr << std::endl;
}
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("lifeTime")) {
float lt;
if (fr[1].getFloat(lt)) {
P.setLifeTime(lt);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("sizeRange")) {
osgParticle::rangef r;
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) {
P.setSizeRange(r);
fr += 3;
itAdvanced = true;
}
}
if (fr[0].matchWord("alphaRange")) {
osgParticle::rangef r;
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) {
P.setAlphaRange(r);
fr += 3;
itAdvanced = true;
}
}
if (fr[0].matchWord("colorRange")) {
osgParticle::rangev4 r;
if (fr[1].getFloat(r.minimum.x()) && fr[2].getFloat(r.minimum.y()) && fr[3].getFloat(r.minimum.z()) && fr[4].getFloat(r.minimum.w()) &&
fr[5].getFloat(r.maximum.x()) && fr[6].getFloat(r.maximum.y()) && fr[7].getFloat(r.maximum.z()) && fr[8].getFloat(r.maximum.w())) {
P.setColorRange(r);
fr += 9;
itAdvanced = true;
}
}
if (fr[0].matchWord("position")) {
osg::Vec3 v;
if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) {
P.setPosition(v);
fr += 4;
itAdvanced = true;
}
}
if (fr[0].matchWord("velocity")) {
osg::Vec3 v;
if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) {
P.setVelocity(v);
fr += 4;
itAdvanced = true;
}
}
if (fr[0].matchWord("radius")) {
float f;
if (fr[1].getFloat(f)) {
P.setRadius(f);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("mass")) {
float f;
if (fr[1].getFloat(f)) {
P.setMass(f);
fr += 2;
itAdvanced = true;
}
}
// interpolators
if (fr[0].matchWord("sizeInterpolator") && fr[1].matchString("{")) {
fr += 2;
itAdvanced = true;
osgParticle::Interpolator *ip = dynamic_cast<osgParticle::Interpolator *>(fr.readObject());
if (ip) {
P.setSizeInterpolator(ip);
}
++fr;
}
if (fr[0].matchWord("alphaInterpolator") && fr[1].matchString("{")) {
fr += 2;
itAdvanced = true;
osgParticle::Interpolator *ip = dynamic_cast<osgParticle::Interpolator *>(fr.readObject());
if (ip) {
P.setAlphaInterpolator(ip);
}
++fr;
}
if (fr[0].matchWord("colorInterpolator") && fr[1].matchString("{")) {
fr += 2;
itAdvanced = true;
osgParticle::Interpolator *ip = dynamic_cast<osgParticle::Interpolator *>(fr.readObject());
if (ip) {
P.setColorInterpolator(ip);
}
++fr;
}
}
return true;
}
return false;
}
void write_particle(const osgParticle::Particle &P, osgDB::Output &fw)
{
fw << "{" << std::endl;
fw.moveIn();
fw.indent() << "shape ";
switch (P.getShape())
{
case osgParticle::Particle::POINT: fw << "POINT" << std::endl; break;
case osgParticle::Particle::HEXAGON: fw << "HEXAGON" << std::endl; break;
case osgParticle::Particle::QUAD_TRIANGLESTRIP: fw << "QUAD_TRIANGLESTRIP" << std::endl; break;
case osgParticle::Particle::QUAD:
default: fw << "QUAD" << std::endl; break;
}
fw.indent() << "lifeTime " << P.getLifeTime() << std::endl;
osgParticle::rangef rf = P.getSizeRange();
fw.indent() << "sizeRange " << rf.minimum << " " << rf.maximum << std::endl;
rf = P.getAlphaRange();
fw.indent() << "alphaRange " << rf.minimum << " " << rf.maximum << std::endl;
osgParticle::rangev4 rv4 = P.getColorRange();
fw.indent() << "colorRange ";
fw << rv4.minimum.x() << " " << rv4.minimum.y() << " " << rv4.minimum.z() << " " << rv4.minimum.w() << " ";
fw << rv4.maximum.x() << " " << rv4.maximum.y() << " " << rv4.maximum.z() << " " << rv4.maximum.w() << std::endl;
osg::Vec3 v = P.getPosition();
fw.indent() << "position ";
fw << v.x() << " " << v.y() << " " << v.z() << std::endl;
v = P.getVelocity();
fw.indent() << "velocity ";
fw << v.x() << " " << v.y() << " " << v.z() << std::endl;
fw.indent() << "mass " << P.getMass() << std::endl;
fw.indent() << "radius " << P.getRadius() << std::endl;
// interpolators
fw.indent() << "sizeInterpolator {" << std::endl;
fw.moveIn();
fw.writeObject(*P.getSizeInterpolator());
fw.moveOut();
fw.indent() << "}" << std::endl;
fw.indent() << "alphaInterpolator {" << std::endl;
fw.moveIn();
fw.writeObject(*P.getAlphaInterpolator());
fw.moveOut();
fw.indent() << "}" << std::endl;
fw.indent() << "colorInterpolator {" << std::endl;
fw.moveIn();
fw.writeObject(*P.getColorInterpolator());
fw.moveOut();
fw.indent() << "}" << std::endl;
fw.moveOut();
fw.indent() << "}" << std::endl;
}

View File

@@ -1,93 +0,0 @@
#include <osgParticle/ParticleProcessor>
#include <osgParticle/ParticleSystem>
#include <iostream>
#include <osg/ref_ptr>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
extern bool read_particle(osgDB::Input &fr, osgParticle::Particle &P);
extern void write_particle(const osgParticle::Particle &P, osgDB::Output &fw);
bool ParticleProcessor_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool ParticleProcessor_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy ParticleProcessor_Proxy
(
0,
"ParticleProcessor",
"Object Node ParticleProcessor",
ParticleProcessor_readLocalData,
ParticleProcessor_writeLocalData
);
bool ParticleProcessor_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::ParticleProcessor &myobj = static_cast<osgParticle::ParticleProcessor &>(obj);
bool itAdvanced = false;
osg::ref_ptr<osgParticle::ParticleSystem> ps_proto = osgNew osgParticle::ParticleSystem;
osgParticle::ParticleSystem *ps = static_cast<osgParticle::ParticleSystem *>(fr.readObjectOfType(*ps_proto));
if (ps) {
myobj.setParticleSystem(ps);
itAdvanced = true;
}
if (fr[0].matchWord("enabled")) {
if (fr[1].matchWord("TRUE")) {
myobj.setEnabled(true);
fr += 2;
itAdvanced = true;
} else if (fr[1].matchWord("FALSE")) {
myobj.setEnabled(false);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("referenceFrame")) {
if (fr[1].matchWord("RELATIVE_TO_ABSOLUTE")) {
myobj.setReferenceFrame(osgParticle::ParticleProcessor::RELATIVE_TO_ABSOLUTE);
fr += 2;
itAdvanced = true;
}
if (fr[1].matchWord("RELATIVE_TO_PARENTS")) {
myobj.setReferenceFrame(osgParticle::ParticleProcessor::RELATIVE_TO_PARENTS);
fr += 2;
itAdvanced = true;
}
}
return itAdvanced;
}
bool ParticleProcessor_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::ParticleProcessor &myobj = static_cast<const osgParticle::ParticleProcessor &>(obj);
if (myobj.getParticleSystem()) fw.writeObject(*myobj.getParticleSystem());
fw.indent() << "enabled ";
if (myobj.isEnabled())
fw << "TRUE" << std::endl;
else
fw << "FALSE" << std::endl;
fw.indent() << "referenceFrame ";
switch (myobj.getReferenceFrame())
{
case osgParticle::ParticleProcessor::RELATIVE_TO_ABSOLUTE:
fw << "RELATIVE_TO_ABSOLUTE" << std::endl;
break;
case osgParticle::ParticleProcessor::RELATIVE_TO_PARENTS:
default:
fw << "RELATIVE_TO_PARENTS" << std::endl;
}
return true;
}

View File

@@ -1,173 +0,0 @@
#include <osgParticle/ParticleSystem>
#include <osg/BoundingBox>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <iostream>
#include <string>
extern bool read_particle(osgDB::Input &fr, osgParticle::Particle &P);
extern void write_particle(const osgParticle::Particle &P, osgDB::Output &fw);
bool ParticleSystem_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool ParticleSystem_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy ParticleSystem_Proxy
(
osgNew osgParticle::ParticleSystem,
"ParticleSystem",
"Object Drawable ParticleSystem",
ParticleSystem_readLocalData,
ParticleSystem_writeLocalData
);
bool ParticleSystem_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::ParticleSystem &myobj = static_cast<osgParticle::ParticleSystem &>(obj);
bool itAdvanced = false;
if (fr[0].matchWord("particleAlignment")) {
if (fr[1].matchWord("BILLBOARD")) {
myobj.setParticleAlignment(osgParticle::ParticleSystem::BILLBOARD);
fr += 2;
itAdvanced = true;
}
if (fr[1].matchWord("FIXED")) {
myobj.setParticleAlignment(osgParticle::ParticleSystem::FIXED);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("alignVectorX")) {
osg::Vec3 v;
if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) {
myobj.setAlignVectorX(v);
fr += 4;
itAdvanced = true;
}
}
if (fr[0].matchWord("alignVectorY")) {
osg::Vec3 v;
if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) {
myobj.setAlignVectorY(v);
fr += 4;
itAdvanced = true;
}
}
if (fr[0].matchWord("doublePassRendering")) {
if (fr[1].matchWord("TRUE")) {
myobj.setDoublePassRendering(true);
fr += 2;
itAdvanced = true;
} else if (fr[1].matchWord("FALSE")) {
myobj.setDoublePassRendering(false);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("frozen")) {
if (fr[1].matchWord("TRUE")) {
myobj.setFrozen(true);
fr += 2;
itAdvanced = true;
} else if (fr[1].matchWord("FALSE")) {
myobj.setFrozen(false); // this might not be necessary
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("freezeOnCull")) {
if (fr[1].matchWord("TRUE")) {
myobj.setFreezeOnCull(true);
fr += 2;
itAdvanced = true;
} else if (fr[1].matchWord("FALSE")) {
myobj.setFreezeOnCull(false);
fr += 2;
itAdvanced = true;
}
}
if (fr[0].matchWord("defaultBoundingBox")) {
osg::BoundingBox bbox;
if ( fr[1].getFloat(bbox.xMin()) &&
fr[2].getFloat(bbox.yMin()) &&
fr[3].getFloat(bbox.zMin()) &&
fr[4].getFloat(bbox.xMax()) &&
fr[5].getFloat(bbox.yMax()) &&
fr[6].getFloat(bbox.zMax()) ) {
myobj.setDefaultBoundingBox(bbox);
fr += 7;
itAdvanced = true;
}
}
if (fr[0].matchWord("particleTemplate")) {
++fr;
itAdvanced = true;
osgParticle::Particle P;
if (read_particle(fr, P)) {
myobj.setDefaultParticleTemplate(P);
}
}
return itAdvanced;
}
bool ParticleSystem_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::ParticleSystem &myobj = static_cast<const osgParticle::ParticleSystem &>(obj);
fw.indent() << "particleAlignment ";
switch (myobj.getParticleAlignment()) {
default:
case osgParticle::ParticleSystem::BILLBOARD:
fw << "BILLBOARD" << std::endl;
break;
case osgParticle::ParticleSystem::FIXED:
fw << "FIXED" << std::endl;
break;
}
osg::Vec3 v = myobj.getAlignVectorX();
fw.indent() << "alignVectorX " << v.x() << " " << v.y() << " " << v.z() << std::endl;
v = myobj.getAlignVectorY();
fw.indent() << "alignVectorY " << v.x() << " " << v.y() << " " << v.z() << std::endl;
fw.indent() << "doublePassRendering ";
if (myobj.getDoublePassRendering())
fw << "TRUE" << std::endl;
else
fw << "FALSE" << std::endl;
fw.indent() << "frozen ";
if (myobj.isFrozen())
fw << "TRUE" << std::endl;
else
fw << "FALSE" << std::endl;
fw.indent() << "freezeOnCull ";
if (myobj.getFreezeOnCull())
fw << "TRUE" << std::endl;
else
fw << "FALSE" << std::endl;
osg::BoundingBox bbox = myobj.getDefaultBoundingBox();
fw.indent() << "defaultBoundingBox ";
fw << bbox.xMin() << " " << bbox.yMin() << " " << bbox.zMin() << " ";
fw << bbox.xMax() << " " << bbox.yMax() << " " << bbox.zMax() << std::endl;
fw.indent() << "particleTemplate ";
write_particle(myobj.getDefaultParticleTemplate(), fw);
return true;
}

View File

@@ -1,45 +0,0 @@
#include <osgParticle/ParticleSystemUpdater>
#include <osg/ref_ptr>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool PSU_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool PSU_writeLocalData(const osg::Object &obj, osgDB::Output &fr);
osgDB::RegisterDotOsgWrapperProxy PSU_Proxy
(
osgNew osgParticle::ParticleSystemUpdater,
"ParticleSystemUpdater",
"Object Node ParticleSystemUpdater",
PSU_readLocalData,
PSU_writeLocalData
);
bool PSU_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::ParticleSystemUpdater &myobj = static_cast<osgParticle::ParticleSystemUpdater &>(obj);
bool itAdvanced = false;
osg::ref_ptr<osgParticle::ParticleSystem> proto = osgNew osgParticle::ParticleSystem;
osgParticle::ParticleSystem *ps = static_cast<osgParticle::ParticleSystem *>(fr.readObjectOfType(*proto));
if (ps) {
myobj.addParticleSystem(ps);
itAdvanced = true;
}
return itAdvanced;
}
bool PSU_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::ParticleSystemUpdater &myobj = static_cast<const osgParticle::ParticleSystemUpdater &>(obj);
for (int i=0; i<myobj.numParticleSystems(); ++i) {
fw.writeObject(*myobj.getParticleSystem(i));
}
return true;
}

View File

@@ -1,28 +0,0 @@
#include <osgParticle/PointPlacer>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool PointPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool PointPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy PointPlacer_Proxy
(
osgNew osgParticle::PointPlacer,
"PointPlacer",
"Object Placer CenteredPlacer PointPlacer",
PointPlacer_readLocalData,
PointPlacer_writeLocalData
);
bool PointPlacer_readLocalData(osg::Object &, osgDB::Input &)
{
return false;
}
bool PointPlacer_writeLocalData(const osg::Object &, osgDB::Output &)
{
return false;
}

View File

@@ -1,28 +0,0 @@
#include <osgParticle/Program>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool Program_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool Program_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy Program_Proxy
(
0,
"Program",
"Object Node ParticleProcessor Program",
Program_readLocalData,
Program_writeLocalData
);
bool Program_readLocalData(osg::Object &, osgDB::Input &)
{
return false;
}
bool Program_writeLocalData(const osg::Object &, osgDB::Output &)
{
return false;
}

View File

@@ -1,68 +0,0 @@
#include <osgParticle/RadialShooter>
#include <osgParticle/range>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool RadialShooter_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool RadialShooter_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy RadialShooter_Proxy
(
osgNew osgParticle::RadialShooter,
"RadialShooter",
"Object Shooter RadialShooter",
RadialShooter_readLocalData,
RadialShooter_writeLocalData
);
bool RadialShooter_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::RadialShooter &myobj = static_cast<osgParticle::RadialShooter &>(obj);
bool itAdvanced = false;
osgParticle::rangef r;
if (fr[0].matchWord("thetaRange")) {
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) {
myobj.setThetaRange(r);
fr += 3;
itAdvanced = true;
}
}
if (fr[0].matchWord("phiRange")) {
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) {
myobj.setPhiRange(r);
fr += 3;
itAdvanced = true;
}
}
if (fr[0].matchWord("initialSpeedRange")) {
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) {
myobj.setInitialSpeedRange(r);
fr += 3;
itAdvanced = true;
}
}
return itAdvanced;
}
bool RadialShooter_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::RadialShooter &myobj = static_cast<const osgParticle::RadialShooter &>(obj);
osgParticle::rangef r;
r = myobj.getThetaRange();
fw.indent() << "thetaRange " << r.minimum << " " << r.maximum << std::endl;
r = myobj.getPhiRange();
fw.indent() << "phiRange " << r.minimum << " " << r.maximum << std::endl;
r = myobj.getInitialSpeedRange();
fw.indent() << "initialSpeedRange " << r.minimum << " " << r.maximum << std::endl;
return true;
}

View File

@@ -1,30 +0,0 @@
#include <osgParticle/RandomRateCounter>
#include <iostream>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool RandomRateCounter_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool RandomRateCounter_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy RandomRateCounter_Proxy
(
osgNew osgParticle::RandomRateCounter,
"RandomRateCounter",
"Object Counter VariableRateCounter RandomRateCounter",
RandomRateCounter_readLocalData,
RandomRateCounter_writeLocalData
);
bool RandomRateCounter_readLocalData(osg::Object &, osgDB::Input &)
{
return false;
}
bool RandomRateCounter_writeLocalData(const osg::Object &, osgDB::Output &)
{
return false;
}

View File

@@ -1,59 +0,0 @@
#include <osgParticle/SectorPlacer>
#include <iostream>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool SectorPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool SectorPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy SectorPlacer_Proxy
(
osgNew osgParticle::SectorPlacer,
"SectorPlacer",
"Object Placer CenteredPlacer SectorPlacer",
SectorPlacer_readLocalData,
SectorPlacer_writeLocalData
);
bool SectorPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::SectorPlacer &myobj = static_cast<osgParticle::SectorPlacer &>(obj);
bool itAdvanced = false;
osgParticle::rangef r;
if (fr[0].matchWord("radiusRange")) {
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) {
myobj.setRadiusRange(r);
fr += 3;
itAdvanced = true;
}
}
if (fr[0].matchWord("phiRange")) {
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) {
myobj.setPhiRange(r);
fr += 3;
itAdvanced = true;
}
}
return itAdvanced;
}
bool SectorPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::SectorPlacer &myobj = static_cast<const osgParticle::SectorPlacer &>(obj);
osgParticle::rangef r;
r = myobj.getRadiusRange();
fw.indent() << "radiusRange " << r.minimum << " " << r.maximum << std::endl;
r = myobj.getPhiRange();
fw.indent() << "phiRange " << r.minimum << " " << r.maximum << std::endl;
return true;
}

View File

@@ -1,60 +0,0 @@
#include <osgParticle/SegmentPlacer>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <osg/Vec3>
#include <iostream>
bool SegmentPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool SegmentPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy SegmentPlacer_Proxy
(
osgNew osgParticle::SegmentPlacer,
"SegmentPlacer",
"Object Placer SegmentPlacer",
SegmentPlacer_readLocalData,
SegmentPlacer_writeLocalData
);
bool SegmentPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::SegmentPlacer &myobj = static_cast<osgParticle::SegmentPlacer &>(obj);
bool itAdvanced = false;
osg::Vec3 v;
if (fr[0].matchWord("vertex_A")) {
if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) {
myobj.setVertexA(v);
fr += 4;
itAdvanced = true;
}
}
if (fr[0].matchWord("vertex_B")) {
if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) {
myobj.setVertexB(v);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
bool SegmentPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::SegmentPlacer &myobj = static_cast<const osgParticle::SegmentPlacer &>(obj);
osg::Vec3 v = myobj.getVertexA();
fw.indent() << "vertex_A " << v.x() << " " << v.y() << " " << v.z() << std::endl;
v = myobj.getVertexB();
fw.indent() << "vertex_B " << v.x() << " " << v.y() << " " << v.z() << std::endl;
return true;
}

View File

@@ -1,47 +0,0 @@
#include <osgParticle/VariableRateCounter>
#include <iostream>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool VariableRateCounter_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool VariableRateCounter_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy VariableRateCounter_Proxy
(
0,
"VariableRateCounter",
"Object Counter VariableRateCounter",
VariableRateCounter_readLocalData,
VariableRateCounter_writeLocalData
);
bool VariableRateCounter_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgParticle::VariableRateCounter &myobj = static_cast<osgParticle::VariableRateCounter &>(obj);
bool itAdvanced = false;
osgParticle::rangef r;
if (fr[0].matchWord("rateRange")) {
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) {
myobj.setRateRange(r);
fr += 3;
itAdvanced = true;
}
}
return itAdvanced;
}
bool VariableRateCounter_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgParticle::VariableRateCounter &myobj = static_cast<const osgParticle::VariableRateCounter &>(obj);
osgParticle::rangef r = myobj.getRateRange();
fw.indent() << "rateRange " << r.minimum << " " << r.maximum << std::endl;
return true;
}

View File

@@ -2,38 +2,17 @@ TOPDIR = ../..
include $(TOPDIR)/Make/makedefs
CXXFILES =\
Emitter.cpp\
FluidFrictionOperator.cpp\
IO_AccelOperator.cpp\
IO_CenteredPlacer.cpp\
IO_Emitter.cpp\
IO_FluidFrictionOperator.cpp\
IO_ForceOperator.cpp\
IO_LinearInterpolator.cpp\
IO_ModularEmitter.cpp\
IO_ModularProgram.cpp\
IO_MultiSegmentPlacer.cpp\
IO_Particle.cpp\
IO_ParticleProcessor.cpp\
IO_ParticleSystem.cpp\
IO_ParticleSystemUpdater.cpp\
IO_PointPlacer.cpp\
IO_Program.cpp\
IO_RadialShooter.cpp\
IO_RandomRateCounter.cpp\
IO_SectorPlacer.cpp\
IO_SegmentPlacer.cpp\
IO_VariableRateCounter.cpp\
ModularEmitter.cpp\
ModularProgram.cpp\
MultiSegmentPlacer.cpp\
Particle.cpp\
ParticleProcessor.cpp\
ParticleSystem.cpp\
ParticleSystemUpdater.cpp\
Program.cpp\
Version.cpp\
Emitter.cpp\
FluidFrictionOperator.cpp\
ModularEmitter.cpp\
ModularProgram.cpp\
MultiSegmentPlacer.cpp\
Particle.cpp\
ParticleProcessor.cpp\
ParticleSystem.cpp\
ParticleSystemUpdater.cpp\
Program.cpp\
Version.cpp\
LIBS += -losg -losgDB -losgUtil $(GL_LIBS) $(OTHER_LIBS) $(DYNAMICLIBRARYLIB)