collision response animator and collada scenes
-
- Posts: 23
- Joined: Sat Jun 15, 2013 3:13 am
collision response animator and collada scenes
Did anyone manage to get the collision response animator to work with scene geometry loaded from collada files? No matter what I do the node that is supposed to collide just passes through. Alternatively, if I load the same scene as a b3d file it seems to work. Any ideas what might me wrong with collada?
Re: collision response animator and collada scenes
Collada sceneloader is a hack *sigh*. Do you try to load a collada mesh or a collada scene?
Do you use "smgr->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);" ?
Do you use "smgr->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);" ?
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
-
- Posts: 23
- Joined: Sat Jun 15, 2013 3:13 am
Re: collision response animator and collada scenes
My scene loading code. I try to get the mesh from the cache so I can pass it to the selector, but I'm not even sure the mesh is legit. The file itself contains one big mesh and two lights.
Code: Select all
smgr->getParameters()->setAttribute(irr::scene::COLLADA_CREATE_SCENE_INSTANCES, true);
smgr->getMesh("media3.dae");
IMeshCache *cache = smgr->getMeshCache();
IMesh * level_mesh = cache->getMeshByIndex(0);
core::array<ISceneNode*> map_nodes;
smgr->getSceneNodesFromType(ESNT_ANY, map_nodes);
for (size_t i = 0; i < map_nodes.size(); ++i) {
map_nodes[i]->setMaterialFlag(EMF_LIGHTING, false);
}
smgr->getParameters()->setAttribute(irr::scene::COLLADA_CREATE_SCENE_INSTANCES, false);
Re: collision response animator and collada scenes
No, that's basically the hack in this loader. It's using the meshloader interface to load a scene - which isn't really possible (as a scene is made up of many meshes and nodes using them). So it just returns a dummy mesh and put's the loaded scene-nodes into the scenemanager.
I suspect one workaround could be - create a new scenemanager (ISceneManager::createNewScenemanager) and load it into that one. Then all nodes in that will be of the new collada scene (if that's your only scene you don't need that step). Then you can move the nodes over to your original scenemanager (change the parent of all nodes below the root of the new scenemanger to the root of the old scenemanager). And while doing so create triangle-selectors for all those nodes.
I suspect one workaround could be - create a new scenemanager (ISceneManager::createNewScenemanager) and load it into that one. Then all nodes in that will be of the new collada scene (if that's your only scene you don't need that step). Then you can move the nodes over to your original scenemanager (change the parent of all nodes below the root of the new scenemanger to the root of the old scenemanager). And while doing so create triangle-selectors for all those nodes.
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
-
- Posts: 23
- Joined: Sat Jun 15, 2013 3:13 am
Re: collision response animator and collada scenes
There is no real need to create a separate scene manager for this, as you can just deactivate the collada loading feature once you are done loading the scene. As you can see from my code you can even obtain the scene nodes directly from the scene manager after that, granted you load the scene before anything else you do. So getting scene nodes from the scene manager is as easy as calling the getSceneNodesFromType() method.CuteAlien wrote:I suspect one workaround could be - create a new scenemanager (ISceneManager::createNewScenemanager) and load it into that one. Then all nodes in that will be of the new collada scene (if that's your only scene you don't need that step). Then you can move the nodes over to your original scenemanager (change the parent of all nodes below the root of the new scenemanger to the root of the old scenemanager). And while doing so create triangle-selectors for all those nodes.
What I didn't realise, however, is that while ISceneNode doesn't have a getMesh method, the IMeshSceneNode does. I also didn't realise that I can just reinterpret the ISceneNode pointers as IMeshSceneNodes and get the mesh from them, if I know for sure that a particular SceneNode is a MeshSceneNode.
Code: Select all
ITriangleSelector* selector = smgr->createTriangleSelector(((IMeshSceneNode*)map_nodes[2])->getMesh(), (IMeshSceneNode*)map_nodes[2]);