[osg-users] cullcallback and visitor ?

Vincent Bourdier vincent.bourdier at gmail.com
Thu Sep 25 23:58:43 PDT 2008


Hi,

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)

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.

How to implement the cull() method allowing my code to get the cull state
when I need it ?
I'm a bit lost...

Thanks.

Regards,
 Vincent.


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

> 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/c2e14258/attachment-0003.htm>


More information about the osg-users mailing list