Page 1 of 2

How to have accurate collision detection?

Posted: Thu Apr 17, 2008 2:11 am
by shingoshing
Hi,

I have searched through the forum for a long time, but I don't quite get the exact solution to have an accurate collision detection between two SceneNodes.

Here's the problem:
Image
The required collision detection is between the dagger and the alien. However, if I use the bounding box to check it, it is not accurate enough.

I've also tried to use the Bullet Physics Engine. But it doesn't seem to support the IAnimatedMeshSceneNode at all. So how should I solve it?

Thanks a lot!


Code of loading alien:
irr::scene::IAnimatedMesh *mesh = gl_data.smgr->getMesh("./media/char/alien.b3d");
alienNode = gl_data.smgr->addAnimatedMeshSceneNode(mesh);
Code of collision detection:
daggerNode->getTransformedBoundingBox().intersectsWithBox(alienNode->getTransformedBoundingBox())

Posted: Thu Apr 17, 2008 3:12 am
by Ion Dune
Maybe make a selector from the alien, and then either use an ellipse or a line to represent the knife? This might be kind of slow with a high poly mesh (which it looks like you have) though... Perhaps you could make boxes around bones you have (if you're using them) and then check the knife with all of those.

Posted: Thu Apr 17, 2008 7:08 am
by MasterGod
I think you're looking for ragdoll technique.

Posted: Thu Apr 17, 2008 7:15 am
by JP
Well not exactly ragdoll technique as that really applies to the physics behind making a series of physics objects connected together, generally forming a skeleton of a human, basically go limp.

But it's the same sort of thing as you'd do with ragdolls, what Ion Dune suggested, by having bounding boxes for each individual part of the model and checking against those.

Posted: Thu Apr 17, 2008 12:54 pm
by MasterGod
JP wrote:by having bounding boxes for each individual part of the model and checking against those.
How can that be done?

Posted: Thu Apr 17, 2008 1:04 pm
by JP
Ion Dune wrote:Perhaps you could make boxes around bones you have (if you're using them) and then check the knife with all of those.
Exactly the same way ragdolls are done... which is what you suggested yourself.... :?

Posted: Thu Apr 17, 2008 1:18 pm
by MasterGod
lol, I only know that there is a technique named ragdoll to do such things but I have no idea how it is being done :wink:

Posted: Thu Apr 17, 2008 4:08 pm
by rogerborg
However you do it, using Irrlicht or a 3rd person engine, you'll need to get a bunch of triangles representing the current animation frame of the mesh.

If you're not using a skinned/skeletal mesh, then you can call IAnimatedMesh::getMesh(x) to get an IMesh, then create a triangle selector from it (and then use e.g. ISceneCollisionManager::getCollisionPoint()). It's inefficient - in that it re-allocs memory every time you create a selector - but there's currently no better method available.

If you're using new skeletal meshes, then you're pretty much boned (pun intended) as getMesh(x) currently isn't working for them.

Posted: Thu Apr 17, 2008 8:01 pm
by sio2
Get the bone matrices. Transform per-bodypart bounding boxes/spheres/whatever. You can use mesh/triangles but it will be a lot slower.

Posted: Thu Apr 17, 2008 10:06 pm
by shingoshing
Thanks a lot for your replies. Now I have some ideas of how to make the collision detection to be more accurate.

And I'm now trying to draw the line to get the collision point with the triangle selector of the alien. I will try to think about it carefully first.

Thanks again for your suggestions :D

Posted: Fri Apr 18, 2008 12:40 am
by Auradrummer
Hi all,
I'm using my free time (I'm stuck with the beginning of my project) to read forum posts and learn more.

I had one idea, don't know if it is good: If you build an invisible alien copy only with bounding boxes and uses the same function to animate it, you could detect the collision on it, right?

Posted: Fri Apr 18, 2008 8:15 am
by JP
Yeah that would work too, that's sort of what i've done in my game for static meshes, make the physics collision boxes from a much lower poly mesh which is basically just a load of bounding boxes. This is often how it's done in the industry i believe as you don't need high poly for collision, just the basic shape.

And yeah i guess it would apply to animated models as well, if the very low poly version of your character was animated in exactly the same way then it should match up nicely.

But i guess the animation would have to be done in a modelling program rather than irrlicht.... it's basically the same thing as doing the way i initially mentioned, but apparently that won't currently work in irrlicht, but this way should!

Posted: Tue Jul 15, 2008 2:40 am
by wuallen
It is lucky to see this discussion.

I agree mastergod -- we need a ragdoll technology.

I have been looking for a triangle collision method for animated mesh for a while and it make me upset very much. But now I realize that I don't need it. We should attach each bone with a rigid geometric shape. This is the charming feature of the bone animation. So we can punch our enemy flying against the wall, and it crashes the wall.

I also think we can get the static mesh of animated skinned mesh, because every time we draw it, the mesh has been built in the buffer. We just get them out of that buffer.

Posted: Tue Jul 15, 2008 7:37 am
by rogerborg
Patch it, patch iiiiiit.

Posted: Fri Nov 07, 2008 12:24 pm
by Adversus
Attach bounding spheres or boxes to some of the bones of the skin, as the bones move so will the spheres.

This is how we've done it on all the games I've worked on.