Because in Beginners Help forum still appears questions about it, I deside me to write a function for easy using of selectors when Irrlicht collision is needed. This function can be base for easy creating of collision type "each to each". Also avoid autocollision. Each node must have one MetaTriangleSelector. This meta selector consist selectors for all nodes except this node.
Code: Select all
IMetaTriangleSelector* CreateMetaSelectorForWorldNodes(ISceneNode* Node)
{
IMetaTriangleSelector * WorldNodesMetaTriangleSelector = SceneManager->createMetaTriangleSelector(); //will consist selectors of all nodes without this Node
SceneManager->getRootSceneNode()->getChildren();
const core::list<ISceneNode*>& children = SceneManager->getRootSceneNode()->getChildren();
core::list<ISceneNode*>::Iterator it = children.begin();
for (; it != children.end(); ++it)
{
ISceneNode* current = *(it);
if(current)
{
if(current->getTriangleSelector() && current != Node)
WorldNodesMetaTriangleSelector->addTriangleSelector(current->getTriangleSelector());
}
}
return WorldNodesMetaTriangleSelector;
}
1. loading of some node
Code: Select all
scene::IAnimatedMesh* faerie = smgr->getMesh("../../media/faerie.md2");
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(faerie);
Code: Select all
smgr->createTriangleSelectorFromBoundingBox (node);
Code: Select all
IMetaTriangleSelector* metaselector = CreateMetaSelectorForWorldNodes(node) ;
Code: Select all
node->setTriangleSelector(metaselector);
Code: Select all
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
metaselector, node, core::vector3df(30,50,30),
core::vector3df(0,-3,0),
core::vector3df(0,50,0));
node->addAnimator(anim);
You can expand this example by adding of some idBitMask parameter if you want creating of some type of selective collision by groups.