Hello,
I would like to do a triangle selector for scene loaded from a .irr file. I successfully got a pointer to the node i am interested in but i can't seem to get a pointer to the mesh. I need a pointer to the mesh so i can use it when calling the createOctTreeTriangleSelector function.
Is there a way to get the pointer to the mesh or is there an easyer way to do a triangle selector for a .irr file?
Getting a mesh from .irr file
News:
I discovered that i can use getMeshByIndex(0) (My mesh id in irredit is 0)
Problem is that i don't know how i can properly call the function. I tried smgr.getMeshByIndex(0); but it didn't work
In the documentation it says that the function is part of IMeshCache but i'm not that used to classes. I'm not use how to use it.
I discovered that i can use getMeshByIndex(0) (My mesh id in irredit is 0)
Problem is that i don't know how i can properly call the function. I tried smgr.getMeshByIndex(0); but it didn't work
In the documentation it says that the function is part of IMeshCache but i'm not that used to classes. I'm not use how to use it.
Nevermind, i figured it out:
Code: Select all
// load the scene
smgr->loadScene("main.irr");
// prepare node & mesh for triangle selector(get the pointer)
scene::ISceneNode* node = node=smgr->getSceneNodeFromId(0);
scene::IAnimatedMesh* mesh = smgr->getMeshCache()->getMeshByIndex(0);
//triangle selector
scene::ITriangleSelector* selector = 0;
if (node)
{
selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0),node,128);
node->setTriangleSelector(selector);
selector->drop();
}
// add a user controlled camera with collision response
scene::ICameraSceneNode* camera =
camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(core::vector3df(0,1000,0));
scene::ISceneNodeAnimator* anim =
smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-0.5,0),
core::vector3df(0,5,0));
camera->addAnimator(anim);
anim->drop();
Hi Alex
Your code helped me to add collision to my irr file.
But I have a problem, the map is duplicated. I have the version I created with the smgr->loadScene(), and the mesh I setted up with the command
scene::ISceneNode* node = node=smgr->getSceneNodeFromId(0);
is there any way to delete the map created with the loadscene, and let the map with the collision response?
Or is there any other way to add collision to an irr file, without duplicate it?
By the way, I have the .obj of my map, I ussually use it instead of the .irr, but I cant load the file with textures.
Thanks.
Your code helped me to add collision to my irr file.
But I have a problem, the map is duplicated. I have the version I created with the smgr->loadScene(), and the mesh I setted up with the command
scene::ISceneNode* node = node=smgr->getSceneNodeFromId(0);
is there any way to delete the map created with the loadscene, and let the map with the collision response?
Or is there any other way to add collision to an irr file, without duplicate it?
By the way, I have the .obj of my map, I ussually use it instead of the .irr, but I cant load the file with textures.
Thanks.
-
- Posts: 157
- Joined: Tue Mar 20, 2007 8:30 am
@Alex Stan
Nice work figuring it out for yourself, you got further with .irr files than I ever did
@Viniterra
You can add collision to an .irr file, there's plenty of people in Beginners Help who have asked and gotten answers, so the search and look for something like "collision .irr" and you should find what your after
Nice work figuring it out for yourself, you got further with .irr files than I ever did
@Viniterra
You can add collision to an .irr file, there's plenty of people in Beginners Help who have asked and gotten answers, so the search and look for something like "collision .irr" and you should find what your after
Tell me what you cherish most. Give me the pleasure of taking it away.
vitek has already posted code how to do that at http://irrlicht.sourceforge.net/phpBB2/ ... sc&start=0
certainly! it's quite perfect. from the link I recommend you to use smgr->smgr->createTriangleSelectorFromBoundingBox();
instead of all smgr->createTriangleSelector(msn->getMesh(), msn)
sorry for my bad english
certainly! it's quite perfect. from the link I recommend you to use smgr->smgr->createTriangleSelectorFromBoundingBox();
instead of all smgr->createTriangleSelector(msn->getMesh(), msn)
sorry for my bad english