Hi,
I want to let my user pick individual vertices on a model. I used the osgPick
example code to get the picking of an object working great, but when I tried to
use the code to pick the vertex it is not really working correctly, and I am
not sure what I am doing wrong. Here is the code I am using:
Code:
//Get the selected vertex.
const osgUtil::LineSegmentIntersector::Intersection::IndexList& vil =
hitr->indexList;
osg::Geometry *osgGeom = dynamic_cast<osg::Geometry *>(hitr->drawable.get());
if(vil.size() > 0 && osgGeom)
{
osg::ref_ptr<osg::Vec3Array> aryVert =
dynamic_cast<osg::Vec3Array*>(osgGeom->getVertexArray());
int iSelVert = vil[0];
m_vSelectedVertex = (*aryVert)[iSelVert];
}
else
m_vSelectedVertex.set(0, 0, 0);
I assumed that the index list that is returned back would be of the index of
vertices sorted by the closest vertex. When I tested this though it sometimes
gave me the same number even when I clicked different vertices. It was always
three numbers in the index list as well. Not sure why. Is there anyone out
there who can clear up exactly what the index list is returning to me, and how
I can use that to get the vertex that was clicked on?
Thank you!
Cheers,
David[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=40752#40752
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org