Hello Michael,

On 11/16/2010 09:14 AM, Michael Raab wrote:
> I tried it your way. I used MaterialGroup::renderEnter/Leave as draft for my 
> implementation.
>
> Action::ResultE onEnterMaterialGroup( CNodePtr&  pNode, Action * action )
> {
>       RenderAction *ra = dynamic_cast<RenderAction *>(action);
>       MaterialGroupPtr mg = MaterialGroupPtr::dcast(pNode);
>
>      Action::ResultE r = mg->renderEnter(action);
>       
>       osg::ChunkMaterialPtr m = 
> SelectionHelper::getInstance()->getIDMaterial(osg::getContainerId(pNode));
>       ra->setMaterial(m.getCPtr(), action->getActNode());
>
>      return r;
> }
>
> Action::ResultE onLeaveMaterialGroup( CNodePtr&  pNode, Action * action )
> {
>       RenderAction *ra = dynamic_cast<RenderAction *>(action);
>       MaterialGroupPtr mg = MaterialGroupPtr::dcast(pNode);
>
>      return mg->renderLeave(action);
> }
 >
> The problem is
> mg->renderEnter(action) and
> mg->renderLeave(action)
> are protected. Ideas?

I don't think you want to call the original MaterialGroup callbacks at 
all, those are the ones that set the material on the RenderAction which 
then prevents your per-geometry material to be used.
Also, for the id-buffer rendering you probably want a unique material 
for each geometry regardless of their original material (so you don't 
want to set the id-buffer material from the MaterialGroup). My 
suggestion therefore was to register the callbacks of Group for 
MaterialGroup (basically getting rid of the special behaviour of MG and 
just keep the frustum culling stuff from Group).
I see now that Group's callbacks are protected too, but you can copy the 
contents to the above callbacks and should be good.

I guess what I'm trying to say is that for id-buffer rendering a 
MaterialGroup should just behave like a Group.

        Cheers,
                Carsten

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to