Hi Martin, A perplexing result for which I have no answer.
Robert. 2009/6/22 Großer Martin <[email protected]>: > Hello Robert, > > I dig into the LineSegmentIntersector code and I found the lines 391 - 399: > > if (geometry) // it is true > { > osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*> > (geometry->getVertexArray()); > > if (vertices) // it is always false > { > osg::Vec3* first = &(vertices->front()); > if (triHit._v1) > { > hit.indexList.push_back(triHit._v1-first); > hit.ratioList.push_back(triHit._r1); > } > > [...] > > "if (vertices)" is always false, but the geometry has a vertices. In my > application I wrote the following code: > > const osgUtil::LineSegmentIntersector::Intersection hit = > _ray->getFirstIntersection(); > ::osg::Drawable* drawable = hit.drawable.get(); > ::osg::Geometry* geometry = drawable ? drawable->asGeometry() : 0; > ::osg::Vec3Array* vertices = geometry ? dynamic_cast< > ::osg::Vec3Array*>(geometry->getVertexArray()) : 0; > > Here is the test "if (vertices)" true. It is for me irreproducible. There > are not the same geometries with the same vertices in the > LineSegementIntersector and in my > > Cheers, > > > Martin > > > > Am Montag, den 22.06.2009, 08:53 +0100 schrieb Robert Osfield: > > Hi Martin, > > You'll need to dig into the LineSegmentIntersector code to answer this > question. > > Robert. > > 2009/6/22 Großer Martin <[email protected]>: >> 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 >> >> > _______________________________________________ > 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

