Terrain collisions VIA IrrEdit

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Elspin
Posts: 2
Joined: Fri Oct 19, 2007 2:21 am

Terrain collisions VIA IrrEdit

Post by Elspin »

So, instead of manually creating the terrain, I'm loading it from a .irr file made in IrrEdit, so how would I do this?

Code: Select all

// create triangle selector for the terrain	
scene::ITriangleSelector* selector =
    smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
selector->drop();

// create collision response animator and attach it to the camera
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
	selector, camera, core::vector3df(60,100,60),
	core::vector3df(0,0,0), 
	core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
Note at the top I need the variable terrain, which was never created because I loaded from a .irr like this:

Code: Select all

smgr->loadScene("worlds/myTest.irr");
instead of doing this:

Code: Select all

scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode( 
      "../../media/terrain-heightmap.bmp");
So how can I get the current terrain of the scene?
sader
Posts: 28
Joined: Sat Sep 29, 2007 1:38 pm

Post by sader »

ISceneManger has these functions:
virtual ISceneNode * getSceneNodeFromId (..., ...)
virtual ISceneNode * getSceneNodeFromName(..., ...)
virtual ISceneNode * getSceneNodeFromType(..., ...)
I gues you can do your task with one of them not sure exactly how :roll:
Elspin
Posts: 2
Joined: Fri Oct 19, 2007 2:21 am

Post by Elspin »

Thanks, the name one worked perfectly :)

Uh oh, nevermind.

error C2664: 'irr::scene::ISceneManager::createTerrainTriangleSelector' : cannot convert parameter 1 from 'irr::scene::ISceneNode *' to 'irr::scene::ITerrainSceneNode *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

all those functions return the wrong kind of SceneNode, what the hell :(
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can check the scene node type and do a reinterpret_cast afterwards.
Post Reply