Page 1 of 1

Terrain Collision problem

Posted: Fri Aug 11, 2006 6:17 am
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

Posted: Mon Aug 14, 2006 2:18 am
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.

Posted: Mon Aug 14, 2006 7:12 am
by Yotunii
Sounds like the floating point 'feature' in DirectX.. You can use createDeviceEx with HighPrecisionFPU = true.

Posted: Mon Aug 14, 2006 9:12 am
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.