Page 1 of 1

Collision detection on animated mesh

Posted: Sun May 10, 2009 3:10 pm
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

Posted: Tue May 12, 2009 5:13 am
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 :)

Posted: Wed May 13, 2009 5:05 pm
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.

Posted: Fri Feb 04, 2011 5:56 pm
by JaSK
bump because I have the same problem...

Posted: Fri Feb 04, 2011 6:18 pm
by hybrid
Just use the usual triangle selector. It works for animated meshes as well. Please check example 7.

Posted: Sat Feb 05, 2011 12:46 am
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.

Posted: Sat Feb 05, 2011 11:48 am
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.