3

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.

enter image description here

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.

Graviton
  • 219
  • 1
  • 5
  • 11

2 Answers2

1

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!

House
  • 73,224
  • 17
  • 184
  • 273
  • @Byte56, you have any existing framework that does the above things? I'm tired of writing everything by hand. – Graviton May 13 '11 at 02: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. – House May 13 '11 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? – Graviton May 14 '11 at 01: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. – House May 14 '11 at 02:02
  • I see! Is there any reference you have on the plane collision part? That would be helpful to me as well. – Graviton May 14 '11 at 02:19
  • Well any two planes that aren't parallel with each other will intersect at some point. What you're more interested in is quad collision or triangle collision. Likely for this scenario simple ray-triangle intersection. Should be simple to find via a Google search. – House May 14 '11 at 05:06
  • I posted some ray triangle intersection code on this question if that's useful to your project. – House May 16 '11 at 18:29
0

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.

user_123abc
  • 635
  • 4
  • 10
  • @Clinton, you have any papers or pointers for this? – Graviton May 13 '11 at 02: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? – user_123abc May 13 '11 at 03: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. – Graviton May 13 '11 at 03: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)? – user_123abc May 13 '11 at 03: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 – Graviton May 13 '11 at 03:32
  • Ahhh, okay. I'd say my answer really isn't going to be of much use to you then, I was thinking you were going to use the slopes for collision detection, which doesn't seem to be the case. I'd say Byte56's answer is more in line with what you want. Sorry! – user_123abc May 13 '11 at 03:36