# How to generate slopes that meet the plane, is using collision detection a good idea?

I have a terrain, which is defined by mesh. And there are a lot of other polygonal faces scattered throughout the terrain, they can be located above, or below or cutting through the terrain. You can think of those faces as platforms.

A screenshot below should clarify what I mean. Despite looking smooth, all the mesh are actually consist of small elements (number> 10k) combined together, giving the false appearance of smoothness. The obvious disconnected area are platforms.

My question is, how can I generate slopes that connect between the platforms and other platforms/ terrain? The slope plane is defined as a series of piecemeal planes, starting from the edge of platforms, going down or up, depending on where is the nearest platforms or terrain elements.

I would need to generate he slope planes so that I can compute the volume difference between the slopes and the terrains, it's not just for visualization purpose.

I'm thinking about using collision detection engines to do things like this, but

1. I'm not too sure whether this is the right idea
2. if this was the right idea, any open source collision detection engines ( C or C++ or C#) I can use?

Edit: Any open source framework that can do this is desired.

I'm not sure I know exactly what you want to do, but I'm fairly sure you don't need a collision detection engine. You'll want to use some of the principles of a collision detection engine, but don't need a full blown engine. I assume that after you find these slopes they won't change? This terrain is going to be static?

You've got a few problems here.

1. Find out where and what the closest surface to "connect" to is. This can probably be solved following the normal of the edge out (like a ray) to see what is out there (up first then down?). If you bump into a platform, find the top edge that's closest (the edge you bumped into) and move to problem 2. If it's terrain, move to problem 2.

2. How to connect to two surfaces. Likely this can be done almost the same way as problem 1. You found the direction you need to go in problem 1, now create a normal on each end of the edge in that direction. Now the ends where you started and the points where those normals bump into something else are your 4 points for a quad.

3. Finding how when you bump into something. I'm assuming you have some height map you can reference. Hopefully you'd be able to use that along with your ray to find if something exists at that point in 3D space. Otherwise you'll have to check all the primitives (triangles? quads?) in the area to see if there was a intersection.

Not sure that's really clear, but it's somewhat difficult to explain. Good luck!

• @Byte56, you have any existing framework that does the above things? I'm tired of writing everything by hand. May 13, 2011 at 2:14
• Heh, sorry no. Did you create all the code for generating this scene? If so it's likely that an open source solution will be as much or more work than implementing your own version. I'm sorry to say I don't know of any plug and play option. You appear to have a uncommon plug :) That means real work. May 13, 2011 at 17:39
• @Byte56, quite the contrary I think it should be a common plug. I mean, detecting the planes that collide with other planes, how uncommon can it be? May 14, 2011 at 1:21
• If only that was the problem. The issue is that those planes don't exist yet. I agree plane collision is a common one, but taking the geometry created above to find where those planes should start and their angle is the hard part, finding out when they end (collision) should be the simple part. May 14, 2011 at 2:02
• I see! Is there any reference you have on the plane collision part? That would be helpful to me as well. May 14, 2011 at 2:19

This seems to me to be the type of problem that you would solve by using the current mesh as the rendering mesh, and creating a separate mesh for collisions where you connect the appropriate surfaces inside of the modeling application. I'm not sure investing the time into coming up with an algorithm would be worthwhile unless you're going to continually run into this problem over and over.

• @Clinton, you have any papers or pointers for this? May 13, 2011 at 2:11
• I guess before elaborating, it might be good to get a better idea of exactly what you're doing. I understand what you want to do, I'm not sure why you want to do it? May 13, 2011 at 3:01
• @Clinton, because it is our client's requirement, to be able to generate slopes connecting platforms and terrains in a realistic and mechanical manner. May 13, 2011 at 3:24
• What I mean is, what are those slopes going to be used for? Do the slopes need to be visualized (i.e. actual visible geometry)? May 13, 2011 at 3:28
• @Clinton, yes, the slopes need to be visualized, and not only that, I would need to compute the volume difference between the slopes and the terrains May 13, 2011 at 3:32