Author Topic: Collision detection problem  (Read 3316 times)

Offline ndr123

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Collision detection problem
« Reply #15 on: November 19, 2011, 12:01:33 pm »
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 :)
« Last Edit: November 19, 2011, 12:04:48 pm by ndr123 »

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Collision detection problem
« Reply #16 on: November 02, 2012, 12:27:49 pm »
[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.
« Last Edit: November 02, 2012, 01:18:35 pm by K24A3 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision detection problem
« Reply #17 on: November 02, 2012, 01:59:32 pm »
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.

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Collision detection problem
« Reply #18 on: November 02, 2012, 02:42:04 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision detection problem
« Reply #19 on: November 02, 2012, 02:49:38 pm »
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.

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Collision detection problem
« Reply #20 on: November 02, 2012, 02:51:45 pm »
Oh ok I'll adjust my code, thanks.

..update: works fine now.
« Last Edit: November 02, 2012, 02:54:45 pm by K24A3 »

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Collision detection problem
« Reply #21 on: November 02, 2012, 03:01:18 pm »
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

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Collision detection problem
« Reply #22 on: November 02, 2012, 03:24:36 pm »
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.
« Last Edit: November 02, 2012, 03:27:24 pm by K24A3 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision detection problem
« Reply #23 on: November 02, 2012, 05:39:14 pm »
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).

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Collision detection problem
« Reply #24 on: November 09, 2012, 02:34:40 am »
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.