Author Topic: How does the collision detection work  (Read 1236 times)

Offline luozi

  • byte
  • *
  • Posts: 20
    • View Profile
How does the collision detection work
« on: October 25, 2011, 03:56:22 am »
Hello everyone, recentlly I'm intrested  in the jpct. I find it is very convenient, but when I use the collison detection I met a strange problem.
I create two spheres, one big, one small. When the small one is outside the big one, the collison detection works well, the sphere stoped when collison took place. But when the small one is in the center of the big one the small sphere goes through the big one as if the collisione never. took place.Then I create a plane and both side work well. I'm wondering whether I set something wrong or not. Can anybody give me a help?

Offline AGP

  • quad
  • ******
  • Posts: 1638
    • View Profile
Re: How does the collision detection work
« Reply #1 on: October 25, 2011, 05:34:33 am »
I wonder if it considers the normals. Try flipping them and find out.

Offline AGP

  • quad
  • ******
  • Posts: 1638
    • View Profile
Re: How does the collision detection work
« Reply #2 on: October 25, 2011, 05:37:02 am »
By the way, to flip them you would call Object3D.invert().

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12011
    • View Profile
    • http://www.jpct.net
Re: How does the collision detection work
« Reply #3 on: October 25, 2011, 06:59:42 am »
You can't trigger a collision when colliding with back faces. Like AGP said, in that case you might have to invert the object (which in turn makes it invisible from the outside). If that's an issue, either use separate objects for both sides or, if this isn't needed for rendering, you the inverted one at least for collision detection and set it to invisible afterwards.

Offline luozi

  • byte
  • *
  • Posts: 20
    • View Profile
Re: How does the collision detection work
« Reply #4 on: October 25, 2011, 07:36:50 am »
Thank you very much ! I am so glad you reply my question, in our country's forum nobody does.
I think what you mean is that the  sphere has two faces, and the detection is only be detection when another object hit its front face. Am I right? If i'm right  what the difference between the two faces?Buy the way ,I am trying to translate the english jpct to chinese so that my classmates can make full use of the jpct. Thank you again.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12011
    • View Profile
    • http://www.jpct.net
Re: How does the collision detection work
« Reply #5 on: October 25, 2011, 08:26:04 am »
The difference is, that in the "front" case, the face normal points towards the collision source and in the back face case, it's pointing away. It the exact same thing as back face culling is.