Hi,

The Intersector return a osgUtil::LineSegmentIntersector::Intersections.

For each intersection, you have a nodePath, an intersection point (
getWorldIntersectPoint() ) and a normal ( getWorldIntersectNormal() ).

Now, if you know the vector of the object movement, and the normal of the
intersection, you can compute the reaction using the law of reflexion. (i.e
The angle between the incident vector and the normal to the intersected
surface is equal to the angle between the normal and the reaction vector )

You get the normal, the vector of incidence and the intersection point to
know where you intersect in the scene.
The rest is just some maths.

Hope this is more clear.

Regards,
   Vincent.

2009/7/24 Brett Thomas Lee <[email protected]>

>
> Vincent.B wrote:
> > Hi,
> >
> > Using the intersector nodepath, normal and intersection point, you can
> compute the reaction to a collision.
> >
> > Vincent.
> >
> > 2009/7/23 Jean-Sébastien Guay < ()>
> >
> > > Hi Brett,
> > >
> > >
> > > >  I found intersection of  a line segment with a triangle mesh using
> intersection visitor in osg.But I dont want the line segment to penetrate
> into the triangle mesh.Can someone help me in doing this using osg please.
> > > >
> > >
> > >
> > > OSG is not a collision detection library, it's a graphics library.
> Intersection testing in OSG exists primarily for user interaction, for
> example picking an object. If you want something more involved than that,
> you'd be better off using a physics/collision detection library.
> > >
> > > Note that if all you want is to find the length of the line segment
> that touches the first geometry, you can get the first intersection returned
> by the intersection visitor. In that data structure there is a ratio
> variable, that is the ratio of where the intersection occured between the
> start and end of your original segment. So for example:
> > >
> > >  osg::Vec3 start(0,0,0);
> > >  osg::Vec3 end(0,10000,0);
> > >
> > >  osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
> > >      new osgUtil::LineSegmentIntersector( start, end );
> > >  osgUtil::IntersectionVisitor iv(intersector.get());
> > >
> > >  viewer->getCamera()->accept(iv);
> > >
> > >  osgUtil::LineSegmentIntersector::Intersections& intersections =
> > >      intersector->getIntersections();
> > >
> > >  // First intersection:
> > >  osgUtil::LineSegmentIntersector::Intersection firstHit =
> > >      intersections.front();
> > >
> > >  // This is easy since we know our ray was along the Y axis:
> > >  double distance = (end.y() - start.y()) * firstHit.ratio;
> > >
> > >  // Or if the ray could be in any direction:
> > >  // Vector from start to hit point
> > >  osg::Vec3 hitVec = (end - start) * ratio;
> > >  double distance2 = hitVec.length();
> > >
> > > Hope this helps,
> > >
> > > J-S
> > > --
> > > ______________________________________________________
> > > Jean-Sebastien Guay     ()
> > >                               http://www.cm-labs.com/ (
> http://www.cm-labs.com/)
> > >                        http://whitestar02.webhop.org/ (
> http://whitestar02.webhop.org/)
> > >
> > > _______________________________________________
> > > osg-users mailing list
> > >  ()
> > >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org(
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > >
> > >
> > >
> >
> >
> >  ------------------
> > Post generated by Mail2Forum
>
>
>
> Can you please give a more detailed description please sir.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=15324#15324
>
>
>
>
>
> _______________________________________________
> 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