Accurate Collision Detection with Terrains
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
Accurate Collision Detection with Terrains
Is there a way to get more accurate collision detection when using a terrain (model) or heightmap file? I've been trying... but when I use a heightmap file I can't actually get ahold of the mesh for the triangle selector so that doesn't work.
When using a terrain generated with MilkShape the model I use for testing 'floats' over the terrain making the shadow appear afew 100 units to the left/right (depending on what position I move to) of the model.
ScreenShot: www.phyer.net/whoppyarts/temp/shadow_funny.JPG
Yes, I tried decreasing the radius of the ellipsoid, that didn't work. But, the model does move "up and down" along with the hills of the terrain.
If anyone has a solution to this please let me know.
When using a terrain generated with MilkShape the model I use for testing 'floats' over the terrain making the shadow appear afew 100 units to the left/right (depending on what position I move to) of the model.
ScreenShot: www.phyer.net/whoppyarts/temp/shadow_funny.JPG
Yes, I tried decreasing the radius of the ellipsoid, that didn't work. But, the model does move "up and down" along with the hills of the terrain.
If anyone has a solution to this please let me know.
-
- Posts: 292
- Joined: Sun Mar 14, 2004 5:28 pm
- Location: Germany
- Contact:
I take an ITriangleSelector to get the current hight of the terrain for characters and for jeeps for something you should use an physik engine
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
-
- Posts: 292
- Joined: Sun Mar 14, 2004 5:28 pm
- Location: Germany
- Contact:
This was only an example
Edit:
My models stand on the floor, using the method, I explained:
http://raf.games-forge.de/v07/source/pr ... 20aussieht.
Edit:
My models stand on the floor, using the method, I explained:
http://raf.games-forge.de/v07/source/pr ... 20aussieht.
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
DarkWhoopy, if you are using a TerrainSceneNode you can just modify the models Z cordinates and set it equal to the height of the terrain at that point
Oh and don't trust my sintax.
Code: Select all
//Move node in the direction you want then:
vector3df pos3d = fairyNode->getPosition();
pos3d.z = terNode->getHeight(vector2d(pos3d.X,pos3d.Y)) //modify height to match terrain height
fairyNode->setPosition(pos3d);
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
Now she falls right through the terrain but stops at the bottom of its bounding box...
I can't get the mesh for the triangle selector
Someone have a terrian/collision example?
Code: Select all
mTerrain = mhandle->getSmgr()->addTerrainSceneNode(0,1,
mhandle->driver->createImageFromFile("Data/maps/grassplain_sk.bmp"),
mhandle->driver->createImageFromFile("Data/maps/terrian1.bmp"),0,
core::dimension2d< f32 >(10.0f, 10.0f), 150.0f, core::dimension2d< s32 >(64, 64));
mTerrain->setMaterialFlag(EMF_LIGHTING, false);
//Inside update function
vector3df pos3d = vector3df(mPlayerNode->getPosition());
mTerrain->getHeight(core::vector2d<f32>(pos3d.X,pos3d.Z),pos3d.Y);
mPlayerNode->setPosition(pos3d);
Someone have a terrian/collision example?
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
-
- Posts: 292
- Joined: Sun Mar 14, 2004 5:28 pm
- Location: Germany
- Contact:
Get the hight of the terrain at an position (x/z) using the ITriangleSelector an any other getHeight method.
Then get the relative vector form the cradle (origin) of your model to the position, where the model should stand on the floor.
Then
amsnModel->setPosition(vector3df(x + vRelVector.X, fTerrainHeight + vRelVector.Y, z + vRelVector.Z));
Then get the relative vector form the cradle (origin) of your model to the position, where the model should stand on the floor.
Then
amsnModel->setPosition(vector3df(x + vRelVector.X, fTerrainHeight + vRelVector.Y, z + vRelVector.Z));
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
-
- Posts: 292
- Joined: Sun Mar 14, 2004 5:28 pm
- Location: Germany
- Contact:
Three? I thougt, two, BoundingBox and TriangleSelection
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
No wonder! I checked the source files and.... I guess i'll have to find another solution for now
Code: Select all
//! Calculates height of a point in the terrain
bool CTerrainSceneNode::getHeight(core::vector2d<f32> pos, f32& outHeight)
{
return false;
}