0
$\begingroup$

Good Day!

Situation: I have multiple objects with the same amount of vertices and a similar though deformed topology (all objects originate from the same one). I need to do two things to all my objects: Use them as shape key for each other and copy their weights by topology. Unfortunately, the vertex indices differ, thus the result of both actions is messed up.

Question: Is there a way to manipulate the vertex indices so they match in all objects?

Failed Attempts: I tried an addon called "copy vert IDs". The IDs did undergo some changes but weren't matching. I also used the Data Transfer modifier, copied vertex Data but it didn't seem to have any effect on the indices.

Thank you!

$\endgroup$
7
  • $\begingroup$ How different are the meshes? What kind of deformations are we talking about? $\endgroup$
    – Omar Emara
    Commented May 4, 2018 at 18:45
  • $\begingroup$ Not very different - they are faces. The deformations are meant for things like old/young or thin/big. If I could use them as Shapekeys (which was originally not intended) I could change things like the age smoothly. Nevertheless, the deformations are strong enough to ruin functions like "nearest vertex". $\endgroup$
    – Brodesius
    Commented May 4, 2018 at 19:24
  • $\begingroup$ The solution I had rely upon vertices normals and locations, so I am afraid with such drastic changes, there is no easy way to do it. If the models are not high poly, you can duplicate the model, align its vertices (using snapping) with the reference model, then compute a loop up table using KD Trees, apply it on the original model. If this is an option, I can write an answer with more details. $\endgroup$
    – Omar Emara
    Commented May 4, 2018 at 19:32
  • $\begingroup$ Thank you! I will give the snapping method a try. I think I know, how this could work. $\endgroup$
    – Brodesius
    Commented May 4, 2018 at 19:38
  • $\begingroup$ Okay, this would probably work, but it is not very efficient. You have to snap vertex by vertex since proportional editing ignores the snapping. With about 5k vertices, it is a very slow method. :-/ $\endgroup$
    – Brodesius
    Commented May 4, 2018 at 20:07

2 Answers 2

2
$\begingroup$

Lets say you have a reference object (Red) and a deformed object (Blue), while both have the same mesh structure, the vertices indices are different, we want to align the vertices indices so that we can create proper shape keys and smooth morphs.

The solution rely on computing a look up table for vertices based on their closest vertex in the reference object using a KD Tree. In order for this to work, an instance with the same indices structure of the deformed object has to roughly align with the reference object, if the deformation is too extreme, you will have to try to align the deformed object manually someway. This can be done by snapping the vertices manually, roughly aligning them using sculpting or proportional editing, for instance, I am going to duplicate the deformed object and try to align it using proportional editing:

Example Aligning

It doesn't have to be precise, it just have to good enough for the algorithm to work.

Then we are going to send that to Animation Nodes where we sample both the vertices locations of the reference object and the duplicated object we just edited. Then I am going to create a KD Tree from the reference object's vertices locations and use the Find Nearest Point Node to find the indices of the nearest vertices in the reference object. If we view the indices of the vertices of both objects and cross reference them with the output indices in the node tree, we will find that they indeed match:

Node Tree

Notice that the output list tells us that the vertex at index zero should be at index 32, the vertex at index 1 should be at index 15, the vertex and index 2 should be at index 22, and so on. If we now get the vertices from the deformed mesh at the output indices, we will get the vertices in the same order as the reference object but in the locations of the deformed object:

New Vertices

The edges and polygon indices of the new mesh are that of the reference mesh. All you have to do now is output the mesh and use it to create your shapekeys.

$\endgroup$
1
  • $\begingroup$ How did you do that this fast? :-o Thank you! $\endgroup$
    – Brodesius
    Commented May 4, 2018 at 20:55
1
$\begingroup$

Alternative Solution: It is possible to use the "Copy Vert IDs"-Addon even with deformed meshes. Therefore you have to select 2 adjacent faces on the origin mesh and hit ctrl+c -> "copy vert IDs topological". Next, select the same 2 faces on the target mesh and hit ctrl+c -> "paste vert IDs topological". All indices should match now. This solution may not work for everyone though: I have downloaded the Addon on a forum currently not available, and I have found no documentation.

(Stil not 100% happy with the solution, I did more research on the topic and finally decided to write my own python script by merging "Magic UV" by Nutti and "Copy Vert IDs" by Jose Conseco, since I know "Magic UV" was capable of the two-adjacent-faces-topology-identification-method and "Copy Vert IDs" to reassign Vertex indices. To my surprise, I found this method already built into the "Copy Vert IDs" script and learned that it is in fact based on "Magic UV".)

$\endgroup$

You must log in to answer this question.

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