5

What is the best way to project an arbitrary 2D polygon onto a 3D triangle mesh?

To make thing clearer, here is a visualization of the problem:

img

The triangle mesh is representing terrain and thus can be considered 2.5D. I want to be able to treat the projected polygon as a separate object. This particular implementation is done in WebGL and three.js but any solution that fits an interactive 3D application is of interest.

Spektre
  • 49,595
  • 11
  • 110
  • 380
figursagsmats
  • 155
  • 1
  • 1
  • 15
  • 1
    you could try using decals? https://threejs.org/examples/#webgl_decals – Martin Schuhfuß Feb 13 '18 at 11:12
  • I would create UV mapping (as you got uniform grid it is simple linear interpolation of vertex index) of the triangle grid and texture it by your polygon pre-rendered to texture... – Spektre Feb 13 '18 at 11:42
  • I agree with Martin Schuhfuß. But at the same time, in the picture, the result looks like two geometries kind of "united", as there are additional points and faces. – prisoner849 Feb 13 '18 at 12:34
  • Also, maybe this [SO answer](https://stackoverflow.com/a/48328939/4045502) will be helpful. – prisoner849 Feb 13 '18 at 12:49
  • Sorry about the uniform grid. It was just easier to make an example that way, but in reality the the grid is not uniform. Yes in the picture the two geometries are united. This is not entirely necessary, so decals could be a solution! Alltough there is a possibility that we would like to change the mesh exactly where the polygon is projected. For example when the given polygon represents a lake, then it would seem logical to make the projected part of the part of the polygon flat. – figursagsmats Feb 13 '18 at 12:52

1 Answers1

3

If your question is not how to texture map the surface, then you really have to generate new 3D polygons.

You will be using some projection mechanism (such as a parallel one) that turns your 3D problem to 2D.

First backproject the surface onto the polygon plane. The polygon will be overlaid on a corresponding 2D mesh. Now for every facet, find the intersection (in the Boolean sense) of the facet and the polygon.

You will need a polygon intersection machinery for that purpose, such as the Weiler-Atherton or Sutherland-Hodgman clipping algorithms (the latter is much simpler, but works on convex windows only). (Also check http://www.angusj.com/delphi/clipper.php)

After clipping, you project to the original facet plane.