|
楼主 |
发表于 2012-4-9 18:12:50
|
显示全部楼层
这是尾迹的截图,设置生命期,尾迹会变得很难看:
代码:
OSGGroupPtr root = new osg::Group();
{
osgParticle:article ptemplate;
ValueParticle valueParticle = GetPropertyParticle();
ptemplate.setLifeTime(valueParticle.Life); // 3 seconds of life
ptemplate.setSizeRange(osgParticle::rangef(valueParticle.Size[0],valueParticle.Size[1]));
ptemplate.setAlphaRange(osgParticle::rangef(valueParticle.Alpha[0],valueParticle.Alpha[1]));
ptemplate.setColorRange(osgParticle::rangev4(Vector4Conv(valueParticle.Color[0]), Vector4Conv(valueParticle.Color[1])));
ptemplate.setRadius(valueParticle.Radius);
m_OSGParticleSystemPtr = new osgParticle::ParticleSystem;
m_OSGParticleSystemPtr->setDefaultAttributes(GetPropertyTexture().File, true, false);
m_OSGParticleSystemPtr->setParticleScaleReferenceFrame(osgParticle::ParticleSystem:OCAL_COORDINATES);
m_OSGParticleSystemPtr->setDefaultParticleTemplate(ptemplate);
m_OSGModularEmitterPtr = new osgParticle::ModularEmitter;
m_OSGModularEmitterPtr->setParticleSystem(m_OSGParticleSystemPtr);
Vector2 rateRange = GetPropertyRateRange();
osgParticle::RandomRateCounter *counter = new osgParticle::RandomRateCounter;
counter->setRateRange(rateRange[0], rateRange[1]);
m_OSGModularEmitterPtr->setCounter(counter);
Vector2 placerRadiusRange = GetPropertyPlacerRadiusRange();
osgParticle::SectorPlacer *placer = new osgParticle::SectorPlacer;
placer->setCenter(0, 0, 0);
placer->setRadiusRange(placerRadiusRange[0],placerRadiusRange[1]);
placer->setPhiRange(0, 2 * osg::PI);
m_OSGModularEmitterPtr->setPlacer(placer);
Vector2 shooterSpeedRange = GetPropertyShooterSpeedRange();
osgParticle::RadialShooter *shooter = new osgParticle::RadialShooter;
shooter->setThetaRange(0, 0);
shooter->setPhiRange(0, 0);
shooter->setInitialSpeedRange(shooterSpeedRange[0],shooterSpeedRange[1]);
m_OSGModularEmitterPtr->setShooter(shooter);
root->addChild(m_OSGModularEmitterPtr);
m_OSGModularProgramPtr = new osgParticle::ModularProgram;
m_OSGModularProgramPtr->setParticleSystem(m_OSGParticleSystemPtr);
m_OSGModularProgramPtr->setReferenceFrame(osgParticle::ParticleProcessor::RELATIVE_RF);
root->addChild(m_OSGModularProgramPtr.get());
// create a Geode to contain our particle system.
osg::Geode *geode = new osg::Geode;
geode->addDrawable(m_OSGParticleSystemPtr);
// add the geode to the scene graph.
root->addChild(geode);
//
osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater;
psu->addParticleSystem(m_OSGParticleSystemPtr);
root->addChild(psu);
}
这段代码是截取部分的,大概结构能够描述清楚
我是把粒子系统放到Root节点下,但不知道卫生么还是有长长的尾迹线,感觉放置器给拉长了 |
-
tupian
|