# Buggy / Terrain Physics

This topic is 4906 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've got a typical heightmapped terrain and a dune buggy mesh (from a .x, I'm using DX9). I'm trying to get the buggy to move realistically across the terrain, so need some kind of collision detection, which I can manage with eg a ball as it's just one point, but the buggy is different. Basically it could rest on the ground is any way...on its 4 wheel, on its side, on its roof..etc. I can't see bounding box working, but could maybe use bounding sphere for a terrain triangle proximity test. But even if I did full tri-tri collision detection between the buggy and terrain, I'm still stuck at how to make the other parts of the buggy move independent of the collided part. So what I'm asking is if anyone can describe some basic techniques and point me to some places to read up on it. Thanks, James

##### Share on other sites
Well, I havn't done much physics, but you said basic techniques so here goes:

For the collision detection, you could simply test all the vertices of the buggy against the triangles of terrain. As long as the terrain is not too jagged it should look fine. For collision response, when you find a vertex is on the wrong side of a triangle, find the closest point to it on the plane of the triangle, and move the entire buggy so that the vertex ends up at that point.

I suppose you want physics for the buggy. Well, how 'bout a link. It's supposedly about advanced character physics, but it's the simplest scheme I've seen (and therefore my favourite). It won't give you a buggy without significant effort though, so you might want to look for a physics library such as ode, newton etc. In fact, same goes for the collision. It all depends how much you want to do yourself.

##### Share on other sites
One of the simplest models would be to use 4 spheres for the wheels and a box for the main body of the car. You would then check to see if the 4 spheres are intersecting any of the ground polygons, if they are then you simply pop them out of the ground. You would also need to do additional checks to be sure that the wheel had not passed completly through the ground polygons in a laggy frame by doing a raycast or something. The main body of the car could be treated in a similar way, but it would be done with a box rather than a sphere. For slightly more accuracy, you could use cylinders instead of polygons for the wheels.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013540
×