Collision detection, need some help

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.
Post Reply
utunnels
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm

Collision detection, need some help

Post by utunnels »

I'm trying to figure out, is there an easy way to test if a mesh intersects with another, like you do with a aabbox class.

Do I need to create triangle selectors? I also need to get the center point of the collision.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collision detection, need some help

Post by CuteAlien »

That's pretty much what Irrlicht does offer when it comes to collision handling: http://irrlicht.sourceforge.net/docu/cl ... nager.html
You can see there which functions need an ITriangleSelector. The collision animator in Irrlicht just uses those functions.

So no - exact mesh-vs-mesh collisions are not offered. I think I discussed a little more about this in the forum once with some ideas how to implement that, but the most important part is that when you are doing games you don't need that. At least not yet, maybe some day it will change, but for now pretty much every game uses the same trick and uses simpler forms like boxes or spheres or ellipsoids around the real model and does collide with those. Real mesh-vs-mesh collision is still rather expensive (although it might work by now by using a very simplified collision model, so maybe some games already do that). And the ellipsoid/bounding box solutions just turned out to be good enough to be accepted by players so far.

If you really want mesh-vs-mesh (for example because you want to advance the state of the art or because you are not doing a game) then I think the best solution for now is using a collision library, I think every physics engine has one of those included.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
utunnels
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm

Re: Collision detection, need some help

Post by utunnels »

Thank you. I'll take a look at that.
Yeah, I think I'll try bbox method instead.

I have another question, if I'm making a platformer type game, do I need to call createCollisionResponseAnimator method of the scene manager for every objet?

Code: Select all

 
    anim = smgr->createCollisionResponseAnimator(terrainTriangleSelector, objectNode1);
    objectNode1->addAnimator(anim);
 
    anim = smgr->createCollisionResponseAnimator(terrainTriangleSelector, objectNode2);
    objectNode2->addAnimator(anim);
 
    anim = smgr->createCollisionResponseAnimator(terrainTriangleSelector, objectNode3);
    objectNode3->addAnimator(anim);
 
  ....
 
I'm sort of confused width multiple animators.

What if there are multiple platforms? Do I also need to create multiple triangle selectors?
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Collision detection, need some help

Post by Mel »

cloth simulations need mesh vs mesh collisions, for instance.

But for a character moving for an scenario, you only need a triangle selector for the scenario, and all the other moving objects (characters and such) can use a collision response animator. So, answering your question, yes, you would need a collision response animator for each object you want to collide with the stage.
Last edited by Mel on Wed Sep 26, 2012 8:39 am, edited 1 time in total.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
utunnels
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm

Re: Collision detection, need some help

Post by utunnels »

Thank you Mel.
So the engine actually uses bounding box of the scene node to do collision detection, right?
I think that is sufficient for me.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collision detection, need some help

Post by CuteAlien »

The collision animator is using ISceneCollisionManager::getCollisionResultPosition, so it is using an ellipsoid. For typical shooter-controls that usually works better.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply