- skinCluster weights,
- polygon geometry, and
- component selection
- and a lot more
very stable based on the Edgeflow of the Object.
For finding the opposite Vertices this tool uses an algorithm, that only looks at the way the components (edges, vertices and faces) are connected together, and therefore ignores positions.
This means, the Tool even works, if the positions of the vertices are not symmetrical or even if the character is in a different
pose than the default pose.
How can I use it?
copy the files somewhere on disk, open edgeFlowMirrorUI.py and change the line
edgeFlowMirrorPluginFile = ‘myFileLocation/edgeFlowMirror.py’;
to match the path to where your plugin is located
(you could also load the plugin in other ways, like copying it into the maya folder - in thise case you can ignore
this step)
Source edgeFlowMirrorUI.py and run:
showUI()
One way of running that function would be from Python Script Editor:
import sys
sys.path.append('/myFileLocation/')
import edgeFlowMirrorUI
edgeFlowMirrorUI.showUI()
First, a middle edge needs to be set. Middle Edge is ONLY ONE of the edges, that go through the middle axis (see picture
below for more infos – important: even though in this picture the whole middle loop is selected, the edgeFlowMirror tool ONLY
needs ONE of them)
Both options (skinCluster and Geometry) work with Vertex Selection and Object Selection (only on Polygons)
SkinCluster:
Weight influences are mirrored based on names of the joints. The correct prefixes need to be set in the UI.
For example, with left joints prefix "l_" and right joints prefix "r_", l_elbow is the opposite joint of r_elbow.
Joints that don't have these prefixes in their names are being handled as middle joints. This means, the influence values from this joint on one side are mirrored to the other side on this influence, rather than applying them to an opposite influence. This middle influences are being logged in the script editor.
Geometry:
For Flipping or Mirroring, set Base Mesh first. Base mesh is the default mesh. On any polygon object that will be mirrored, the
positions relative to the Base Mesh positions will be mirrored, rather than absolute positions.
How does my character need to look like, so the Tool works?
Although the positions of the vertices don't matter, the edgeflow must be the same at the left side and the right side. And there needs to be one Edge Loop going through the whole middle axis.
If the character used to be symmetrical (created with any similar option like Mesh -> Mirror Geometry) and then only vertex
positions were modified, in the normal case the tool should work perfectly.
How can I be sure, that this algorithm works for my character?
Set the MiddleEdge, and in Geometry press the button next to Symmetry Mesh (important: THIS WILL CHANGE YOUR OBJECT,
make sure you save / use undo after it)
The Plugin tries to create a mirrorshape - if it says "found mirrorPoint for each selected point " and the object looks very
symmetrical, you are good to go, and in the normal case, all mirrorings should work good.
If the Plugin says "Warning: some points couldn't be mirrored (see selection)", then look at the selected vertices, as those are the ones that didn't get mirrored. Try giving him a different middle edge (any edge of the middle loop) and compare the results - mirror might still work however should be used with extra caution!
The Algorithm:
A very important input is the Middle Edge, that is required for each task. The Middleedge is ONLY ONE of the edges from the
vertical middlerow of the character. (See picture above)
If the flow of the edges (i.e. the way, they connect the faces and vertices are connected together) is symmetrical, it doesn't matter, which edge of the row we use.
The tool then looks, which face is on the right side, and which face is on the left side. And then it automatically knows, that the
vertices of the right face are the opposite mirrorvertices of the left face and adds those into the mirror arrays.
In the next step, it looks for the neighbour vertices of the first vertices of the left side vertices, and on the neighbour vertices of the right side vertices (that we found before). Those vertices are being declared as mirrorvertices again and being put into the arrays.
Then it looks for the neighbour vertices of the neighbour vertices of the left faces and the neighbour vertices of the neighbour
vertices of the right faces and so on ......
For developers:
The plugin can also easlily be used to create any other Mirror Tools with MEL (or Python)
Here are 2 MEL lines, that give you 2 arrays (mapArray, sideArray) that hold the mirror-mappings of the vertices. You can use these arrays to write MEL/Python code that mirrors other things - like selection, or any weightmaps.
int $mapArray[] = `edgeFlowMirror -task "getMapArray" -middleEdge myObject.e[15]`;
int $sideArray[] = `edgeFlowMirror -task "getSideArray" -middleEdge myObject.e[15]`;
after running these commands,
$mapArray looks like this: 25, 10, 5, 8, ...
which is an array, that has the size of the vertex count of the model. In this example, Vertex 0 is the opposite mirror vertex of Vertex 25, Vertex 1 is the opposite of Vertex 10, Vertex 2 the opposite of Vertex 5, etc...
$sideArray looks like this: 1, 1, 1, 0, 2, 2, 2, ...
Since $mapArray only maps vertices, but doesn't tell us anything about which side the vertex actually is, $sideArray takes care of it. 1 means left, 2 means right, and 0 means middle.
Contact:
For any further questions please don't hesitate to contact me: thomasbittner@hotmail.de
Also, contact me if you need it for a different Maya version - or the c++ version. Maybe things can be done..
I DO NOT TAKE RESPONSIBILITY OF ANYTHING THAT HAPPENS WITH THIS TOOL!
Please use the Feature Requests to give me ideas.
Please use the Support Forum if you have any questions or problems.
Please rate and review in the Review section.