天天看點

osg demo21 osgpraticle snow effect雪花效果

//DEMO21
//功能:加入雪花效果

#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osgParticle/PrecipitationEffect>
#include <osg/Node>

void main()
{
	osgViewer::Viewer viewer;
	//設定雪花類
	osg::ref_ptr<osgParticle::PrecipitationEffect>precipitationEffect = new osgParticle::PrecipitationEffect;
	//設定雪花濃度
	precipitationEffect->snow(0.5);
	//設定雪花顔色
	precipitationEffect->setParticleColor(osg::Vec4(1,1,1,1));
	//設定風向
	precipitationEffect->setWind(osg::Vec3(2,0,0));

	osg::Group* root = new osg::Group();
	//把雪花加入到場景節點
	root->addChild(precipitationEffect.get());
	osg::Node* ceep = osgDB::readNodeFile("ceep.ive");
	root->addChild(ceep);
	viewer.setSceneData(root);
	viewer.realize();
	viewer.run();
}
           
osg