Advertisement

Collision det with walls and floors

Started by April 24, 2003 10:47 AM
4 comments, last by Aargyle 21 years, 9 months ago
I wanted to ask about collision detection with walls and the ground. This is troubling me because you will basically have to do this detection every frame, not once in a while like two objects colliding. If your world is flat floors and walls, its ok because you can do bounding boxes or spheres and its fast. But my problem comes up when I use a heightmap for the ground. With a heightmap terrain, the ''walls'' and the ''floors'' are all one piece, and can''t be split up into neat boxes. Anyone know a fast method or strategy to use here? I don''t want to have to check using the polygon on polygon method, for something that is done EVERY frame for every object in the world. But my little brain can''t picture using boxes or spheres correctly when you are walking around things like sand dunes with cliff walls, that don''t turn into boxes or spheres. Thanks!
Well I''m planning on using a binary tree for both my terrain rendering and collision detection. That way it it checks which big triangle you are in, then which smaller triangle. This way it only has to find which patch you''re in, then there are only two triangles. Then when you nkow which tri the player or object is over you can do collision detection with one plane. As you are only checking if the object is over the tri it is very quick and very simple.

You can store a pointer to the current triangle between frames, so it doesn''t have to recalc every frame.

If you are not using a binary tree for the terrain, but a grid, you can easily find the grid square you are in from the coord of the player, then only check the two tris applicable. I''m new to this, so I''ve never actually done anything I''m talking about, so other people''s answers will be afr better and clearer
Advertisement
I should clarify this

When my ground is flat, I can check my objects bounding box against a floor box or a plane.

But when the floor is a height map, what do I check my bounding box against?

Specifically I''m thinking of a car driving over some sand dunes. Each tire needs to know to stay above the sand, and the other parts of the car have to check against the dunes too (incase the wheels aren''t all on the ground, the car is in rollover, theres a really steep slope which the bumper hits, or the car is falling off a cliff and I need to know when it hits bottom).

I''m assuming the size of the car is greater than the polygon size of the heightmap, so that you can''t represent the part "under" the car as a plane. Plus if the heightmap has a sharp slope or wall this wouldn''t work either.
Ah you posted while I was writing higherspeed

Yeah that does clear it up a little. For each tire I can check it with the triangle under it.

But for the car itself I''m a little worried, since it will usually be over several triangles.

Also when the car approaches a steep change in terrain, like a cliff or wall, the tires might well be on the ground while the bumper strikes the cliff wall.

I''m so confused, hehehe. I don''t want to check like 20 triangles each time but maybe its the way to go.
Hi,

I got the same problem with a battletank game. Moving the tank on hills is my goal but for now I didn''t find any good hints.

cheers
I''ll tell you what I am thinking at the moment.

In a normal frame, I will always have 4 tires contacting the terrain. This means I should make that detection and response as fast as possible.

The much rarer case of some other part of the vehicle coming into contact with the terrain could be treated as any other collision (more advanced and slow in other words).

I think what I will do is model each tire with a sphere, and each frame if the tire falls below the surface I will just raise it back up to the level of the terrain. This sphere/plane or sphere/triangle collision detection should be pretty fast. For your tank you could probably use a rectangle for each track.

Then I will use a bounding box for the rest of the car to see if I need any more advanced testing. BUT. I still am not sure what to test this box against - i.e. every triangle near the car? ewwww. Thats still something that has to be done every frame.

This topic is closed to new replies.

Advertisement