- XML interface changes:
* condition at top level * <start|end>/<color|size> hierarchy * wind/gravity -> bool * rename some properties (rotspeed -> rotation-speed, etc.) * unit suffixes - remove redundant code - warnings--
This commit is contained in:
@@ -146,22 +146,18 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
}
|
}
|
||||||
std::string textureFile;
|
std::string textureFile;
|
||||||
if (configNode->hasValue("texture")) {
|
if (configNode->hasValue("texture")) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
//SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
"requested:"<<configNode->getStringValue("texture","")<<"\n");
|
// "requested:"<<configNode->getStringValue("texture","")<<"\n");
|
||||||
textureFile= osgDB::findFileInPath(configNode->getStringValue("texture",
|
textureFile= osgDB::findFileInPath(configNode->getStringValue("texture",
|
||||||
""),
|
""),
|
||||||
options->getDatabasePathList());
|
options->getDatabasePathList());
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "found:"<<textureFile<<"\n");
|
//SG_LOG(SG_GENERAL, SG_ALERT, "found:"<<textureFile<<"\n");
|
||||||
|
|
||||||
for(int i = 0; i < options->getDatabasePathList().size(); ++i)
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
|
||||||
"opts:"<<options->getDatabasePathList()[i]<<"\n");
|
|
||||||
|
|
||||||
|
//for(unsigned i = 0; i < options->getDatabasePathList().size(); ++i)
|
||||||
|
// SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
|
// "opts:"<<options->getDatabasePathList()[i]<<"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textureFile.empty())
|
|
||||||
textureFile="";
|
|
||||||
|
|
||||||
particleSys->setDefaultAttributes(textureFile,
|
particleSys->setDefaultAttributes(textureFile,
|
||||||
configNode->getBoolValue("emissive",
|
configNode->getBoolValue("emissive",
|
||||||
true),
|
true),
|
||||||
@@ -233,7 +229,7 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
shooter->setThetaRange(minTheta, maxTheta);
|
shooter->setThetaRange(minTheta, maxTheta);
|
||||||
shooter->setPhiRange(minPhi, maxPhi);
|
shooter->setPhiRange(minPhi, maxPhi);
|
||||||
|
|
||||||
const SGPropertyNode* speednode = shnode->getChild("speed");
|
const SGPropertyNode* speednode = shnode->getChild("speed-mps");
|
||||||
|
|
||||||
if (speednode) {
|
if (speednode) {
|
||||||
if (speednode->hasValue("value")) {
|
if (speednode->hasValue("value")) {
|
||||||
@@ -245,7 +241,7 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SGPropertyNode* rotspeednode = shnode->getChild("rotspeed");
|
const SGPropertyNode* rotspeednode = shnode->getChild("rotation-speed");
|
||||||
|
|
||||||
if (rotspeednode) {
|
if (rotspeednode) {
|
||||||
float x1,y1,z1,x2,y2,z2;
|
float x1,y1,z1,x2,y2,z2;
|
||||||
@@ -259,27 +255,29 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
}
|
}
|
||||||
} //else ModularEmitter uses the default RadialShooter
|
} //else ModularEmitter uses the default RadialShooter
|
||||||
|
|
||||||
|
|
||||||
|
const SGPropertyNode* conditionNode = configNode->getChild("condition");
|
||||||
const SGPropertyNode* counternode = configNode->getChild("counter");
|
const SGPropertyNode* counternode = configNode->getChild("counter");
|
||||||
|
|
||||||
if (counternode) {
|
if (conditionNode || counternode) {
|
||||||
osgParticle::RandomRateCounter* counter
|
osgParticle::RandomRateCounter* counter
|
||||||
= new osgParticle::RandomRateCounter;
|
= new osgParticle::RandomRateCounter;
|
||||||
emitter->setCounter(counter);
|
emitter->setCounter(counter);
|
||||||
float pps = 0.0f, spread = 0.0f;
|
float pps = 0.0f, spread = 0.0f;
|
||||||
const SGPropertyNode* ppsnode = counternode->getChild("pps");
|
|
||||||
|
|
||||||
if (ppsnode) {
|
if (counternode) {
|
||||||
|
const SGPropertyNode* ppsnode = counternode->getChild("particles-per-sec");
|
||||||
if (ppsnode->hasValue("value")) {
|
if (ppsnode) {
|
||||||
pps = ppsnode->getFloatValue("value",0);
|
if (ppsnode->hasValue("value")) {
|
||||||
spread = ppsnode->getFloatValue("spread",0);
|
pps = ppsnode->getFloatValue("value",0);
|
||||||
counter->setRateRange(pps-spread, pps+spread);
|
spread = ppsnode->getFloatValue("spread",0);
|
||||||
} else {
|
counter->setRateRange(pps-spread, pps+spread);
|
||||||
callback()->setupCounterData(ppsnode, modelRoot);
|
} else {
|
||||||
|
callback()->setupCounterData(ppsnode, modelRoot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const SGPropertyNode* conditionNode
|
|
||||||
= counternode->getChild("condition");
|
|
||||||
if (conditionNode) {
|
if (conditionNode) {
|
||||||
callback()->setupCounterCondition(conditionNode, modelRoot);
|
callback()->setupCounterCondition(conditionNode, modelRoot);
|
||||||
callback()->setupCounterCondition(pps, spread);
|
callback()->setupCounterCondition(pps, spread);
|
||||||
@@ -292,7 +290,7 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
= particleSys->getDefaultParticleTemplate();
|
= particleSys->getDefaultParticleTemplate();
|
||||||
float r1=0, g1=0, b1=0, a1=1, r2=0, g2=0, b2=0, a2=1;
|
float r1=0, g1=0, b1=0, a1=1, r2=0, g2=0, b2=0, a2=1;
|
||||||
const SGPropertyNode* startcolornode
|
const SGPropertyNode* startcolornode
|
||||||
= particlenode->getChild("startcolor");
|
= particlenode->getNode("start/color");
|
||||||
if (startcolornode) {
|
if (startcolornode) {
|
||||||
const SGPropertyNode* componentnode
|
const SGPropertyNode* componentnode
|
||||||
= startcolornode->getChild("red");
|
= startcolornode->getChild("red");
|
||||||
@@ -328,7 +326,7 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
0, 3);
|
0, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const SGPropertyNode* endcolornode = particlenode->getChild("endcolor");
|
const SGPropertyNode* endcolornode = particlenode->getNode("end/color");
|
||||||
if (endcolornode) {
|
if (endcolornode) {
|
||||||
const SGPropertyNode* componentnode = endcolornode->getChild("red");
|
const SGPropertyNode* componentnode = endcolornode->getChild("red");
|
||||||
|
|
||||||
@@ -368,14 +366,14 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
osg::Vec4(r2,g2,b2,a2)));
|
osg::Vec4(r2,g2,b2,a2)));
|
||||||
|
|
||||||
float startsize=1, endsize=0.1f;
|
float startsize=1, endsize=0.1f;
|
||||||
const SGPropertyNode* startsizenode = particlenode->getChild("startsize");
|
const SGPropertyNode* startsizenode = particlenode->getChild("start/size");
|
||||||
if (startsizenode) {
|
if (startsizenode) {
|
||||||
if (startsizenode->hasValue("value"))
|
if (startsizenode->hasValue("value"))
|
||||||
startsize = startsizenode->getFloatValue("value",0);
|
startsize = startsizenode->getFloatValue("value",0);
|
||||||
else
|
else
|
||||||
callback()->setupStartSizeData(startsizenode, modelRoot);
|
callback()->setupStartSizeData(startsizenode, modelRoot);
|
||||||
}
|
}
|
||||||
const SGPropertyNode* endsizenode = particlenode->getChild("endsize");
|
const SGPropertyNode* endsizenode = particlenode->getChild("end/size");
|
||||||
if (endsizenode) {
|
if (endsizenode) {
|
||||||
if (endsizenode->hasValue("value"))
|
if (endsizenode->hasValue("value"))
|
||||||
endsize = endsizenode->getFloatValue("value",0);
|
endsize = endsizenode->getFloatValue("value",0);
|
||||||
@@ -409,18 +407,14 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
osgParticle::FluidProgram *program = new osgParticle::FluidProgram();
|
osgParticle::FluidProgram *program = new osgParticle::FluidProgram();
|
||||||
|
|
||||||
if (programnode) {
|
if (programnode) {
|
||||||
std::string fluid = programnode->getStringValue("fluid","air");
|
std::string fluid = programnode->getStringValue("fluid", "air");
|
||||||
|
|
||||||
if (fluid=="air")
|
if (fluid=="air")
|
||||||
program->setFluidToAir();
|
program->setFluidToAir();
|
||||||
|
|
||||||
else
|
else
|
||||||
program->setFluidToWater();
|
program->setFluidToWater();
|
||||||
|
|
||||||
std::string grav = programnode->getStringValue("gravity","enabled");
|
if (programnode->getBoolValue("gravity", true)) {
|
||||||
|
|
||||||
if (grav=="enabled") {
|
|
||||||
|
|
||||||
if (attach == "world")
|
if (attach == "world")
|
||||||
callback()->setupProgramGravity(true);
|
callback()->setupProgramGravity(true);
|
||||||
else
|
else
|
||||||
@@ -428,8 +422,7 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
} else
|
} else
|
||||||
program->setAcceleration(osg::Vec3(0,0,0));
|
program->setAcceleration(osg::Vec3(0,0,0));
|
||||||
|
|
||||||
std::string wind = programnode->getStringValue("wind","enabled");
|
if (programnode->getBoolValue("wind", true))
|
||||||
if (wind=="enabled")
|
|
||||||
callback()->setupProgramWind(true);
|
callback()->setupProgramWind(true);
|
||||||
else
|
else
|
||||||
program->setWind(osg::Vec3(0,0,0));
|
program->setWind(osg::Vec3(0,0,0));
|
||||||
@@ -438,7 +431,6 @@ osg::Group * Particles::appendParticles(const SGPropertyNode* configNode,
|
|||||||
|
|
||||||
program->setParticleSystem(particleSys);
|
program->setParticleSystem(particleSys);
|
||||||
}
|
}
|
||||||
else { }
|
|
||||||
|
|
||||||
if (callback.get()) { //this means we want property-driven changes
|
if (callback.get()) { //this means we want property-driven changes
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "setting up particle system user data and callback\n");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "setting up particle system user data and callback\n");
|
||||||
|
|||||||
@@ -79,11 +79,9 @@ public:
|
|||||||
return wind;
|
return wind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
static osg::Vec3 gravity;
|
static osg::Vec3 gravity;
|
||||||
static osg::Vec3 wind;
|
static osg::Vec3 wind;
|
||||||
private:
|
|
||||||
|
|
||||||
const SGPropertyNode* modelRoot;
|
const SGPropertyNode* modelRoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -98,11 +96,11 @@ public:
|
|||||||
startSizeValue(NULL),
|
startSizeValue(NULL),
|
||||||
endSizeValue(NULL),
|
endSizeValue(NULL),
|
||||||
lifeValue(NULL),
|
lifeValue(NULL),
|
||||||
|
counterCond(NULL),
|
||||||
refFrame(NULL),
|
refFrame(NULL),
|
||||||
program(NULL),
|
program(NULL),
|
||||||
useGravity(false),
|
useGravity(false),
|
||||||
useWind(false),
|
useWind(false)
|
||||||
counterCond(NULL)
|
|
||||||
{
|
{
|
||||||
memset(colorComponents, 0, sizeof(colorComponents));
|
memset(colorComponents, 0, sizeof(colorComponents));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user