Hi Martin,

Something really odd is going on your system.  It kinda looks like a
compiler bug or a build error.  I have g++ 4.3.3 on my Kubuntu system.

It might be useful to put together an example code that illustrate
this problem in way that others (like myself) can pick up and
reproduce the same error as your seeing.

Robert.

2009/6/22 Großer Martin <grosser.mar...@gmx.de>:
> Hello Robert,
>
> i find out something. I try to print out the adress of the geometry
> object and the vertices like the following lines:
>
> std::cout << "Adresse Geometry: " << &(*geometry) << std::endl;
> std::cout << "Adresse Vertices: " << &(*vertices) << std::endl;
>
> The result was...
>
> In LineSegmentIntersector:
> ---------------------------
>        Adresse Geometry: 0x90de2f8
>        Adresse Vertices: 0
>
> In my application:
> ---------------------------
>        Adresse Geometry: 0x90de2f8
>        Adresse Vertices: 0x90df848
>
> Also my idea was, the cast is faild. Now, I change the dynamic_cast to
> the reinterpret_cast and now it works fine!
>
> I use Fedora10 and the gcc compiler version 4.3.1.
>
> Cheers,
>
> Martin
>
>
> Am Montag, den 22.06.2009, 13:33 +0100 schrieb Robert Osfield:
>> Hi Martin,
>>
>> A perplexing result for which I have no answer.
>>
>> Robert.
>>
>> 2009/6/22 Großer Martin <grosser.mar...@gmx.de>:
>> > 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 <grosser.mar...@gmx.de>:
>> >> 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 <grosser.mar...@gmx.de>:
>> >>> 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
>> >>> 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
>> >>
>> >> _______________________________________________
>> >> 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
>> >
>> > _______________________________________________
>> > 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
>
> _______________________________________________
> 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