#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::ref_ptr<osg::Node> glider = osgDB::readNodeFile("glider.osg");
root->addChild(glider.get());
viewer.setSceneData(root);
viewer.realize();
viewer.run();
}
OSG雪花粒子效果
最新推荐文章于 2023-12-22 22:22:03 发布