collision detection

Started by Disastorm, March 24, 2011, 07:59:03 AM

Previous topic - Next topic

Disastorm

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. 

EgonOlsen

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.

Disastorm

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 .

EgonOlsen

Invisible objects don't trigger collisions regardless of their collision mode...

Disastorm

#4
oh ok i didnt know that.  Ill try out your method.

Disastorm

Hey do u have to do collision detection in same thread as translations?

EgonOlsen

Yes, of course. Otherwise, your detection will be based on a crazy mix of data.

Disastorm

#7
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?

Kaiidyn

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

EgonOlsen

Quote from: Kaiidyn on March 28, 2011, 01:21:07 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.

Disastorm

Is there a way to make a primitive with the dimensions from the bounding box? the primitive methods seem to just have scales?

EgonOlsen

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.