Hi,
I have the code to do with LineSegmentIntersector, but I don't know how can I
get the IndexList and RatioList to do the same with PolytopeIntersector.
Code:
osg::Drawable* drawable = intersection.drawable.get();
osg::Geometry* geometry = drawable ? drawable->asGeometry() : 0;
osg::Vec3Array* vertices = geometry ?
dynamic_cast<osg::Vec3Array*>(geometry->getVertexArray()) : 0;
if (vertices)
{
// get the vertex indices.
const osgUtil::LineSegmentIntersector::Intersection::IndexList& indices =
intersection.indexList;
const osgUtil::LineSegmentIntersector::Intersection::RatioList& ratios =
intersection.ratioList;
if (indices.size()==3 && ratios.size()==3)
{
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::Array* texcoords = (geometry->getNumTexCoordArrays()>0) ?
geometry->getTexCoordArray(0) : 0;
osg::Vec2Array* texcoords_Vec2Array = dynamic_cast<osg::Vec2Array*>(texcoords);
if (texcoords_Vec2Array)
{
// we have tex coord array so now we can compute the final tex coord at the
point of intersection.
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;
}
}
Any idea????
Thank you!
Cheers,
Aitor
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=33375#33375
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org