需要加阴影和光照,才能产生阴影效果
1. 如何加阴影
//加阴影
osg::ref_ptr<osgShadow::SoftShadowMap > ssm = new osgShadow::SoftShadowMap;
// ssm->setAmbientBias(osg::Vec2(0.7,0.7));//0.5,0.5
float bias = ssm->getBias();
ssm->setBias(bias*2.0);
osg::ref_ptr<osgShadow::ShadowedScene> ss = new osgShadow::ShadowedScene();
ss->setShadowTechnique(ssm);
ss->setReceivesShadowTraversalMask(0x01);
ss->setCastsShadowTraversalMask(0x02);
_buildings->setNodeMask(0x02);