Hi,

I asked similar question some time ago. In the meantime I figured it out 
myself. You don't need to add light to shadowed scene nor it does not need 
to be present in fixed location in viewer scene hierarchy. I assume of 
course that you have at lest one light somewhere in hierarchy. In case of 
many lights it would be helpful if you point out the Light source that must 
be used to generate shadows. See ShadowMap::setLight function.

 I suspect that crash you observe is due to unitialized ShadowMap technique. 
If you can use debuger, check if osgShadow::ShadowMap::init() gets called 
before the crash. If not you may try to call it by yourself as last line of 
your example.
Try adding "sm->init();" line.

Init should be called in UpdateTraversal but if for some reason you created 
your ShadowedScene after UpdateTraversal but before CullTraversal : crash 
may happen.

Cheers,
Wojtek Lewandowski

----- Original Message ----- 
From: "Basic Soft" <[EMAIL PROTECTED]>
To: <osg-users@lists.openscenegraph.org>
Sent: Friday, January 11, 2008 3:38 PM
Subject: [osg-users] Adding shadow to an existing scenegraph


>I want to add shadowing to a complex already loaded
> scene in a larger framework context. Possibly
> shadowing should only be activated for subgraphs.
>
> So far I'm trying to add a osgShadow::ShadowedScene to
> the scenegraph which crashes on me while the
> scenegraph is traversed. Error message is as follows:
> osg25-osgd.dll!osg::Object::getDataVariance()
>
> Do I need to register the ShadowedScene with the
> Viewer or the associated Camera? Must there be a light
> present in the ShadowedScene?
>
> Any help greatly appreciated here.
>
> Here is a code snippet:
>
> osg::ref_ptr<osgShadow::ShadowedScene> shadowedScene =
> new osgShadow::ShadowedScene;
>
> shadowedScene->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask);
> shadowedScene->setCastsShadowTraversalMask(CastsShadowTraversalMask);
>
> osg::ref_ptr<osgShadow::ShadowMap> sm = new
> osgShadow::ShadowMap;
> shadowedScene->setShadowTechnique(sm.get());
>
> selectedNode->setNodeMask(CastsShadowTraversalMask);
> selectedNode->setNodeMask(ReceivesShadowTraversalMask);
> shadowedScene->addChild(selectedNode);
>
> shadowedScene->addChild(selectedNode);
> root->asGroup()->replaceChild(selectedNode, shadowedScene.get());
>
>
> 
> ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now. 
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to