Problem with simple collision detection

I’ve a problem when I tried to detect collsion between my two 3ds models.

I modified TestCollision.java from







to









as you can see, I replaced the boxes with my models

the problem is when I did that, it will always print “Collision: Yes”



my assumption is I didn’t call updateModelBound() yet but this is also a problem.

because the type of my models are Spatial not Geometry. It doesn’t have the function so I can’t call it.



Note:

all of my models have their own bounding box

jbr.setProperty("bound", "box");


I've also tried ("bound", "obb") instead, but I got the same result.

and this is how I detect collision (same as the TestCollision.java)

      results.clear();
      n1.calculateCollisions(scene, results);
      
      if(n1.hasCollision(scene, false)) {
         System.out.println("hasCollision also reports true");
      }



any help would be much appreciated

Hmm, my guess (only a guess) is that the internals are colliding with themselves…  can you calc collisions with n2 instead of scene as a check?

I believe Renanse is correct here. The Test you modified is pretty simple. Add 2 boxes and see if ANYTHING collides, if so, then it must be the two boxes (that's all that is in the scene). If anything in the scene collides print Collision: YES.



Your models are made up of multiple parts, so those parts are colliding. So you'll either have to reduce your collision check from scene to the second model node, or evaluate the results object and see what was hit, if it's part of the same model ignore it.

WoW!  :smiley:

thanks you renanse and mojomonk, I got it.