# Creating a Smooth 3D Mesh from a 2D Outline

I am trying to find (or maybe create) an algorithm for creating a smooth, rounded 3D mesh given a 2D outline. I'm trying to recreate a system from a Gamecube game called Amazing Island, and you can see an example of how it works here. A more modern example of what I'm trying to do would be the Soft Edge 3D Doodle tool in Paint 3D.

Basically, you draw a shape with a freeform pen tool, and the shape is "inflated" into a 3D mesh. The result should have smooth, curved, somewhat organic-looking edges, rather than simply extruding the shape into a prism. Each shape can be assumed to be simply connected (meaning shapes with holes through them are not possible), and it can be assumed that the outline won't self-intersect. It would be nice if I could find a way to have non-simply connected shapes, but it's not necessary, and seems like it would be significantly more complicated.

The closest thing that I've been able to find is how to take an outline and triangulate it to make a flat 2D mesh. I'm pretty lost on how I can take that and turn it into what I want though. I can get a list of points representing the vertices of the outline, which seems like it should be the first step.

I'm implementing this in C#, in Unity, but I'm not necessarily looking for code. A description of an algorithm, or even a good idea for how I could approach the problem, would be great. Thank you for your time.

## 2 Answers

One algorithm that's pretty good for this, but very difficult to implement is to find the Medial Axis of the shape and then have various profiles that are based on the signed distance from the medial axis. You can also use the Straight Skeleton instead of the Medial Axis, but it's also a bit of a pain to calculate.

An easier way that's not quite as accurate, but usually good enough is described here: https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf. You can take a bitmap of the shape the user drew, shrink it down to some manageable size, calculate the distance of every pixel from the edges of the shape, then scale it to the size you need (and scale the distances accordingly). Once you have signed distances you can use them with the same 3D profiles mentioned above.

For example, the pillow in the video you showed is basically drawn as a square. Your 3D profile would set the front face height to 0 at the squares edges, and increasing up to some maximum as you moved towards the center, peaking after a short distance and holding up to the center. The back face height would be the same but in the opposite direction.

• The medial axis is easier to calculate then the straight skeleton, the edge cases of the straight skeleton are a nightmare! Dec 4 '19 at 23:04

You could try the FiberMesh technique. Fibermesh takes 3D input curves and interprets them as the contours of the surface. It then creates a smooth surface by using an optimization technique. Here you can see a video, which demonstrates the technique.