|
#include <osgProducer/Viewer>
#include <osg/Group>
#include <osgParticle/ExplosionEffect>
#include <osgParticle/ExplosionDebrisEffect>
#include <osgParticle/SmokeEffect>
#include <osgParticle/FireEffect>
void CreateFire(osg::Group *root)
{
//设置风速
osg::Vec3 wind(1.0f,0.0f,0.0f);
//设置位置
osg::Vec3 position(0, 0, 0) ;
//申请爆炸物,1.0为缩放比,当前为不缩放,还有一个默认的剧烈程度的参数,默认为1.0
osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(position, 1.0f);
//申请爆炸后的碎片,1.0为缩放比,当前为不缩放,还有一个默认的剧烈程度的参数,默认为1.0
osgParticle::ExplosionDebrisEffect* explosionDebri = new osgParticle::ExplosionDebrisEffect(position, 1.0f);
//建立烟模拟,1.0为缩放比,当前为不缩放,还有一个默认的剧烈程度的参数,默认为1.0
osgParticle::SmokeEffect* smoke = new osgParticle::SmokeEffect(position, 1.0f);
//建立火焰模拟,1.0为缩放比,当前为不缩放,还有一个默认的剧烈程度的参数,默认为1.0
osgParticle::FireEffect* fire = new osgParticle::FireEffect(position, 1.0f,5.0f);
//设置风力影响
explosion->setWind(wind);
explosionDebri->setWind(wind);
smoke->setWind(wind); fire->setWind(wind);
//加入到根结点
root->addChild(explosion);
root->addChild(explosionDebri);
root->addChild(smoke);
root->addChild(fire);
}
int main(int argc, char **argv)
{
osgProducer::Viewer viewer;
viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
osg::Group *root = new osg::Group;
//创建结点
CreateFire(root);
viewer.setSceneData(root);
viewer.realize();
while( !viewer.done() )
{
viewer.sync();
viewer.update();
viewer.frame();
}
viewer.sync();
viewer.cleanup_frame();
viewer.sync();
return 0;
}
我用的是osg2.99,这个程序运行不出...里面是旧版本的库,新版本osgProducer库改成了osgViewer,剩下的就不知道了。。。。求指教 |
|