Intersection without bounding object [solved]

Hello,

i have a little program (game) - motocycle race. I have track as a OBJ file as well as motorbike. Its there some way to check if motorbike is on road without doing intersection stuff (boundig box etc…)? Because I have track as a whole object, therfore i cant use bounding box on it. Thanks a lot!



EDIT: problem solved: with use hasTriangleCollision method of TriMesh object;)

You can go one step further and check for triangle collision. I think one common step in your problem is to pick a ray from your motorcylcle down and see if there is a triangle collision with the track.



Something like this:



   
// nevertheless you need a boundingvolume
track.setModelBound(new BoundingBox());
track.updateModel();
....

// make sure the worldcoords of the motorcycle are uptodate
              motorcycle.updateGeometricState(0,true);
// place ray at position of the motorcycle with direction down
       Ray r = new Ray(motorcycle.getWorldTranslation(),new Vector3f(0,-1,0));
// this will hold the result of the pick-test (if using this more than once you have to call clear() or so
      TrianglePickResults tpr = new TrianglePickResults();
// test if the ray intersects the track and write the result(s) in tpr
      track.findPick(r, tpr);
// check if there is a result. (but you also have to checkif really a triangle is hit!!!
      if (tpr.getNumber()>0 && tpr.getPickData(0).getTargetTris().size()>0)
      {
         System.out.println("on road");
      }
      else
      {
         System.out.println("not on road");
      }



Didn't test that now, but this should be the right direction. Have a look at the pick-examples (TestPick in jmetest intersection)

Hope that helped

EDIT: ARG,...you found the sollution on your own! Even better...good job

thanks a lot even thought :wink: