Author Topic: collision detection  (Read 2314 times)

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
collision detection
« on: March 24, 2011, 07:59:03 am »
hello, i can use collision detection elipsoid but when 2 animated character models touch each other the game becomes really low fps.  Is there any way to prevent this?
Is there a way to make it so their physical collision box will act like a cube or something instead of their actual model?
Or do I need to use ray-polygon and prevent the characters from touching each other?  Also, if that is the case, does ray polygon function different than elipsoid, because for some reason ray polygon lets me walk through some walls that elipsoid does not let me walk through. 
« Last Edit: March 24, 2011, 08:05:00 am by Disastorm »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: collision detection
« Reply #1 on: March 24, 2011, 07:48:00 pm »
What's the polygon count of these models? jPCT's collision detection is always primitive (ray, sphere or ellipsoid) against polygons but that doesn't mean that it has to happen against the actual model's polygons. I'm usually using "collision objects" instead. They act as placeholders for the real models and i toggle visibility between them and the real models before and after collision detection, so that the rendering uses the real models while the collision detection uses the simpler collision objects. Another, more MVC oriented,  option is to do the collision detection in a completely different world consisting of collision models only.

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: collision detection
« Reply #2 on: March 24, 2011, 11:30:45 pm »
I'm not sure on the count, I downloaded them from the internet, but anyway thanks for the good idea.  So do I make a new object and add a child and set visibility to false?  Actually which one should I make the child, the visible one?  What do you mean toggle visibility before and after collision detection, what is the reason to toggle it back and forth? Cant you just have it invisible forever and use those as the collision object while the visible models are set to Collision None .

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: collision detection
« Reply #3 on: March 25, 2011, 06:17:50 am »
Invisible objects don't trigger collisions regardless of their collision mode...

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: collision detection
« Reply #4 on: March 26, 2011, 01:32:23 am »
oh ok i didnt know that.  Ill try out your method.
« Last Edit: March 26, 2011, 01:33:56 am by Disastorm »

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: collision detection
« Reply #5 on: March 26, 2011, 06:23:18 am »
Hey do u have to do collision detection in same thread as translations?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: collision detection
« Reply #6 on: March 26, 2011, 08:37:10 am »
Yes, of course. Otherwise, your detection will be based on a crazy mix of data.

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: collision detection
« Reply #7 on: March 28, 2011, 08:52:14 am »
Hello, when i make the collisionModels if i use a primitive, how do I know what scale and height to make the primitive.  Is there a way I can get the height and width of the model.  Also, there is no way to make a rectangle or other primitive using the dimensions  instead of height and scale?

*edit actually i guess thinking about it, best thing to do is probably just make a custom collision version of each model to be most accurate?
« Last Edit: March 28, 2011, 09:39:09 am by Disastorm »

Offline Kaiidyn

  • long
  • ***
  • Posts: 103
    • View Profile
Re: collision detection
« Reply #8 on: March 28, 2011, 01:21:07 pm »
if i remember correctly, object3d has something like getboundingbox or something, maybe you could use this?
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: collision detection
« Reply #9 on: March 28, 2011, 01:38:30 pm »
if i remember correctly, object3d has something like getboundingbox or something, maybe you could use this?
The Mesh of an Object3D has that method. It returns the bb-coordinates in object space, you can simply derive the size in all three dimensions from these values.

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: collision detection
« Reply #10 on: March 29, 2011, 12:40:52 am »
Is there a way to make a primitive with the dimensions from the bounding box? the primitive methods seem to just have scales?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: collision detection
« Reply #11 on: March 29, 2011, 08:08:13 am »
No, you have to figure out the correct correlation between bb and scaling of the primitives for yourself. It might help to render the "collision world" on top of the real one to see if they match.