|
osg::ref_ptr<osgShadow::ShadowedScene> ss=new osgShadow::ShadowedScene;
ss->setShadowTechnique(new osgShadow::SoftShadowMap);
ss->setReceivesShadowTraversalMask(0x01);
ss->setCastsShadowTraversalMask(0x02);
dixingX->setNodeMask(0x02);
d2->setNodeMask(0x01);
ss->addChild(dixingX);
ss->addChild(d2.get());
//设置光源1
osg::BoundingSphere bs=d2->getBound();
osg::Vec4 position=osg::Vec4(bs.center().x()-500,bs.center().y()-bs.radius(),bs.center().z()+1000,1.0f);
//osg::Vec4 position=osg::Vec4(-50,-10,10,1.0f);
osg::ref_ptr<osg:ightSource> ls=new osg::LightSource;
ls->getLight()->setPosition(position);
//ls->getLight()->setDirection(osg::Vec3(0.0f,1.0f,-1.0f));
ls->getLight()->setAmbient(osg::Vec4(0.2,0.2,0.2,1.0));
ls->getLight()->setDiffuse(osg::Vec4(0.3,0.3,0.3,1.0));
//光源衰减
ls->getLight()->setConstantAttenuation(1.0f);
ls->getLight()->setLinearAttenuation(0.0f);
ls->getLight()->setQuadraticAttenuation(0.0f);
我在模型的一边设置了一个光源,使模型产生一个阴影,但是法线模型的另一面(在阴影中的那一部分)是黑色的,看不清原来的纹理,这种情况应该怎样解决啊,谢谢!!! |
|