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
Collision detection on animated mesh
-
- Posts: 28
- Joined: Fri Apr 24, 2009 2:43 pm
- Location: over there...
i think irrlicht can't do the generic tutorial example selector for animated nodes (so don't flame me.... not the face ) but try for example
hope this helps
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);
//Personal code
bool sarcasm;
void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
bool sarcasm;
void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
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.
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.
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.
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.
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.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm