|
定义了全局变量:
const int ReceivesShadowTraversalMask = 0x1;
const int CastsShadowTraversalMask = 0x2;
然后在一个函数里设置阴影,但是设置断点调试时setReceivesShadowTraversalMask和setCastsShadowTraversalMask只能执行一句,另一句跳过,请问是怎么回事啊??
osg::ref_ptr<osgShadow::ShadowedScene> shs = new osgShadow::ShadowedScene;
shs->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask);
shs->setCastsShadowTraversalMask(CastsShadowTraversalMask);
osg::ref_ptr<osgShadow::ShadowMap> sm = new osgShadow::ShadowMap;
shs->setShadowTechnique(sm.get());
osg::ref_ptr<osg::Node> node1 = boatNode.get();
osg::ref_ptr<osg::Node> node2 = terrainNode1.get();
if(node1)
{
node1->setNodeMask(CastsShadowTraversalMask);
}
if(node2)
{
node2->setNodeMask(ReceivesShadowTraversalMask);
}
osg::ref_ptr<osg::MatrixTransform> matt1 = new osg::MatrixTransform;
//osg::ref_ptr<osg::MatrixTransform> matt2 = new osg::MatrixTransform;
matt1->addChild(node1);
matt1->addChild(node2);
/*shadowScene->addChild(node1);
shadowScene->addChild(node2);*/
shs->addChild(matt1);
osg::ref_ptr<osg:ightSource> ls = new osg::LightSource;
ls->getLight()->setPosition(osg::Vec4(0.0,0.0,20000.0,1.0));
ls->getLight()->setAmbient(osg::Vec4(0.2,0.2,0.2,1.0));
ls->getLight()->setDiffuse(osg::Vec4(0.8,0.8,0.8,1.0));
shs->addChild(ls.get()); |
|