How to have accurate collision detection?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
shingoshing
Posts: 5
Joined: Tue Jan 22, 2008 5:27 am

How to have accurate collision detection?

Post 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())
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post 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.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

I think you're looking for ragdoll technique.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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.
Image Image Image
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

JP wrote:by having bounding boxes for each individual part of the model and checking against those.
How can that be done?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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.... :?
Image Image Image
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post 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:
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post 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.
shingoshing
Posts: 5
Joined: Tue Jan 22, 2008 5:27 am

Post 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
Auradrummer
Posts: 260
Joined: Thu Apr 17, 2008 1:38 pm
Location: Brasopolis - Brazil

Post 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?
Professional Software Developer and Amateur Game Designer ;-)
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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!
Image Image Image
wuallen
Posts: 67
Joined: Thu Jan 25, 2007 3:07 am
Location: Shanghai

Post 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.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Patch it, patch iiiiiit.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Post 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.
Post Reply