4
\$\begingroup\$

I am using MeshMorpher from the Unify wiki in my Unity project, and I want to be able to transform between arbitrary meshes.

This script only works when there are an equal number of vertices between the two meshes. Is there some way to equalize the vertex count between a set of meshes? I don't mean that this would reduce the vertex count of a mesh, but would rather add redundant vertices to any meshes with smaller counts.

However, if there is an alternate method of handling this (other than increasing vertices), I would like to know.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ In order to seamlessly merge arbitrary meshes, they also need to be homeomorphic. \$\endgroup\$ Commented Jul 2, 2013 at 0:01
  • \$\begingroup\$ Even in offline movie CGI the models are kept similar in both counts and shape, like @SamHocevar points out. Any other way and the artifacts generated from synthesized points become noticeable. \$\endgroup\$ Commented Jul 2, 2013 at 1:16
  • \$\begingroup\$ The question does not seem to be reasonable when you consider the comments in the implementation that was linked by the OP. It clearly said: /// However the mesh morpher requires that you use the same amount of vertices for each mesh and that /// those vertices are laid out in the exact same way. Thus it won't work if Unity autosplits vertices based on normals. \$\endgroup\$
    – AturSams
    Commented Mar 22, 2014 at 16:02

2 Answers 2

1
\$\begingroup\$

Just a supposition here but a way to go without artifacts could be mesh conforming :

in short casting your mesh B onto your mesh A, easy to implement with morphed planes but could be a whole other issue with closed meshes.

What you need to do is create a function which will approximate the new point coordinates based on a set of points (as you have greater count with mesh A) and remap the point, kill the triangles, recreate the triangles the normals and then interpolate...

Mesh conforming demo

EDIT : one of the simple way to do that would be to approximate new base position based on the same vertex index than the one of mesh A ex:

Mesh A 20 Vertices Mesh B 10 Vertices

Kill Mesh B triangles Set Mesh B Vertices in index Order using for ex :

VertexPosMeshB[1] = (VertexPosMeshA[1] + VertexPosMeshA[2])/2; //scaling down to the actual size of Mesh B and approximating to fit previous pos

Re create Triangles in Index order or with a home made algo fitting the mesh shape. then Interpolate mesh B vertices over time until it fits the state you want

WARNING : If you mesh counts are too far apart of course you will have some weird results, try looking for Tesselation then to make your mesh with less poly conform to the one with more poly without "actually" being forced to keep the exact same number of vertices when you create your meshes.

A mix of tesselation and approximation algorithm could do the trick i believe

\$\endgroup\$
0
\$\begingroup\$

This tool is not useful for transforming between arbitrary meshes and it says that in the link you provided.

All this tool does is take N vertices with positions X0i, Y0i, Z0i and slowly transitions them to position X1i, Y1i, Z1i. It just takes a lot of numbers and does a time weighted average between them and a lot of other numbers each frame. Sort of like:

1 ... 1.1 ... 1.2 ... 1.3 ... ... 2

This process is also called interpolation.

There is no magic happening

From your link:

/// However the mesh morpher requires that you use the same amount of vertices for each mesh and that those vertices are laid out in the exact same way...

There are other ways to accomplish what you describe but they require very advance techniques and a very large amount of computation power.

For instance, you could:

  1. Convert the meshes to voxels.
  2. Do a boolean operation on two resulting models to get the differences.
  3. Use some transformation to gradually dissolve the pieces that exist on the original source mesh and do not exist in the target destination mesh.
  4. Use another transformation to grow the pieces that exist in the target but not in the source.
  5. Replace the voxel model with the target model.

If you want to spend even more computing power, you could use something like dual marching cubes to convert the in-between frames into smooth meshes...

Generally the morphing algorithm you linked to is an interpolation tool used to smoothly transition one mesh from pose A to pose B of the same mesh after some changes were applied to the positions of it's vertices.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .