Hi Aitor,

The PolytopeIntersector doesn't record this information, and one could
interpret intersections with a polytope in many ways, certainly
nothing a simple as a index and ratio like you can with a line or
planar intersection.

Intersecting a mesh with a polytope is very different than with a line
segment, you can't just apply the same expectations, just have think
about it, there isn't one intersection point when a triangle
intersects a polytope, you simply can't suddenly apply a point
intersection style approach.

Robert.

On Wed, Nov 3, 2010 at 11:21 AM, Aitor Ardanza <aitoralt...@terra.es> wrote:
> 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
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to