Terrain Collision problem

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
froggy
Posts: 2
Joined: Fri Aug 11, 2006 5:59 am

Terrain Collision problem

Post by froggy »

Hi all,

I start using IRRLICHT for my game from last month and hit to this terrain collision problem.

What I am doing is to make my mesh (IAnimatedMeshSceneNode) to walk on terrain by the build-in collision function getCollisionResultPosition

This is how I create terrain and selector

Code: Select all

terrain = smgr->addTerrainSceneNode("terrain/terrain-heightmap2.bmp");
terrain->setScale(core::vector3df(40.0f, 4.4f, 40.0f));
scene::ITriangleSelector* selector = smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector); 
Then this is how I detect the collision : the world has -1Y gravity

Code: Select all

t = smgr->getSceneCollisionManager()->getCollisionResultPosition(
			selector, p, radius, move, tri, b, (f32) (speed * time)/1000.0f , core::vector3df(0,-1,0));
node->setPosition( t );

PROBLEM
When I try running around, it is ok for a while, but then drop off the map ... I am subspecting that I am standing between two triangles. is that possible ? or because I am using scale in terrain ?

Anyone got any working source with getCollisionResultPosition & Terrain, can you please post in here ?

Thanks
froggy
Posts: 2
Joined: Fri Aug 11, 2006 5:59 am

Post by froggy »

Just to let u know that ...

The same code works fine in version 1.1

It could be caused by an old bug.
Yotunii
Posts: 16
Joined: Sun Aug 13, 2006 9:44 am

Post by Yotunii »

Sounds like the floating point 'feature' in DirectX.. You can use createDeviceEx with HighPrecisionFPU = true.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you used scale before creation of the triangle selector it should have worked before, too. Maybe your heightmap is too large? Dont use anything larger than 256x256 (because this will create too mayn vertices) and use 2^n+1 in both dimensions, so take 129x129.
Post Reply