[osg-users] intersection tests

Julien Valentin julienvalentin51 at gmail.com
Sat Feb 18 12:33:46 PST 2017


Hi nick
At first glance, I don't see any problem with your code...
If you just want to code a mousepicker
osgViewer::View::computeIntersections(screenx,screeny,outintersections))
 would fit your needs.

Code:
// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler
{
public:
bool PickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
    switch(ea.getEventType())
    {
    case(osgGA::GUIEventAdapter::DOUBLECLICK):
    {
        osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
        if (view){
osgUtil::LineSegmentIntersector::Intersections inter;
if(view->computeIntersections(ea.getX(),ea.gety(),inter){
...blablabla...
}
}
}




Perhaps you should try it before debugging deeper

Further, I would recommend the polytopeintersector for general purpose picking (it works for points primitives too)

Hope it helps


Cheers



Trajce Nikolov NICK wrote:
> It has to do with MatrixTransforms and probably the IntersectionVisitor. I had my scene rotated a bit and it was buggy. With identity matrix on top works well ... Trying to debug if I can find something
> 
> On Thu, Feb 16, 2017 at 8:31 PM, Trajce Nikolov NICK < ()> wrote:
> 
> > Hi Community,
> > 
> > I am experiencing some bad results from various intersection tests. I have a database with buildings and for some reason the intersection tests are failing to get me the roofs of the buildings ...
> > 
> > 
> > Here some snippets of my tries:
> > 
> > 
> > http://pastebin.com/s7aZk8wA (http://pastebin.com/s7aZk8wA)
> > 
> > http://pastebin.com/1s99SGZc (http://pastebin.com/1s99SGZc)
> > 
> > http://pastebin.com/UtkqPRce (http://pastebin.com/UtkqPRce)
> > 
> > 
> > 
> > What I am missing here?
> > 
> > 
> > Thanks for every hint as always!
> > Cheers!
> > 
> > -- 
> > trajce nikolov nick
> > 
> > 
> > 
> > 
> 
> 
> 
> 
> -- 
> trajce nikolov nick
> 
>  ------------------
> Post generated by Mail2Forum


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70269#70269








More information about the osg-users mailing list