Hi,
I am having a anyoing issue that i cannot figure out. Ive seen some post about
similar issue but with no defenit fix. I writing a picker code to know the
vertices of my object when i click in it following faitfully the example in
picking in the samples, however, getFirstIntersection() is causing and
exception when it returns from the pick function. the call stack shows that is
trying to delete a vector in the ~Intersection() destructor.
I have both OSG 3.0.1 and OSG 2.8.5 sorce and have build them in VS(2008). Ive
seen coments that this could be an issue related to code generation
Debug/Release not matching the OSG generation which is usually MT debug DLL.
Ive tried every generation on my code and on OSG itself (matching them of
course) but they still gives the issue. the strange thing is that the samples
does not have this problem of exception. Could it be a Compiler setting?
sorry for any misunderstanding. This is the first time im posting in this forum.
i would appreciate any help
Code:
Void PickHandler::pick(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer*
viewer)
{
osg::Node* scene = viewer->getSceneData();
if(!scene) return;
osg::Node* node = 0;
osg::Group* parent = 0;
//Our ray that
osgUtil::LineSegmentIntersector* picker;
// use window coordinates
// remap the mouse x,y into viewport coordinates.
osg::Viewport* viewport = viewer->getCamera()->getViewport();
Real mx = viewport->x() +
(Int)((Real)viewport->width()*(ea.getXnormalized()*0.5f+0.5f));
Real my = viewport->y() +
(Int)((Real)viewport->height()*(ea.getYnormalized()*0.5f+0.5f));
picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::WINDOW,
mx, my);
//InteresectionVisitor is used to testing for intersections with the scene?
osgUtil::IntersectionVisitor iv(picker);
viewer->getCamera()->accept(iv);
if(picker->containsIntersections())
{
Real x,y,z;
[b]osgUtil::LineSegmentIntersector::Intersection intersection =
picker->getFirstIntersection();[/b]
x = intersection.getLocalIntersectPoint().x();
y = intersection.getLocalIntersectPoint().y();
z = intersection.getLocalIntersectPoint().z();
osg::NodePath& nodePath = intersection.nodePath;
node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
parent =
(nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;
char text[256];
sprintf(text,"intersection-> x:%f y:%f z:%f\n Hits: %s, nodePath size:
%d",x,y,z,node->className(),nodePath.size());
::MessageBox(NULL,text,"",MB_OK);
}
}
Thank you!
Cheers,
Renato
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45555#45555
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org