Collision detection on animated mesh

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
pir
Posts: 24
Joined: Wed Apr 29, 2009 8:15 pm

Collision detection on animated mesh

Post by pir »

Hi!

I can't find any information about how to setup a selector on an animated mesh. I've tried to use ISceneManager::createTriangleSelector(). But the collision is only registered at the start pose of the mesh. How do I create a selector that do collision detection on the active pose of the mesh animation?
Do I need to create a new triangleSelector every time the mesh is changed by the joints? Or is there some way I can update my selector when the mesh is changed by the joints?


I've searched the forum for questions on this, but can't find any and I can't find any demos. Please tell me if my question is unclear or there are any relevant posts I've missed.

BR
pir
thatdudeoverthere
Posts: 28
Joined: Fri Apr 24, 2009 2:43 pm
Location: over there...

Post by thatdudeoverthere »

i think irrlicht can't do the generic tutorial example selector for animated nodes (so don't flame me.... not the face :shock:) but try for example

Code: Select all

IAnimatedMeshSceneNode* node=0; //example node
node = scene_manager->addAnimatedMeshSceneNode("mesh"); //mesh of your choice...
ITriangleSelector* selector=0;

selector = scene_manager->createTriangleSelectorFromBoundingBox(node);

hope this helps :)
//Personal code

bool sarcasm;

void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
pir
Posts: 24
Joined: Wed Apr 29, 2009 8:15 pm

Post by pir »

Thanks for yout answer. Your suggestion works. I've tried it before. But I need to use triangle selectoin instead of bounding box selection. The bounding box selection works for the animation, but not the triangle selection.

The temporary solution I've done is to drop the triangle selection and recreate it after every animation update. But I can't understand why the triangle selection doesn't work the same way as the bounding box selection.
JaSK
Posts: 3
Joined: Thu Aug 13, 2009 2:40 pm

Post by JaSK »

bump because I have the same problem...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Just use the usual triangle selector. It works for animated meshes as well. Please check example 7.
JaSK
Posts: 3
Joined: Thu Aug 13, 2009 2:40 pm

Post by JaSK »

no idea why, but it doesn't work.

just as pir and thatdude say: if I do createtriangleselectorfromboundingbox it indeed updates, but not if I use the regular createtriangleselector(animatedmeshscenenode).

a bounding box is not good enough for me, so what I'm currently doing is:
- check if I'm sorta close to the object on which collision detection is to be performed
- if I am, remove its triangle selector and create a new one every frame.
CuteAlien
Admin
Posts: 9694
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Ok, this is a little irritating as the documentation says "Call ITriangleSelector::update() to have the triangle selector updated based on the current frame of the animated mesh scene node. " - but as far as I can see this is not necessary. Instead the triangleselector seems to check whenever you ask for it's triangles if it is up-to-date.

So basically - it should work already (as hybrid mentioned - check example 07 which works with animated nodes).

Maybe you call the wrong createTriangleSelector - there is one for a mesh+node and one for IAnimatedMeshSceneNode - you need the latter. So make sure the pointer you pass is really IAnimatedMeshSceneNode *.

And unless someone knows why that stuff with calling update is mentioned in the documentation for ISceneManager::createTriangleSelector I'll change it tomorrow.
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