[osg-users] cullcallback and visitor ?

Vincent Bourdier vincent.bourdier at gmail.com
Fri Sep 26 00:40:06 PDT 2008


2008/9/26 Ulrich Hertlein <u.hertlein at sandbox.de>

> Hi Vincent,
>
> Vincent Bourdier wrote:
> > If if do a nodevisitior, I've the problem that the operator() takes a
> > nodevisitor in parameter and so I can't obtain the cull state with that.
> > (method isCulled() not aviable from a node visitor)
>
> The way I understood Robert, the fact that your operator() is called means
> the node in
> question is *not* culled so you could simple set your _isCulled=true.  And
> don't forget to
> call traverse().
>

Ok, this is a simple and good way to have the result, but not sufficient :
cull = true when operator() is called, but if the operator is not called,
cull still = true and will never be false...

Any idea to obtain the culled state when I want ?
(hoping it's the last question...)

Thanks a lot.

Regards,
Vincent.


>
> > Next, if I do a osg::drawable::Cullvisitor, I see how so implement the
> > cull() method, but It is a const method, so I can't add my own code in it
> to
> > memorize the cull state before looking at it.
>
> The Drawable::CullCallback serves a different purpose.
> It can be used to actively cull Drawables.
>
> Cheers,
> /ulrich
>
> >> Vincent Bourdier wrote:
> >>> _mainChild->getDrawable(0)->setCullCallback(new tileVisibleCallback());
> >>>
> >>> ***
> >>> tileVisibleCallback::tileVisibleCallback(){
> >>>     _cull = false;
> >>> };
> >>>
> >>> void tileVisibleCallback::operator()(osg::Node* node,
> >> osgUtil::CullVisitor*
> >>> nv){
> >>>     _cull = nv->isCulled(*node);
> >>>     osg::notify(osg::NOTICE)<<"Cull "<<_cull<<"\n";
> >>>
> >>> };
> >>>
> >>> bool tileVisibleCallback::isCulled(){
> >>>     return _cull;
> >>> };
> >> You're mixing up osg::Drawable::CullCallback and osg::NodeCallback and
> >> consequently
> >> osg::Node::setCullCallback and osg::Drawable::setCullCallback.
> >>
> >> osg::Drawable::CullCallback has a virtual cull() function that tells if
> the
> >> Drawable
> >> *should* be culled by returning true or false.
> >>
> >> osg::NodeCallback has a virtual operator() that does what you want.
> >>
> >> You need to derive your callback from osg::NodeCallback, implement
> >> operator() (as you
> >> already do), and call:
> >>        _mainChild->setCullCallback(...)
> >> instead of
> >>        _mainChild->getDrawable(0)->setCullCallback(...)
> >>
> >> Hope this helps,
> >> /ulrich
> >>
> >>> 2008/9/25 Vincent Bourdier <vincent.bourdier at gmail.com>
> >>>> class tileVisibleCallback : public osg::Drawable::CullCallback{
> >>>> public:
> >>>>     tileVisibleCallback();
> >>>>     virtual void operator()(osg::Node* node, osgUtil::CullVisitor*
> nv);
> >>>>     bool isCulled();
> >>>>
> >>>> private:
> >>>>     bool _cull;
> >>>>
> >>>> };
> >>>>
> >>>> Does it sound good for you ?
> >>>> (the mix between Cullcallback and osgUtil looks strange for me...
> >> but...)
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080926/c654d25e/attachment-0003.htm>


More information about the osg-users mailing list