欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

OSG学习笔记(三)动画效果

程序员文章站 2022-06-10 20:59:31
...

1.雨雪;起火爆炸。

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/api/Win32/GraphicsWindowWin32>
#include <osgDB/ReadFile>
#include <osgDB/ReaderWriter>
#include <osgFX/Scribe>
#include <osg/Switch>
#include <osg/MatrixTransform>
#include <osgParticle/PrecipitationEffect>
#include <osgParticle/FireEffect>
#include <osgParticle/ExplosionEffect>
#include <osgParticle/ExplosionDebrisEffect>

#include <iostream>



int main()
{
	osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
	osg::ref_ptr<osg::Group> root = new osg::Group;

	//root->addChild(osgDB::readNodeFile("D://3rdparty//OSG3.6.3//OpenSceneGraph-Data//glider.osg"));

	//osg::ref_ptr<osgParticle::PrecipitationEffect> pe = new osgParticle::PrecipitationEffect();
	//pe->snow(0.5);//雨雪效果,rain
	//pe->setParticleColor(osg::Vec4(1.0, 1, 1, 0.5));
	//pe->setWind(osg::Vec3(0.5, 0, 0));
	//root->addChild(pe);

	osg::ref_ptr<osgParticle::FireEffect> fe = new osgParticle::FireEffect(osg::Vec3(30, 30, 30), 90);
	root->addChild(fe);

	osg::ref_ptr<osgParticle::ExplosionEffect> ee = new osgParticle::ExplosionEffect(osg::Vec3(30, 30, 30), 90);
	root->addChild(ee);

	osg::ref_ptr<osgParticle::ExplosionDebrisEffect> ede = new osgParticle::ExplosionDebrisEffect(osg::Vec3(30, 30, 30), 9);
	root->addChild(ede);

	viewer->setSceneData(root.get());
	viewer->addEventHandler(new osgViewer::WindowSizeHandler);	
	viewer->run();                                             

	return 0;
}

 

相关标签: OSG