Hello Enrico,

Enrico Borrione wrote:
> Hi OpenSG Users,
>       right now i am trying to make my application handle a lot
> (really a lot) of models. To improve the overall performance of my program,
> I am using lodded models. 
> Since the farthest lod node appears when the model is very far from the
> viewer, 
> I'd like just the first node of the lod to casts shadow.
> 
> So I'd like something like this:
> 
> LODNODE
> |
> |- Child0 (casts shadow)
> |
> |- Child1 (doesn't cast shadow)
> 
> 
> To accomplish this, I thought about using a traverse to add distant lod
> nodes to the
> ShadowViewport exclude list. In my traverse I do something like:
> 
> myApp::AddNodeToScene (mynode)
> {
> ...
> ...
> ...
> Traverse disableShadowsOnLodNodel (myNode);
> ...
> ...
> ...
> }
> 
> osg::Action::ResultE myApp::disableShadowsOnLodNodel (osg::NodePtr& curNode)
> {
>       if ((curNode==NullFC)) 
>               return Action::Continue;
> 
>     osg::NodePtr parent = curNode->getParent ();
> 
>     if (parent==osg::NullFC)
>         return Action::Continue;
> 
>     if (parent->getCore()->getType().isDerivedFrom(
> osg::DistanceLOD::getClassType()))
>       {
>         int curNodeIndex = parent->findChild (curNode);
>         
> // avoid to remove the nearest node from the shadow casting
>         if (curNodeIndex!=0)
>             for (int i=0;i<m_vViewports.size();i++)
>             {
>                 beginEditCP(m_vViewports[i]);
>       
> m_vViewports[i]->getExcludeNodes().push_back(curNode);
>                   endEditCP(m_vViewports[i]);
>             }
>       }
> 
>       return Action::Continue;
> }
> 
> 
> 
> My problem is that after this traverse also the nearest lod node does not
> cast shadow anymore.
> Am I doing something wrong?

hm, is it possible that the LOD ranges prevent the nearest node from 
being used for shadow casting ?
The basic problem with your approach is that the ShadowViewport will 
just call setActive(false) on the Nodes in the exclude list, but that 
does not influence the DistanceLOD's choice of which child to use.
Unfortunately I can not think of a good and easy solution to this 
problem, other than modifying the DistanceLOD.

        Hope it helps,
                Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to