|
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osgParticle/PrecipitationEffect>
#include <osg/Node>
#include <osg/MatrixTransform>
#include <osgParticle/PrecipitationEffect>
#define dN 3.1415927
void main()
{
osgViewer::Viewer viewer;
osg::Group * root = new osg::Group() ;
osg::Node* ceep = osgDB::readNodeFile("d:/aa/earth/earth.ive") ;
root ->addChild(ceep) ;
osg::ref_ptr<osg::EllipsoidModel>pEll = new osg::EllipsoidModel;
double posx = 0.0;
double posy = 0.0;
double posz = 0.0;
pEll->convertLatLongHeightToXYZ(26.557861*dN/180,104.957843*dN/180,100000.0, posx, posy, posz);
pEll->convertLatLongHeightToXYZ(26.557861*dN/180,104.957843*dN/180,1000.0, posx, posy, posz);
osg::ref_ptr<osg::MatrixTransform> treffect = new osg::MatrixTransform;
treffect->setMatrix(osg::Matrix::translate(posx, posy, posz));
osg::ref_ptr<osgParticle:recipitationEffect> precipitationEffect = new osgParticle::PrecipitationEffect;
precipitationEffect->snow(0.5);
precipitationEffect->setParticleColor(osg::Vec4(1, 1, 1, 1));
precipitationEffect->setWind(osg::Vec3(posx, posy, posz));
treffect->addChild(precipitationEffect.get ()) ;
root->addChild(treffect.get());
viewer.setSceneData(root);
viewer.realize();
viewer.run();
}
我无论是用osgdem生成的earth.ive,还是用earth文件,都显示不出来雪,拉近后发现,雪在数字球内部下。 |
|