Hello Robert,

now, I use the osgUtil::IntersectionVisitor. The example was very
helpfully. But I have a new little problem. I get the first
intersection:

const osgUtil::LineSegmentIntersector::Intersection hit =
_ray->getFirstIntersection();

After this, I get the intersection point in world coordinates:

osg::Vec3 intersectionPoint = hit.getWorldIntersectPoint();

This vector is right. But the index list and the ratio list are empty.

// get the vertex indices.
const osgUtil::LineSegmentIntersector::Intersection::IndexList& indices
= hit.indexList;
// bary coords
const osgUtil::LineSegmentIntersector::Intersection::RatioList& ratios =
hit.ratioList;
if (indices.size()==3 && ratios.size()==3) // is always false
{
    // TO DO
}

What is my mistake? Have you an idea?

Cheers,

Martin



Am Freitag, den 19.06.2009, 15:18 +0100 schrieb Robert Osfield:

> Hi Martin,
> 
> I would recommend using the osgUtil::IntersectionVisitor rather than
> the osgUtil::IntersectVisitor as the later is deprecated and only kept
> around for backwards compatibility.
> 
> As for examples of getting the texture coords of a ray intersections
> have a look at the osgViewer::InteractiveImageHandler implementation
> in src/osgViewer/ViewerEventHandlers.cpp as it does just this.
> 
> Robert.
> 
> 2009/6/19 Großer Martin <[email protected]>:
> > Hello all,
> >
> > i use the intersectVisitor to get the intersection between a ray and a
> > geode. It works fine and I'm very happy, because it is very comfortable.
> > Now I have the point (vector) of intersection, but I need the triangle
> > of the drawable what I hit. I would like calculate the barycentric
> > coordinates of the point. With this coordinates I want to calculate the
> > texture coordinates of my intersection point.
> >
> > There are a comfortable way in osg? Or have anyone a idea for a nice
> > solution? I think the intersectVisitor find the triangle, but i can't
> > get this information.
> >
> >
> > Cheers
> >
> > Martin
> >
> > _______________________________________________
> > 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
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to