Hello Antonio,

Antonio Bleile wrote:
>  > You can override an Action's callbacks on a per instance basis
>  > (registerEnterFunction, registerLeaveFunction), so you can create a
>  > regular RenderAction and register a different callback for geometry.
>  > That callback would basically do the same as the regular one, but only
>  > after testing that the node has no children.
> 
> OK, and here's the problem:
> 
> Action::ResultE myTraverse(CNodePtr &  Cnode, Action *action)
> {
>      OSG::NodePtr node = action->getActNode();
> 
>      if( node->getNChildren() )
>          return Action::Skip;
>      else
>          return Action::Continue;
> }

ah, well it is a bit more work than that ;)
You need to duplicate and modify the callback for Geometry, which is 
MaterialDrawable::renderActionHandler (see below). In there you check 
the node for children and if it has any you just return Action::Continue 
  otherwise do the usual thing:

Action::ResultE
MaterialDrawable::renderActionHandler(Action *action)
{
     RenderAction *a = dynamic_cast<RenderAction *>(action);

// BEGIN inserted code
     OSG::NodePtr node = action->getActNode();

     if(node->getNChildren() > 0)
          return Action::Continue;
// END inserted code

     Material::DrawFunctor func;
     func = osgTypedMethodFunctor1ObjPtr(this,
                                         &MaterialDrawable::drawPrimitives);

     Material* m = a->getMaterial();

     if(m == NULL)
     {
         if(getMaterial() != NullFC)
         {
             m = getMaterial().getCPtr();
         }
         else
         {
             m = getDefaultMaterial().getCPtr();
             FNOTICE(("MaterialDrawable::render: no Material!?!\n"));
         }
     }

     a->dropFunctor(func, m);

     return Action::Continue;
}

        Hope it helps,
                Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
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