Hi,
I have a very basic question about collision and triangleselector:
I want my camera scene node to collide with various meshes, do I have to create a different triangleselector and a CollisionResponseAnimator for every mesh I want the camera to collide with? or is there a way to make it collide with a single triangleselector and CollisionResponseAnimator?
By the way, I know how to use the OctTreeTriangleSelector that is described in the example, but after looking around for a while, I'm unable to find how to use the other two triangleselectors.
Oh, and a last question: it's me or the forums are slow lately?
EDIT: Thanks! I'll tried it today and worked as expected
Thanks!
[SOLVED] A basic question about collision
[SOLVED] A basic question about collision
Last edited by Amt0571 on Fri Sep 08, 2006 12:05 am, edited 1 time in total.
Amt,
This is a topic that everybody ask and probably will be replied with "use the search button". But, since this issue almost drives me crazy and took a lot of time to find an example using IMetaTriangleSelector, here is the direct link to the solution. Look at the "ming" post in the topic below:
http://irrlicht.sourceforge.net/phpBB2/ ... leselector
Be carefull, since he is using "createTriangleSelectorFromBoundingBox" instead of "createOctTreeTriangleSelector"
Here is my code to apply collision detection to 4 identical meshes (guarita), placed at different coordinates. Use it at your own risk, because I'm not a programmer and I'm not sure if this is the best way to do it. It works for me.
hope this help
by the way, the foruns are slow for me too. I think they are adding some phpBB MODS
This is a topic that everybody ask and probably will be replied with "use the search button". But, since this issue almost drives me crazy and took a lot of time to find an example using IMetaTriangleSelector, here is the direct link to the solution. Look at the "ming" post in the topic below:
http://irrlicht.sourceforge.net/phpBB2/ ... leselector
Be carefull, since he is using "createTriangleSelectorFromBoundingBox" instead of "createOctTreeTriangleSelector"
Here is my code to apply collision detection to 4 identical meshes (guarita), placed at different coordinates. Use it at your own risk, because I'm not a programmer and I'm not sure if this is the best way to do it. It works for me.
Code: Select all
/* add 3d mesh guarita */
IAnimatedMesh* guarita = 0;
guarita = smgr->getMesh("./media/meshes/guarita.obj");
/* display multiple meshes of guarita node*/
ISceneNode* guaritanode = 0;
ITriangleSelector* guaritaselector = 0;
IMetaTriangleSelector* mainTriangleSelector = smgr->createMetaTriangleSelector();
guaritanode = smgr->addOctTreeSceneNode(guarita);
guaritanode->setPosition(core::vector3df(-1400,0,1800));
guaritanode->setScale(vector3df(10,10,10));
guaritanode->setRotation(core::vector3df(270,0,0));
guaritanode->setMaterialFlag(video::EMF_LIGHTING,true);
guaritanode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
guaritanode->setMaterialFlag(EMF_FOG_ENABLE,true); //enables fog
guaritaselector = smgr->createOctTreeTriangleSelector(guarita->getMesh(0), guaritanode, 128);
guaritanode->setTriangleSelector(guaritaselector);
mainTriangleSelector->addTriangleSelector(guaritaselector);
guaritaselector->drop();
guaritanode = smgr->addOctTreeSceneNode(guarita);
guaritanode->setPosition(core::vector3df(-1400,0,-1800));
guaritanode->setScale(vector3df(10,10,10));
guaritanode->setRotation(core::vector3df(270,0,0));
guaritanode->setMaterialFlag(video::EMF_LIGHTING,true);
guaritanode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
guaritanode->setMaterialFlag(EMF_FOG_ENABLE,true); //enables fog
guaritaselector = smgr->createOctTreeTriangleSelector(guarita->getMesh(0), guaritanode, 128);
guaritanode->setTriangleSelector(guaritaselector);
mainTriangleSelector->addTriangleSelector(guaritaselector);
guaritaselector->drop();
guaritanode = smgr->addOctTreeSceneNode(guarita);
guaritanode->setPosition(core::vector3df(1400,0,-1800));
guaritanode->setScale(vector3df(10,10,10));
guaritanode->setRotation(core::vector3df(270,0,0));
guaritanode->setMaterialFlag(video::EMF_LIGHTING,true);
guaritanode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
guaritanode->setMaterialFlag(EMF_FOG_ENABLE,true); //enables fog
guaritaselector = smgr->createOctTreeTriangleSelector(guarita->getMesh(0), guaritanode, 128);
guaritanode->setTriangleSelector(guaritaselector);
mainTriangleSelector->addTriangleSelector(guaritaselector);
guaritaselector->drop();
guaritanode = smgr->addOctTreeSceneNode(guarita);
guaritanode->setPosition(core::vector3df(1400,0,1800));
guaritanode->setScale(vector3df(10,10,10));
guaritanode->setRotation(core::vector3df(270,0,0));
guaritanode->setMaterialFlag(video::EMF_LIGHTING,true);
guaritanode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
guaritanode->setMaterialFlag(EMF_FOG_ENABLE,true); //enables fog
guaritaselector = smgr->createOctTreeTriangleSelector(guarita->getMesh(0), guaritanode, 128);
guaritanode->setTriangleSelector(guaritaselector);
mainTriangleSelector->addTriangleSelector(guaritaselector);
guaritaselector->drop();
/*collision detection guaritas*/
ISceneNodeAnimator* animaguarita4 = smgr->createCollisionResponseAnimator(
mainTriangleSelector, camera, core::vector3df(30,30,30),
core::vector3df(0,0,0),
core::vector3df(0,30,0));
camera->addAnimator(animaguarita4);
animaguarita4->drop();
by the way, the foruns are slow for me too. I think they are adding some phpBB MODS