Hi Martin,

The event picker doesn't take a nodemask to traverse like the nodevisitor, so 
it returns all hits - visible or not.
I made a small mod to the IntersectorVisitor to take a traversal mask and only 
visit those nodes with it set.

It needs a bit of cleaning up to meet OSG standards - I will post it later 
today.

Actually, since the IntersectionVisitor is a NodeVisitor, you can set a traversal mask on it. Just do:

  osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
      new osgUtil::LineSegmentIntersector( /*...*/ );

  osgUtil::IntersectionVisitor iv(intersector.get());
  iv.setTraversalMask(/* the mask we want it to use */);

  camera->accept(iv);

For example, if you have:

  osg::Node::NodeMask IS_VISIBLE_MASK = 0x1;

then if you don't want invisible nodes to be pickable do:

  iv.setTraversalMask(~IS_VISIBLE_MASK);

~ is the bitwise NOT operator, and ~IS_VISIBLE_MASK is the same as 0xFFFFFFFF & ~IS_VISIBLE_MASK . You could also make masks for both behaviors:

  osg::Node::NodeMask IS_VISIBLE_MASK = 0x1;
  osg::Node::NodeMask IS_PICKABLE_MASK = 0x2;

  // Pick nodes only if the IS_PICKABLE_MASK bit is set.
  iv.setTraversalMask(IS_PICKABLE_MASK);
  // See nodes only if the IS_VISIBLE_MASK bit is set.
  camera->setCullMask(IS_VISIBLE_MASK);              

Then setting a node's mask to 0x0 would make it not visible and not pickable, and you could have a node whose mask would be 0x1 to be visible but not pickable, and the opposite too.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to