Hello all,

 

I would like create a scene with one object, which can receive shadows and
one object, which can cast a shadow.

So I create an osgShadow::ShadowedScene and I set the
ReceivesShadowTraversalMask (0x1) and the CastsShadowTraversalMask (0x2).
Then I set the ShadowTechnique on ShadowMap and add two nodes. For the first
node I set the node mask on 0x1 and for the second node I set the node mask
on 0x2. My problem is, the second node receive shadows, but this
<http://dict.leo.org/ende?lp=ende&p=thMx..&search=should> should
<http://dict.leo.org/ende?lp=ende&p=thMx..&search=be> be
<http://dict.leo.org/ende?lp=ende&p=thMx..&search=excluded> excluded.

 

Here my code:

 

const int ReceivesShadowTraversalMask = 0x1;

const int CastsShadowTraversalMask = 0x2;

 

int main()

{

      // scene node

      osg::ref_ptr<osg::Group> root = new osg::Group;

 

      // light node

      osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;

      osg::ref_ptr<osg::Light> light = new osg::Light();

      light->setPosition(osg::Vec4(20.0,80.0,80.0,1.0));

      light->setAmbient(osg::Vec4(0.0,0.0,0.0,1.0));

      ls->setLight(light.get());

      root->addChild(ls.get());

 

      // shadow scene

      osg::ref_ptr<osgShadow::ShadowedScene> scene = new
osgShadow::ShadowedScene;

      scene->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask);

      scene->setCastsShadowTraversalMask(CastsShadowTraversalMask);

 

      // shadow map

      osg::ref_ptr<osgShadow::ShadowMap> sm = new osgShadow::ShadowMap;

      sm->setTextureSize(osg::Vec2s(2048,2048));

      scene->setShadowTechnique(sm.get());

 

      // load nodes

      osg::ref_ptr<osg::Node> node01 =
osgDB::readNodeFile("../../objects/ebene.osg");

      node01->setNodeMask(ReceivesShadowTraversalMask);

 

      osg::ref_ptr<osg::Node> node02 =
osgDB::readNodeFile("../../objects/teekanne.osg");

      node02->setNodeMask(CastsShadowTraversalMask);

 

      scene->addChild(node01.get());

      scene->addChild(node02.get());

      root->addChild(scene.get());

 

      // viewer

      osgViewer::Viewer viewer;

      viewer.setSceneData(root.get());

      viewer.realize();

      viewer.run();

 

      return 0;

}

 

 

 

Can anyone help me?

 

Cheers,

 

Martin

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to