Collision detection problem

Started by ndr123, November 08, 2011, 06:04:57 PM

Previous topic - Next topic

ndr123

#15
While doing other test with my application, the checkforcollisoinspherical suddenly started working. I don't know what can be the matter cause I didn't change anything in the way I check for collisions nor in the way collisions flags on the objects are set. Anyway, as the checkforcollisionspherical needs a much higher value of collideoffset respect to the checkforcollisionellipsoid (with checkforcollisionspherical I need a collideoffset of 100 while with checkforcollisionellipsoid a value of 5 is enought to make everything work fine), using the latter results in higher framerate so I'm using the second. Thanks for the help :)

K24A3

#16
[edit] no worries I got collision working with the ellipse method rather than spherical...

But the returned SimpleVector is not returning the corrected point in space. The object is getting stuck below the floor for some reason. I'll keep on persisting.

EgonOlsen

I'm not sure how your post relates to the thread above...but anyway. The returned SimpleVector is the corrected translation vector, not the endpoint of the translation.

K24A3

Ok so the returned SV is the position in world space placing the object just before the point of collision. But for some reason it's placing the object ahead of the collision point within the collided object. Maybe it's my code.. I'll double check it.

ps. I was trying to get checkforcollisoinspherical working but had no luck hence why I posted here. Only 1 or 2 out of 50 sphere's were detecting collision despite various collideOffset values.

EgonOlsen

No. It's a TRANSLATION vector, not a POSITION vector. You have to add it to the current position to get the final position. Just as you would with a normal, not corrected translation vector.

K24A3

#20
Oh ok I'll adjust my code, thanks.

..update: works fine now.

K24A3

New issue, the objects seem to center to 0,0,0 when I add the returned SV.

                float fTest = 25f;
      SimpleVector vcoll = null;
      //vcoll = obj3D.checkForCollisionSpherical(svPos, 5f);
      vcoll = obj3D.checkForCollisionEllipsoid(svPos, new SimpleVector(fTest,fTest,fTest), 1);
      
      // Was there a collision?
      if(vcoll.equals(svPos)==false)
      {
         svPos.add(vcoll); 
         Global.Debug("COLLISION");
         svMomentum.y = -50;
         //svMomentum.y = -svMomentum.y;
      }
      else
      {
         svPos.set(vcoll);
      }


The objects are simply moving vertically to a floor with no X and Z movement.. trying to figure out why the X and Z translation is centering to 0,0,0

K24A3

#22
The X and Z values returned have significant values from -9 to 9 which is odd since the object is not being moved at all in the x and Z axis. I assume the ellipsoid calculations are adding X and Z movement since ellipsoids are rounded despite the difference between the current translation and the new position being purely vertical on the Y axis?

If that's how it works then that's fine I can adjust the code to ignore X and Z values if need be.

EgonOlsen

What?... ??? Sorry, but i don't get it, especially the part with the "centering"... If you use ellipsoid collision detection, you should make sure that your ellipsoid doesn't intersect with any geometry before calling one of these methods. If it does, it might move you out of the collision if you are lucky or you'll stuck (more likely).

K24A3

Not sure why all the objects are moving to 0,0,0 as a result of the collision, I'll use cubes instead and add some more debugging output to see what's going on.