Moved the IO support for the osgText and osgParticle libraries into seperate
plugin libraries.
This commit is contained in:
48
src/osgPlugins/osgParticle/IO_AccelOperator.cpp
Normal file
48
src/osgPlugins/osgParticle/IO_AccelOperator.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
49
src/osgPlugins/osgParticle/IO_CenteredPlacer.cpp
Normal file
49
src/osgPlugins/osgParticle/IO_CenteredPlacer.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
70
src/osgPlugins/osgParticle/IO_Emitter.cpp
Normal file
70
src/osgPlugins/osgParticle/IO_Emitter.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
63
src/osgPlugins/osgParticle/IO_FluidFrictionOperator.cpp
Normal file
63
src/osgPlugins/osgParticle/IO_FluidFrictionOperator.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
48
src/osgPlugins/osgParticle/IO_ForceOperator.cpp
Normal file
48
src/osgPlugins/osgParticle/IO_ForceOperator.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
28
src/osgPlugins/osgParticle/IO_LinearInterpolator.cpp
Normal file
28
src/osgPlugins/osgParticle/IO_LinearInterpolator.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
62
src/osgPlugins/osgParticle/IO_ModularEmitter.cpp
Normal file
62
src/osgPlugins/osgParticle/IO_ModularEmitter.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
46
src/osgPlugins/osgParticle/IO_ModularProgram.cpp
Normal file
46
src/osgPlugins/osgParticle/IO_ModularProgram.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
54
src/osgPlugins/osgParticle/IO_MultiSegmentPlacer.cpp
Normal file
54
src/osgPlugins/osgParticle/IO_MultiSegmentPlacer.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
205
src/osgPlugins/osgParticle/IO_Particle.cpp
Normal file
205
src/osgPlugins/osgParticle/IO_Particle.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
93
src/osgPlugins/osgParticle/IO_ParticleProcessor.cpp
Normal file
93
src/osgPlugins/osgParticle/IO_ParticleProcessor.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
173
src/osgPlugins/osgParticle/IO_ParticleSystem.cpp
Normal file
173
src/osgPlugins/osgParticle/IO_ParticleSystem.cpp
Normal file
@@ -0,0 +1,173 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
45
src/osgPlugins/osgParticle/IO_ParticleSystemUpdater.cpp
Normal file
45
src/osgPlugins/osgParticle/IO_ParticleSystemUpdater.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
28
src/osgPlugins/osgParticle/IO_PointPlacer.cpp
Normal file
28
src/osgPlugins/osgParticle/IO_PointPlacer.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
28
src/osgPlugins/osgParticle/IO_Program.cpp
Normal file
28
src/osgPlugins/osgParticle/IO_Program.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
68
src/osgPlugins/osgParticle/IO_RadialShooter.cpp
Normal file
68
src/osgPlugins/osgParticle/IO_RadialShooter.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
30
src/osgPlugins/osgParticle/IO_RandomRateCounter.cpp
Normal file
30
src/osgPlugins/osgParticle/IO_RandomRateCounter.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
59
src/osgPlugins/osgParticle/IO_SectorPlacer.cpp
Normal file
59
src/osgPlugins/osgParticle/IO_SectorPlacer.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
60
src/osgPlugins/osgParticle/IO_SegmentPlacer.cpp
Normal file
60
src/osgPlugins/osgParticle/IO_SegmentPlacer.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
47
src/osgPlugins/osgParticle/IO_VariableRateCounter.cpp
Normal file
47
src/osgPlugins/osgParticle/IO_VariableRateCounter.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
33
src/osgPlugins/osgParticle/Makefile
Normal file
33
src/osgPlugins/osgParticle/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
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\
|
||||
|
||||
|
||||
LIBS += -losgParticle $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
TARGET_BASENAME = osgParticle
|
||||
include $(TOPDIR)/Make/cygwin_plugin_def
|
||||
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
205
src/osgPlugins/osgText/IO_Font.cpp
Normal file
205
src/osgPlugins/osgText/IO_Font.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
#include <osgText/Font>
|
||||
#include <osgText/Font>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class Font
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Font_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy Font_Proxy
|
||||
(
|
||||
0,
|
||||
"Font",
|
||||
"Object Font",
|
||||
0,
|
||||
Font_writeLocalData
|
||||
);
|
||||
|
||||
bool Font_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgText::Font &myobj = static_cast<const osgText::Font &>(obj);
|
||||
|
||||
fw.indent() << "parameters ";
|
||||
fw << myobj.getPointSize() << " " << myobj.getTextureSize() << " ";
|
||||
fw << "\"" << myobj.getFontName() << "\"" << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class BitmapFont
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool BitmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy BitmapFont_Proxy
|
||||
(
|
||||
osgNew osgText::BitmapFont,
|
||||
"BitmapFont",
|
||||
"Object Font RasterFont BitmapFont",
|
||||
BitmapFont_readLocalData,
|
||||
0
|
||||
);
|
||||
|
||||
bool BitmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgText::BitmapFont &myobj = static_cast<osgText::BitmapFont &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
if (fr[0].matchWord("parameters")) {
|
||||
int psize;
|
||||
if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) {
|
||||
osgText::BitmapFont *temp = osgNew osgText::BitmapFont(std::string(fr[3].getStr()), psize);
|
||||
temp->copyAndInvalidate(myobj);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class PixmapFont
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool PixmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy PixmapFont_Proxy
|
||||
(
|
||||
osgNew osgText::PixmapFont,
|
||||
"PixmapFont",
|
||||
"Object Font RasterFont PixmapFont",
|
||||
PixmapFont_readLocalData,
|
||||
0
|
||||
);
|
||||
|
||||
bool PixmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgText::PixmapFont &myobj = static_cast<osgText::PixmapFont &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
if (fr[0].matchWord("parameters")) {
|
||||
int psize;
|
||||
if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) {
|
||||
osgText::PixmapFont *temp = osgNew osgText::PixmapFont(std::string(fr[3].getStr()), psize);
|
||||
temp->copyAndInvalidate(myobj);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class TextureFont
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TextureFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy TextureFont_Proxy
|
||||
(
|
||||
osgNew osgText::TextureFont,
|
||||
"TextureFont",
|
||||
"Object Font RasterFont TextureFont",
|
||||
TextureFont_readLocalData,
|
||||
0
|
||||
);
|
||||
|
||||
bool TextureFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgText::TextureFont &myobj = static_cast<osgText::TextureFont &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
if (fr[0].matchWord("parameters")) {
|
||||
int psize, txsize;
|
||||
if (fr[1].getInt(psize) && fr[2].getInt(txsize) && fr[3].isString()) {
|
||||
osgText::TextureFont *temp = osgNew osgText::TextureFont(std::string(fr[3].getStr()), psize, txsize);
|
||||
temp->copyAndInvalidate(myobj);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class OutlineFont
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool OutlineFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy OutlineFont_Proxy
|
||||
(
|
||||
osgNew osgText::OutlineFont,
|
||||
"OutlineFont",
|
||||
"Object Font VectorFont OutlineFont",
|
||||
OutlineFont_readLocalData,
|
||||
0
|
||||
);
|
||||
|
||||
bool OutlineFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgText::OutlineFont &myobj = static_cast<osgText::OutlineFont &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
if (fr[0].matchWord("parameters")) {
|
||||
int psize;
|
||||
if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) {
|
||||
osgText::OutlineFont *temp = osgNew osgText::OutlineFont(std::string(fr[3].getStr()), psize, 1);
|
||||
temp->copyAndInvalidate(myobj);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class PolygonFont
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool PolygonFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy PolygonFont_Proxy
|
||||
(
|
||||
osgNew osgText::PolygonFont,
|
||||
"PolygonFont",
|
||||
"Object Font VectorFont PolygonFont",
|
||||
PolygonFont_readLocalData,
|
||||
0
|
||||
);
|
||||
|
||||
bool PolygonFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgText::PolygonFont &myobj = static_cast<osgText::PolygonFont &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
if (fr[0].matchWord("parameters")) {
|
||||
int psize;
|
||||
if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) {
|
||||
osgText::PolygonFont *temp = osgNew osgText::PolygonFont(std::string(fr[3].getStr()), psize, 1);
|
||||
temp->copyAndInvalidate(myobj);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
100
src/osgPlugins/osgText/IO_Paragraph.cpp
Normal file
100
src/osgPlugins/osgText/IO_Paragraph.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#include <osgText/Paragraph>
|
||||
#include <osgText/Font>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
bool Paragraph_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool Paragraph_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
// osgDB::RegisterDotOsgWrapperProxy Paragraph_Proxy
|
||||
// (
|
||||
// osgNew osgText::Paragraph,
|
||||
// "Paragraph",
|
||||
// "Object Node Geode Paragraph",
|
||||
// Paragraph_readLocalData,
|
||||
// Paragraph_writeLocalData
|
||||
// );
|
||||
//
|
||||
bool Paragraph_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgText::Paragraph &myobj = static_cast<osgText::Paragraph &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
// font
|
||||
osgText::Font *font = dynamic_cast<osgText::Font *>(fr.readObject());
|
||||
if (font) {
|
||||
myobj.setFont(font);
|
||||
itAdvanced = true;
|
||||
}
|
||||
|
||||
// maximum chars
|
||||
if (fr[0].matchWord("maximumNoCharactersPerLine")) {
|
||||
int i;
|
||||
if (fr[1].getInt(i)) {
|
||||
myobj.setMaximumNoCharactersPerLine(i);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
// text
|
||||
if (fr[0].matchWord("text") && fr[1].isString()) {
|
||||
myobj.setText(std::string(fr[1].getStr()));
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
|
||||
// position
|
||||
if (fr[0].matchWord("position")) {
|
||||
osg::Vec3 p;
|
||||
if (fr[1].getFloat(p.x()) && fr[2].getFloat(p.y()) && fr[3].getFloat(p.z())) {
|
||||
myobj.setPosition(p);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
// alignment
|
||||
if (fr[0].matchWord("alignment")) {
|
||||
int i;
|
||||
if (fr[1].getInt(i)) {
|
||||
myobj.setAlignment(i);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool Paragraph_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgText::Paragraph &myobj = static_cast<const osgText::Paragraph &>(obj);
|
||||
|
||||
// font
|
||||
fw.writeObject(*myobj.getFont());
|
||||
|
||||
// maximum chars
|
||||
fw.indent() << "maximumNoCharactersPerLine " << myobj.getMaximumNoCharactersPerLine() << std::endl;
|
||||
|
||||
// text
|
||||
fw.indent() << "text " << myobj.getText() << std::endl;
|
||||
|
||||
// position
|
||||
osg::Vec3 p = myobj.getPosition();
|
||||
fw.indent() << "position " << p.x() << " " << p.y() << " " << p.z() << std::endl;
|
||||
|
||||
// alignment
|
||||
fw.indent() << "alignment " << myobj.getAlignment() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
128
src/osgPlugins/osgText/IO_Text.cpp
Normal file
128
src/osgPlugins/osgText/IO_Text.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#include <osgText/Text>
|
||||
#include <osgText/Font>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy Text_Proxy
|
||||
(
|
||||
osgNew osgText::Text,
|
||||
"Text",
|
||||
"Object Drawable Text",
|
||||
Text_readLocalData,
|
||||
Text_writeLocalData
|
||||
);
|
||||
|
||||
bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
osgText::Text &myobj = static_cast<osgText::Text &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
// position
|
||||
if (fr[0].matchWord("position")) {
|
||||
osg::Vec3 p;
|
||||
if (fr[1].getFloat(p.x()) && fr[2].getFloat(p.y()) && fr[3].getFloat(p.z())) {
|
||||
myobj.setPosition(p);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
// color
|
||||
if (fr[0].matchWord("color")) {
|
||||
osg::Vec4 c;
|
||||
if (fr[1].getFloat(c.x()) && fr[2].getFloat(c.y()) && fr[3].getFloat(c.z()) && fr[4].getFloat(c.w())) {
|
||||
myobj.setColor(c);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
// draw mode
|
||||
if (fr[0].matchWord("drawMode")) {
|
||||
int i;
|
||||
if (fr[1].getInt(i)) {
|
||||
myobj.setDrawMode(i);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
// bounding box
|
||||
if (fr[0].matchWord("boundingBox")) {
|
||||
int i;
|
||||
if (fr[1].getInt(i)) {
|
||||
myobj.setBoundingBox(i);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
// alignment
|
||||
if (fr[0].matchWord("alignment")) {
|
||||
int i;
|
||||
if (fr[1].getInt(i)) {
|
||||
myobj.setAlignment(i);
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
// font
|
||||
osgText::Font *font = dynamic_cast<osgText::Font *>(fr.readObject());
|
||||
if (font) {
|
||||
myobj.setFont(font);
|
||||
itAdvanced = true;
|
||||
}
|
||||
|
||||
// text
|
||||
if (fr.matchSequence("text %s")) {
|
||||
myobj.setText(std::string(fr[1].getStr()));
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgText::Text &myobj = static_cast<const osgText::Text &>(obj);
|
||||
|
||||
// position
|
||||
osg::Vec3 p = myobj.getPosition();
|
||||
fw.indent() << "position " << p.x() << " " << p.y() << " " << p.z() << std::endl;
|
||||
|
||||
// color
|
||||
osg::Vec4 c = myobj.getColor();
|
||||
fw.indent() << "color " << c.x() << " " << c.y() << " " << c.z() << " " << c.w() << std::endl;
|
||||
|
||||
// draw mode
|
||||
fw.indent() << "drawMode " << myobj.getDrawMode() << std::endl;
|
||||
|
||||
// bounding box
|
||||
fw.indent() << "boundingBox " << myobj.getBoundingBox() << std::endl;
|
||||
|
||||
// alignment
|
||||
fw.indent() << "alignment " << myobj.getAlignment() << std::endl;
|
||||
|
||||
// font
|
||||
fw.writeObject(*myobj.getFont());
|
||||
|
||||
// text
|
||||
fw.indent() << "text \"" << myobj.getText() << "\"" << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
16
src/osgPlugins/osgText/Makefile
Normal file
16
src/osgPlugins/osgText/Makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
IO_Text.cpp \
|
||||
IO_Font.cpp \
|
||||
IO_Paragraph.cpp \
|
||||
|
||||
|
||||
LIBS += -losgText $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
TARGET_BASENAME = osgText
|
||||
include $(TOPDIR)/Make/cygwin_plugin_def
|
||||
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
Reference in New Issue
Block a user