Site Stability Read more... ×

# Car on terrain

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

## Recommended Posts

Hi. Before we start, let me tell you that I've already googled and used the search function to find some solution to this. And as you can see, I didn't found one. Let's assume a terrain made of arbitrary number of polygons, like on this image: As you can see, the triangles aren't aligned as they would if I would be using Quads. My question is: What's the fastest/best way to test on which triangle the car's wheel lies on? I've done this with the terrain like this: And it was easy, since the position where the wheel lies can be easily calculated by dividing the current position by the distance of each quad. But I only have a slight idea of how to solve this question. The only method I came up was to use Quadtree/Octree to partition the world, test each block to see where the car's wheel lies, and then, test each triangle on the leaf against the wheel. Any other ideas?

##### Share on other sites
From my experience, the usual method of speeding up this kind of thing is to use some kind of Bounding Volume tree.

AABB trees, OBB trees, and k-DOP trees are good examples that can be used in these circumstances.

It's a big and complex area, on which I'm no expert, so I will simply recommend a good book on the subject...

Real-Time Rendering by Tomas Moller and Eric Haines : http://www.realtimerendering.com/

If you're after an off-the-shelf solution that you can just plug into your engine, then check out the open source OPCODE library : http://www.codercorner.com/Opcode.htm. Just point it at your polygons, and use it's ray test functions, and you will find it to be pretty fast.

Hope that helps.

##### Share on other sites
How is it that your terrain is made with an arbitrary number of polygons in that form? Whenever you create/load it, you could designate each vertex into a quadtree, and then run your car's tires along this quadtree and interpolate appropriately

##### Share on other sites
Thanks for the help, guys.

The terrain will be created by hand, using a modeling tool. That's why I can't assume the polygons would be aligned as they would if I used heightmaps.

I think I'm going to partition the terrain using quadtree/octree and check all polygons inside the node where the wheel is.

Meanwhile, when searching for this solution, I came across Quake III Rally, a MOD for quake 3. What got my attention is that they're using BSP trees both for culling and collision. And since I've already written a BSP viewer, I'm going to take a closer look on this, and see if this can be used for my game, too, since BSP are much more better for collision.

Thanks.

The link for Quake III Rally is:
http://www.quakerally.com/

If anyone has a better option, let me know.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11