Re: [osg-users] cullcallback and visitor ?

2008-09-29 Thread Vincent Bourdier
Hi

I make a little UP because I go now a strange problem :

My Cullcallback seem to engender some other problems in my application. When
I put it, the application can crash or freeze, pretending sometimes not
enough memory (false, I've checked) or some other error messages with no
relation with that. I suppose my cull callback is not good and randomly
engender unstable states in the application...

This is what I do, to check visible elements or not :

Callback :

tileVisibleCallback::tileVisibleCallback(Tile* tile)
 : osg::NodeCallback(){
 _tile = tile;
 };

 void tileVisibleCallback::operator()(osg::Node* node, osg::NodeVisitor*
 nv){

 if(!_tile.valid()){
 osg::notify(osg::WARN)Tile callback error : tile not
 recognized!\n;
 return;
 }

 //This method is called so the tile is visible
 //Its name is added to the visible Tile list.
 _tile-_stack-_cullList.push_back(_tile-getName());


 traverse(node, nv);
 };




and the Set :

osg::ref_ptrtileVisibleCallback tvc = new tileVisibleCallback(this);
 if(_mainChild-getCullCallback())
 _mainChild-getCullCallback()-setNestedCallback(tvc.get());
 else
 _mainChild-setCullCallback(tvc.get());


Do you see something not clear ? unstable ? what can engender problems ?

Thanks a lot.

Regards,
Vincent

2008/9/26 Vincent Bourdier [EMAIL PROTECTED]

 Hi,

 I found an other solution using a vector to store the visible elements and
 clearing this list each render loop. I is the more simple solution I think.

 thanks for your help.
 Regards,
Vincent.

 2008/9/26 Ulrich Hertlein [EMAIL PROTECTED]

 Hi Vincent,


 Vincent Bourdier wrote:
  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...

 Yes it will never be reset by the cull traversal so you have to do that
 yourself e.g. just
 before cull or maybe after you've read the cull state from your class.

 Cheers,
 /ulrich

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-29 Thread Robert Osfield
Hi Vincent,

There isn't really any much of clue about what might be wrong from
your email, so you are probably going to have rely on your own skills
to track down what you've done wrong.   The only hint I got from you
email was mention of a out of memory, which could suggest many things
including perhaps that the stack has been filled by a never ending
loop.  This is all your code we are talking about here so you the only
person in a position to debug it.

Robert.

On Mon, Sep 29, 2008 at 2:52 PM, Vincent Bourdier
[EMAIL PROTECTED] wrote:
 Hi

 I make a little UP because I go now a strange problem :

 My Cullcallback seem to engender some other problems in my application. When
 I put it, the application can crash or freeze, pretending sometimes not
 enough memory (false, I've checked) or some other error messages with no
 relation with that. I suppose my cull callback is not good and randomly
 engender unstable states in the application...

 This is what I do, to check visible elements or not :

 Callback :

 tileVisibleCallback::tileVisibleCallback(Tile* tile)
 : osg::NodeCallback(){
 _tile = tile;
 };

 void tileVisibleCallback::operator()(osg::Node* node, osg::NodeVisitor*
 nv){

 if(!_tile.valid()){
 osg::notify(osg::WARN)Tile callback error : tile not
 recognized!\n;
 return;
 }

 //This method is called so the tile is visible
 //Its name is added to the visible Tile list.
 _tile-_stack-_cullList.push_back(_tile-getName());


 traverse(node, nv);
 };



 and the Set :

 osg::ref_ptrtileVisibleCallback tvc = new tileVisibleCallback(this);
 if(_mainChild-getCullCallback())
 _mainChild-getCullCallback()-setNestedCallback(tvc.get());
 else
 _mainChild-setCullCallback(tvc.get());

 Do you see something not clear ? unstable ? what can engender problems ?

 Thanks a lot.

 Regards,
 Vincent

 2008/9/26 Vincent Bourdier [EMAIL PROTECTED]

 Hi,

 I found an other solution using a vector to store the visible elements and
 clearing this list each render loop. I is the more simple solution I think.

 thanks for your help.
 Regards,
Vincent.

 2008/9/26 Ulrich Hertlein [EMAIL PROTECTED]

 Hi Vincent,

 Vincent Bourdier wrote:
  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...

 Yes it will never be reset by the cull traversal so you have to do that
 yourself e.g. just
 before cull or maybe after you've read the cull state from your class.

 Cheers,
 /ulrich

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-29 Thread Vincent Bourdier
Ok,

So I've some question for you :

It is usefull to put a traverse() call in a cullcallback ? are there some
actions we can not put in a cullcallback ?

thanks,

Regards
  Vincent

2008/9/29 Robert Osfield [EMAIL PROTECTED]

 Hi Vincent,

 There isn't really any much of clue about what might be wrong from
 your email, so you are probably going to have rely on your own skills
 to track down what you've done wrong.   The only hint I got from you
 email was mention of a out of memory, which could suggest many things
 including perhaps that the stack has been filled by a never ending
 loop.  This is all your code we are talking about here so you the only
 person in a position to debug it.

 Robert.

 On Mon, Sep 29, 2008 at 2:52 PM, Vincent Bourdier
 [EMAIL PROTECTED] wrote:
  Hi
 
  I make a little UP because I go now a strange problem :
 
  My Cullcallback seem to engender some other problems in my application.
 When
  I put it, the application can crash or freeze, pretending sometimes not
  enough memory (false, I've checked) or some other error messages with no
  relation with that. I suppose my cull callback is not good and randomly
  engender unstable states in the application...
 
  This is what I do, to check visible elements or not :
 
  Callback :
 
  tileVisibleCallback::tileVisibleCallback(Tile* tile)
  : osg::NodeCallback(){
  _tile = tile;
  };
 
  void tileVisibleCallback::operator()(osg::Node* node, osg::NodeVisitor*
  nv){
 
  if(!_tile.valid()){
  osg::notify(osg::WARN)Tile callback error : tile not
  recognized!\n;
  return;
  }
 
  //This method is called so the tile is visible
  //Its name is added to the visible Tile list.
  _tile-_stack-_cullList.push_back(_tile-getName());
 
 
  traverse(node, nv);
  };
 
 
 
  and the Set :
 
  osg::ref_ptrtileVisibleCallback tvc = new tileVisibleCallback(this);
  if(_mainChild-getCullCallback())
  _mainChild-getCullCallback()-setNestedCallback(tvc.get());
  else
  _mainChild-setCullCallback(tvc.get());
 
  Do you see something not clear ? unstable ? what can engender problems ?
 
  Thanks a lot.
 
  Regards,
  Vincent
 
  2008/9/26 Vincent Bourdier [EMAIL PROTECTED]
 
  Hi,
 
  I found an other solution using a vector to store the visible elements
 and
  clearing this list each render loop. I is the more simple solution I
 think.
 
  thanks for your help.
  Regards,
 Vincent.
 
  2008/9/26 Ulrich Hertlein [EMAIL PROTECTED]
 
  Hi Vincent,
 
  Vincent Bourdier wrote:
   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...
 
  Yes it will never be reset by the cull traversal so you have to do that
  yourself e.g. just
  before cull or maybe after you've read the cull state from your class.
 
  Cheers,
  /ulrich
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-29 Thread Robert Osfield
Hi Vincent,

You have to call traverse() in your callback, as node callbacks are in
effect traversal callbacks, if you don't include the traversal of the
subgraph nothing will happen, just make sure you don't traverse the
parent otherwise you'll end up with an infinite loop.

Robert.

On Mon, Sep 29, 2008 at 4:05 PM, Vincent Bourdier
[EMAIL PROTECTED] wrote:
 Ok,

 So I've some question for you :

 It is usefull to put a traverse() call in a cullcallback ? are there some
 actions we can not put in a cullcallback ?

 thanks,

 Regards
   Vincent

 2008/9/29 Robert Osfield [EMAIL PROTECTED]

 Hi Vincent,

 There isn't really any much of clue about what might be wrong from
 your email, so you are probably going to have rely on your own skills
 to track down what you've done wrong.   The only hint I got from you
 email was mention of a out of memory, which could suggest many things
 including perhaps that the stack has been filled by a never ending
 loop.  This is all your code we are talking about here so you the only
 person in a position to debug it.

 Robert.

 On Mon, Sep 29, 2008 at 2:52 PM, Vincent Bourdier
 [EMAIL PROTECTED] wrote:
  Hi
 
  I make a little UP because I go now a strange problem :
 
  My Cullcallback seem to engender some other problems in my application.
  When
  I put it, the application can crash or freeze, pretending sometimes not
  enough memory (false, I've checked) or some other error messages with
  no
  relation with that. I suppose my cull callback is not good and randomly
  engender unstable states in the application...
 
  This is what I do, to check visible elements or not :
 
  Callback :
 
  tileVisibleCallback::tileVisibleCallback(Tile* tile)
  : osg::NodeCallback(){
  _tile = tile;
  };
 
  void tileVisibleCallback::operator()(osg::Node* node, osg::NodeVisitor*
  nv){
 
  if(!_tile.valid()){
  osg::notify(osg::WARN)Tile callback error : tile not
  recognized!\n;
  return;
  }
 
  //This method is called so the tile is visible
  //Its name is added to the visible Tile list.
  _tile-_stack-_cullList.push_back(_tile-getName());
 
 
  traverse(node, nv);
  };
 
 
 
  and the Set :
 
  osg::ref_ptrtileVisibleCallback tvc = new tileVisibleCallback(this);
  if(_mainChild-getCullCallback())
  _mainChild-getCullCallback()-setNestedCallback(tvc.get());
  else
  _mainChild-setCullCallback(tvc.get());
 
  Do you see something not clear ? unstable ? what can engender problems ?
 
  Thanks a lot.
 
  Regards,
  Vincent
 
  2008/9/26 Vincent Bourdier [EMAIL PROTECTED]
 
  Hi,
 
  I found an other solution using a vector to store the visible elements
  and
  clearing this list each render loop. I is the more simple solution I
  think.
 
  thanks for your help.
  Regards,
 Vincent.
 
  2008/9/26 Ulrich Hertlein [EMAIL PROTECTED]
 
  Hi Vincent,
 
  Vincent Bourdier wrote:
   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...
 
  Yes it will never be reset by the cull traversal so you have to do
  that
  yourself e.g. just
  before cull or maybe after you've read the cull state from your class.
 
  Cheers,
  /ulrich
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-26 Thread Vincent Bourdier
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 [EMAIL PROTECTED]

 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 [EMAIL PROTECTED]
  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@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-26 Thread Ulrich Hertlein
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().

 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 [EMAIL PROTECTED]
 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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-26 Thread Vincent Bourdier
2008/9/26 Ulrich Hertlein [EMAIL PROTECTED]

 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 [EMAIL PROTECTED]
  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@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-26 Thread Ulrich Hertlein
Hi Vincent,

Vincent Bourdier wrote:
 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...

Yes it will never be reset by the cull traversal so you have to do that 
yourself e.g. just
before cull or maybe after you've read the cull state from your class.

Cheers,
/ulrich

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-26 Thread Vincent Bourdier
Hi,

I found an other solution using a vector to store the visible elements and
clearing this list each render loop. I is the more simple solution I think.

thanks for your help.
Regards,
   Vincent.

2008/9/26 Ulrich Hertlein [EMAIL PROTECTED]

 Hi Vincent,

 Vincent Bourdier wrote:
  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...

 Yes it will never be reset by the cull traversal so you have to do that
 yourself e.g. just
 before cull or maybe after you've read the cull state from your class.

 Cheers,
 /ulrich

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] cullcallback and visitor ?

2008-09-25 Thread Vincent Bourdier
Hi,

I'm looking at a way to determine if a node is visible (in the frustum) or
not.

I saw something about cullvisitor and isCulled()

But, I do not understand how to implement that visitor.

I saw a osg::Drawable::cullcallback ...
Do I have to make my callbak ingerit from this class ?
What operator do I have to define (operator()(node*, nodevisitor*) ) ?

thanks a lot.

Regards,
Vincent.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-25 Thread Vincent Bourdier
Hi Robert,

How is it possible to test directly against the view frustum ? manually ? or
is there a method still implemented ?
thanks.

Vincent.

2008/9/25 Robert Osfield [EMAIL PROTECTED]

 Hi Vincent,

 The ways to track whether a drawable or node is in the view frustum are:

  1) Attach a cull callback, if it get's called during the cull
 traversal then it hasn't been culled (yet).
  2) Traverse the rendering back data structures (RenderStage etc)
 after the cull traversal so see what drawables.
  3) Test the object in question directly against the view frustum.

 Robert.

 On Thu, Sep 25, 2008 at 4:15 PM, Vincent Bourdier
 [EMAIL PROTECTED] wrote:
  Hi,
 
  I'm looking at a way to determine if a node is visible (in the frustum)
 or
  not.
 
  I saw something about cullvisitor and isCulled()
 
  But, I do not understand how to implement that visitor.
 
  I saw a osg::Drawable::cullcallback ...
  Do I have to make my callbak ingerit from this class ?
  What operator do I have to define (operator()(node*, nodevisitor*) ) ?
 
  thanks a lot.
 
  Regards,
  Vincent.
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-25 Thread Robert Osfield
On Thu, Sep 25, 2008 at 4:23 PM, Vincent Bourdier
[EMAIL PROTECTED] wrote:
 Hi Robert,

 How is it possible to test directly against the view frustum ? manually ? or
 is there a method still implemented ?
 thanks.

You create an osg::Polytope from the Camera's view and projection
matrix which will be your frustum,  then transform by any transforms
in the parent path to place the frustum in local coordinate, then test
the objects bounding sphere/bound box against this frustum.  The
osgUtil::PolytopeVisitor does most of this so could learn a lot form
this.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-25 Thread Vincent Bourdier
Okay, it sound more complicated ...

Just to be sure :

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...)

Thanks,
Regards.
  Vincent

2008/9/25 Robert Osfield [EMAIL PROTECTED]

 On Thu, Sep 25, 2008 at 4:23 PM, Vincent Bourdier
 [EMAIL PROTECTED] wrote:
  Hi Robert,
 
  How is it possible to test directly against the view frustum ? manually ?
 or
  is there a method still implemented ?
  thanks.

 You create an osg::Polytope from the Camera's view and projection
 matrix which will be your frustum,  then transform by any transforms
 in the parent path to place the frustum in local coordinate, then test
 the objects bounding sphere/bound box against this frustum.  The
 osgUtil::PolytopeVisitor does most of this so could learn a lot form
 this.

 Robert.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-25 Thread Vincent Bourdier
So, ... it is not good :

I added my visitor on a drawable :

_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;
};


Nothing is return as cull state... the visitor seem do be visiting
nothing...

Any Idea ? experience ?

Thanks.

Regards,
Vincent.

2008/9/25 Vincent Bourdier [EMAIL PROTECTED]

 Okay, it sound more complicated ...

 Just to be sure :

 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...)

 Thanks,
 Regards.
   Vincent

 2008/9/25 Robert Osfield [EMAIL PROTECTED]

 On Thu, Sep 25, 2008 at 4:23 PM, Vincent Bourdier

 [EMAIL PROTECTED] wrote:
  Hi Robert,
 
  How is it possible to test directly against the view frustum ? manually
 ? or
  is there a method still implemented ?
  thanks.

 You create an osg::Polytope from the Camera's view and projection
 matrix which will be your frustum,  then transform by any transforms
 in the parent path to place the frustum in local coordinate, then test
 the objects bounding sphere/bound box against this frustum.  The
 osgUtil::PolytopeVisitor does most of this so could learn a lot form
 this.

 Robert.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] cullcallback and visitor ?

2008-09-25 Thread Ulrich Hertlein
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 [EMAIL PROTECTED]
 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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org