Getting Mirror Vertex on Asymmetrical Mesh


#1

Hello again!

I’ve written out a tool to take any asymmetrical mesh and generate a copy of itself mirrored (flipped) across the input axis WITHOUT compromising the vertex order. This is useful for generating “left” and “right” blendShapes without having to model both sides.

The first version of the script was a tutorial I followed which solved only for blendShapes (utilizing the base mesh pre-blendShape to determine what the differences were between the “left” and “right” sides).

The second version of this script now solves for any mesh. Assume that there are NO tweaks/local coordinates are 0 0 0 on each vertex. (IF tweaks are assumed, this tool works 100% of the time)

I’ve run into a bit of a haggle. I’m looking for differences in verts based on distance, however this is not always accurate due to the shape of the sculpt. My tool puts all the asymmetrical verts in the positions of the flipped side, however it does not know which vert should go there. Therefore, you can get tangled topology. So it works, but is not 100% foolproof.

My question is: Has anyone come up with a solution to find a connection between asymmetrical verts that does not look for closest distance?

Thanks!

EDIT:
Currently viewing abSymMesh by Brendan Ross


#2

EDIT: I think I might be misunderstanding the question. Never the less, I will leave my reply intact just in case it really is relevant.

As much as I would love to be able query a model for verts by position I know of no such way to do so. If we assume the pos is the same but mirrored along the axis and use Python, your best bet is to iterate over every vert in the model and add them to a dict where the key is a tuple of the x, y,z pos and the value is the vertex object. You can then easily query the dict by taking the selected Vert, getting its pos as a tuple and multiply the mirror axis by -1, it will now be (given our assumptions) the key of the mirror vertex and can be used to retrieve it from the dict.

Of course, unless you have a significant number of vertices your finding the mirror of, this would not be more efficient than simply comparing the vert pos while iterating over them all. Its a bit easier to implement efficiently, however.

Moreover, it can be easily altered to handle small variations in position (and thanks to rounding errors in Maya these WILL happen near each axis) by creating the key toy chopping off values of x,y,Z below a certain precision. This won’t be perfect (you’ll actually need either multiple entries per vert or same fancy rounding) but if you can come up with a hash function that will come up with the same key originally created for the mirrored vert, from the data available in the selected vert, then you can get that mirrored vert.


#3

That takes care of getting the symmetrical/asymmetrical verts, which the tool currently does (and it certainly takes time to do so in MEL haha). My question has to do with finding a relationship between the asymmetrical verts (or the verts that did not find a mirrored vert) on both sides of the axis.

Example scene:
Create a sphere
Move 3 verts on the positive X axis in various directions.

I’ve already identified the asymmetrical verts on the negative X axis correlating to the three verts moved on the positive X axis. BUT, this only gets me partially there. How can I identify which negative X vert belongs to the correlating positive X vert?

My current solution:
After I’ve identified the verts, I create a duplicate of this sphere and inverse its scale by -1 on the X axis. This now gives me a copy of the sphere that can ‘undo’ all the tweaks that were made to the sphere. One vert at a time, I undo its tweak on the duplicate (which places that vert as CLOSE to the negative vert on the original sphere as possible) and check its distance between all negative X verts. The closest distance to any of those three negative verts is the vert that correlates to the positive X vert. OR what I could do instead is move the positive verts back one by one and recheck for a mirrored position.

Either way, IF I assume the sphere has tweaks (or local transforms) on those three positive X verts, this solution works and I have a perfectly mirrored side of the sphere even though the sphere is asymmetrical.

But my question is: How do I find the correlation if the sphere had no local tweaks? Basically, no base shape to return to and check for the differences? Is there some sort of relationship between points on a shape? Is there a fast way of checking for matching topology between two shapes?

I looked at abSymMesh. Kinda confused on how it works, maybe I just didn’t read the directions thoroughly, but it looks like it doesn’t work on a shape without local tweaks (or again I’m misusing the tool).

Thanks again for the reply!


#4

One solution for Maya that might be useful is to look into the included plugin nearestPointOnMesh.mll (hopefully it’s still included with the newest Maya versions).

Basically it works on that you give it a position, and it will output various facts of the model, ie. position within object space, U and V params, and more importantly, the closest face index. This face index narrows down your diff down to 4 different points, which you could use to your advantage

You can create a locator connect it to the input translate to the nearestPointOnMesh node, then within code update the locator’s position with the vertex positions you’re querying, then, query the returning face indexes on the node, convert the face index to vertex indexes, then diff compare the four points.

As well, you could go the OpenMaya route, where you will have to do a bit of legwork to get the same result with the node.

Hope this helps!