<p>One method, probably the easiest. Is to have a one to one association of vertices in 1 model (model A) with vertices in the other model(model B). To do the morph look up the two vertices and lerp between them. Where the linear interpolation ranges from 0 to 1 and the two points form a line segment. 0 would represent model A and 1 would be the fully morphed version of model B.</p>
<p>The biggest problem with this approach is generating the association between the vertices.</p>
<p>To overcome this issue, a relatively simple solution is to scale and rotate both models so they effectively share the same model space, and are approximately overlapping each other. Distortions don't matter here, the goal is to get the two models roughly equivalent in size and shape with the bits of model A that map to model B close to each other. (if the two models are rigged, then this actually becomes easy to do automatically just by mapping the joints to each other)</p>
<p>Once you are happy that the basic parts are lined up, simply iterate across the vertices doing a brute force search for the nearest vertex from model A in model B. There will be some repeated vertices, either repeat them or create a structure to hold multiple mappings.</p>
<p>The result is your mapping. At this point the models can be massaged to be GPU friendly or whatever else is needed.</p>
<p>Other methods exist, but they get very bogged down in theory and math. I like this simple approach because it is relatively easy to implement and understand. (it is also easy to adjust it to fit different needs)</p>

CC BY-SA 4.0
2022-05-15T21:32:04.707Z
2022-05-15T21:32:04.707Z
pmw1234
<p>I have 2 3D head images and want to morph one into the other (animation) without using blender etc. I want to do it using coding preferably using C++, C# or python(libraries are ok). I have done 2D image morphing etc but was unable to replicate it in 3D. Kindly give guidance about the steps that needs to be followed to achieve this task. ( Any Sample project would help).</p>

<opengl><3d><c++><mesh><opencv>
3D head mesh morphing from one mesh into another using coding
suleman butt
# 3D head mesh morphing from one mesh into another using coding

(Asked by: username_0 on 2022-05-12)

I have 2 3D head images and want to morph one into the other (animation) without using blender etc. I want to do it using coding preferably using C++, C# or python(libraries are ok). I have done 2D image morphing etc but was unable to replicate it in 3D. Kindly give guidance about the steps that needs to be followed to achieve this task. ( Any Sample project would help).

**Tags:** opengl, 3d, c++, mesh, opencv


---

## 1 answers

### Answer by username_1 on 2022-05-15. Score: 2

One method, probably the easiest. Is to have a one to one association of vertices in 1 model (model A) with vertices in the other model(model B). To do the morph look up the two vertices and lerp between them. Where the linear interpolation ranges from 0 to 1 and the two points form a line segment. 0 would represent model A and 1 would be the fully morphed version of model B.

The biggest problem with this approach is generating the association between the vertices.

To overcome this issue, a relatively simple solution is to scale and rotate both models so they effectively share the same model space, and are approximately overlapping each other. Distortions don't matter here, the goal is to get the two models roughly equivalent in size and shape with the bits of model A that map to model B close to each other. (if the two models are rigged, then this actually becomes easy to do automatically just by mapping the joints to each other)

Once you are happy that the basic parts are lined up, simply iterate across the vertices doing a brute force search for the nearest vertex from model A in model B. There will be some repeated vertices, either repeat them or create a structure to hold multiple mappings.

The result is your mapping. At this point the models can be massaged to be GPU friendly or whatever else is needed.

Other methods exist, but they get very bogged down in theory and math. I like this simple approach because it is relatively easy to implement and understand. (it is also easy to adjust it to fit different needs)


---

