Added .osg support for new ParticleEffect::s/getDefaultParticleTemplate.
This commit is contained in:
@@ -55,8 +55,6 @@ void ExplosionDebriEffect::setDefaults()
|
||||
|
||||
// set up unit particle.
|
||||
_defaultParticleTemplate.setLifeTime(1.0+0.6*_scale);
|
||||
_defaultParticleTemplate.setRadius(1.0f);
|
||||
_defaultParticleTemplate.setMass(osg::PI*4.0f/3.0f);
|
||||
_defaultParticleTemplate.setSizeRange(osgParticle::rangef(0.75f, 3.0f));
|
||||
_defaultParticleTemplate.setAlphaRange(osgParticle::rangef(0.0f, 1.0f));
|
||||
_defaultParticleTemplate.setColorRange(osgParticle::rangev4(
|
||||
@@ -93,9 +91,8 @@ void ExplosionDebriEffect::setUpEmitterAndProgram()
|
||||
ptemplate.setColorRange(_defaultParticleTemplate.getColorRange());
|
||||
|
||||
// these are physical properties of the particle
|
||||
float r = _defaultParticleTemplate.getRadius()*radius;
|
||||
ptemplate.setRadius(r);
|
||||
ptemplate.setMass(density*r*r*r*_defaultParticleTemplate.getMass());
|
||||
ptemplate.setRadius(radius);
|
||||
ptemplate.setMass(density*radius*radius*radius*osg::PI*4.0f/3.0f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +54,11 @@ void ExplosionEffect::setDefaults()
|
||||
|
||||
// set up unit particle.
|
||||
_defaultParticleTemplate.setLifeTime(0.5+0.1*_scale);
|
||||
_defaultParticleTemplate.setRadius(1.0f);
|
||||
_defaultParticleTemplate.setMass(osg::PI*4.0f/3.0f);
|
||||
_defaultParticleTemplate.setSizeRange(osgParticle::rangef(0.75f, 3.0f));
|
||||
_defaultParticleTemplate.setAlphaRange(osgParticle::rangef(0.1f, 1.0f));
|
||||
_defaultParticleTemplate.setColorRange(osgParticle::rangev4(
|
||||
osg::Vec4(1.0f, 0.8f, 0.2f, 1.0f),
|
||||
osg::Vec4(1.0f, 0.4f, 0.1f, 0.0f)));
|
||||
osg::Vec4(1.0f, 0.8f, 0.2f, 1.0f),
|
||||
osg::Vec4(1.0f, 0.4f, 0.1f, 0.0f)));
|
||||
|
||||
}
|
||||
|
||||
@@ -92,9 +90,8 @@ void ExplosionEffect::setUpEmitterAndProgram()
|
||||
ptemplate.setColorRange(_defaultParticleTemplate.getColorRange());
|
||||
|
||||
// these are physical properties of the particle
|
||||
float r = _defaultParticleTemplate.getRadius()*radius;
|
||||
ptemplate.setRadius(r);
|
||||
ptemplate.setMass(density*r*r*r*_defaultParticleTemplate.getMass());
|
||||
ptemplate.setRadius(radius);
|
||||
ptemplate.setMass(density*radius*radius*radius*osg::PI*4.0f/3.0f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ void FireEffect::setDefaults()
|
||||
|
||||
// set up unit particle.
|
||||
_defaultParticleTemplate.setLifeTime(0.5+0.1*_scale);
|
||||
_defaultParticleTemplate.setRadius(1.0f);
|
||||
_defaultParticleTemplate.setMass(osg::PI*4.0f/3.0f);
|
||||
_defaultParticleTemplate.setSizeRange(osgParticle::rangef(0.75f, 3.0f));
|
||||
_defaultParticleTemplate.setAlphaRange(osgParticle::rangef(0.1f, 1.0f));
|
||||
_defaultParticleTemplate.setColorRange(osgParticle::rangev4(
|
||||
@@ -91,9 +89,9 @@ void FireEffect::setUpEmitterAndProgram()
|
||||
ptemplate.setColorRange(_defaultParticleTemplate.getColorRange());
|
||||
|
||||
// these are physical properties of the particle
|
||||
float r = _defaultParticleTemplate.getRadius()*radius;
|
||||
ptemplate.setRadius(r);
|
||||
ptemplate.setMass(density*r*r*r*_defaultParticleTemplate.getMass());
|
||||
// these are physical properties of the particle
|
||||
ptemplate.setRadius(radius);
|
||||
ptemplate.setMass(density*radius*radius*radius*osg::PI*4.0f/3.0f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,6 @@ void SmokeEffect::setDefaults()
|
||||
|
||||
// set up unit particle.
|
||||
_defaultParticleTemplate.setLifeTime(5.0*_scale);
|
||||
_defaultParticleTemplate.setRadius(1.0f);
|
||||
_defaultParticleTemplate.setMass(osg::PI*4.0f/3.0f);
|
||||
_defaultParticleTemplate.setSizeRange(osgParticle::rangef(0.75f, 3.0f));
|
||||
_defaultParticleTemplate.setAlphaRange(osgParticle::rangef(0.1f, 1.0f));
|
||||
_defaultParticleTemplate.setColorRange(osgParticle::rangev4(
|
||||
@@ -88,9 +86,8 @@ void SmokeEffect::setUpEmitterAndProgram()
|
||||
ptemplate.setColorRange(_defaultParticleTemplate.getColorRange());
|
||||
|
||||
// these are physical properties of the particle
|
||||
float r = _defaultParticleTemplate.getRadius()*radius;
|
||||
ptemplate.setRadius(r);
|
||||
ptemplate.setMass(density*r*r*r*_defaultParticleTemplate.getMass());
|
||||
ptemplate.setRadius(radius);
|
||||
ptemplate.setMass(density*radius*radius*radius*osg::PI*4.0f/3.0f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,13 @@ bool ParticleEffect_readLocalData(osg::Object& object, osgDB::Input& fr)
|
||||
osgParticle::ParticleEffect& effect = static_cast<osgParticle::ParticleEffect&>(object);
|
||||
bool itrAdvanced = false;
|
||||
|
||||
if (fr.matchSequence("position %s"))
|
||||
{
|
||||
effect.setTextureFileName(fr[1].getStr());
|
||||
fr += 2;
|
||||
itrAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("position %f %f %f"))
|
||||
{
|
||||
osg::Vec3 position;
|
||||
@@ -77,16 +84,59 @@ bool ParticleEffect_readLocalData(osg::Object& object, osgDB::Input& fr)
|
||||
itrAdvanced = true;
|
||||
}
|
||||
|
||||
osgParticle::Particle particle = effect.getDefaultParticleTemplate();
|
||||
bool particleSet = false;
|
||||
|
||||
if (fr.matchSequence("particleDuration %f"))
|
||||
{
|
||||
float particleDuration;
|
||||
fr[1].getFloat(particleDuration);
|
||||
effect.setParticleDuration(particleDuration);
|
||||
|
||||
particle.setLifeTime(particleDuration);
|
||||
particleSet = true;
|
||||
fr += 2;
|
||||
itrAdvanced = true;
|
||||
}
|
||||
|
||||
|
||||
if (fr[0].matchWord("particleSizeRange"))
|
||||
{
|
||||
osgParticle::rangef r;
|
||||
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum))
|
||||
{
|
||||
particle.setSizeRange(r);
|
||||
particleSet = true;
|
||||
fr += 3;
|
||||
itrAdvanced = true;
|
||||
}
|
||||
}
|
||||
if (fr[0].matchWord("particleAlphaRange"))
|
||||
{
|
||||
osgParticle::rangef r;
|
||||
if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum))
|
||||
{
|
||||
particle.setAlphaRange(r);
|
||||
particleSet = true;
|
||||
fr += 3;
|
||||
itrAdvanced = true;
|
||||
}
|
||||
}
|
||||
if (fr[0].matchWord("particleColorRange"))
|
||||
{
|
||||
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()))
|
||||
{
|
||||
particle.setColorRange(r);
|
||||
particleSet = true;
|
||||
fr += 9;
|
||||
itrAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (particleSet)
|
||||
{
|
||||
effect.setDefaultParticleTemplate(particle);
|
||||
}
|
||||
|
||||
|
||||
if (fr.matchSequence("wind %f %f %f"))
|
||||
{
|
||||
@@ -136,12 +186,25 @@ bool ParticleEffect_writeLocalData(const osg::Object& object, osgDB::Output& fw)
|
||||
{
|
||||
const osgParticle::ParticleEffect& effect = static_cast<const osgParticle::ParticleEffect&>(object);
|
||||
|
||||
fw.indent()<<"textFileName "<<effect.getTextureFileName()<<std::endl;
|
||||
fw.indent()<<"position "<<effect.getPosition()<<std::endl;
|
||||
fw.indent()<<"scale "<<effect.getScale()<<std::endl;
|
||||
fw.indent()<<"intensity "<<effect.getIntensity()<<std::endl;
|
||||
fw.indent()<<"startTime "<<effect.getStartTime()<<std::endl;
|
||||
fw.indent()<<"emitterDuration "<<effect.getEmitterDuration()<<std::endl;
|
||||
fw.indent()<<"particleDuration "<<effect.getParticleDuration()<<std::endl;
|
||||
|
||||
osgParticle::rangef rf = effect.getDefaultParticleTemplate().getSizeRange();
|
||||
fw.indent() << "particleSizeRange " << rf.minimum << " " << rf.maximum << std::endl;
|
||||
|
||||
rf = effect.getDefaultParticleTemplate().getAlphaRange();
|
||||
fw.indent() << "particleAlphaRange " << rf.minimum << " " << rf.maximum << std::endl;
|
||||
|
||||
osgParticle::rangev4 rv4 = effect.getDefaultParticleTemplate().getColorRange();
|
||||
fw.indent() << "particleColorRange ";
|
||||
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;
|
||||
|
||||
fw.indent()<<"wind "<<effect.getWind()<<std::endl;
|
||||
|
||||
fw.indent()<<"useLocalParticleSystem ";
|
||||
|
||||
Reference in New Issue
Block a user