Hi Gianni,
very briefly for triangle based geometry with VBO:
osgUtil::LineSegmentIntersector::Intersections intersections;
if (computeIntersections(view, ea, intersections) )
{
const osgUtil::LineSegmentIntersector::Intersection&
intersection = *(intersections.begin());
osg::Drawable* drawable = intersection.drawable.get();
osg::Geometry* geometry = drawable ? drawable->asGeometry() : 0;
osg::Vec3Array* vertices = geometry ?
dynamic_cast<osg::Vec3Array*>(geometry->getVertexArray()) : 0;
....
const osgUtil::LineSegmentIntersector::Intersection::IndexList&
indices = intersection.indexList;
const
osgUtil::LineSegmentIntersector::Intersection::RatioList& ratios =
intersection.ratioList;
....
}
With indices you can get the vertices/texture coordinates by accessing
the geometry vertexArrary/texCoordArray etc.
The ratio will give you the barycentric ratios. They can be used for the
interpolation on the triangle, or to determine the "nearest" vertex in
you case
unsigned int i1 = indices[0];
unsigned int i2 = indices[1];
unsigned int i3 = indices[2];
float r1 = ratios[0];
float r2 = ratios[1];
float r3 = ratios[2];
osg::Vec2 tc1 = (*texcoords_Vec2Array)[i1];
osg::Vec2 tc2 = (*texcoords_Vec2Array)[i2];
osg::Vec2 tc3 = (*texcoords_Vec2Array)[i3];
osg::Vec2 tc = tc1*r1 + tc2*r2 + tc3*r3;
Hope that helps.
Hi Sebastian,
thank you very much for your hint. I will give a look at the
LineSegIntersector.
Cheers,
Gianni
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=61972#61972
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org