Home - nyotis/MayaWrapDeformer GitHub Wiki
Please note that the full source code is not available due to copyright restrictions. Assuming the licesing issue is resolved, I am happy to upload the complete source code.
As per February 2018, my Wrap Deformer Maya outperformed Autodesk's built-in (own) Wrap Deformer in terms of robustness and execution speed. The plug-in borrows heavily from the material presented at [1] - in that spirit, it deforms a high-resolution mesh based on one or more low-resolution polygonal mesh(es) - NURBS surface(s) are also supported, but of course there are of less interest in production.
Overall, any wrap deformer needs at least one wrap-influence and one wrap-base. Internally, Maya's SDK makes a copy of the influence object and uses it as a base. Wrap-influence objects are deformable objects themselves and, hence, subject to deformation by other deformers. It really is trivial to bind wrap-influence objects to a skeleton by applying smooth or rigid skinning, so that the wrap-influence objects affect the polygonal surfaces providing the character's skin (browse Maya's help on skinning with wrap deformers).
My wrap deformer is a Dependency Graph Deformer that deforms a wrap-base object -- the high-res mesh -- based on a single wrap-influence object, which is typically a low-res mesh. A wrap-base object is an object the user wants to deform, whereas a wrap-influence object (or objects) is the object that influences/drives the deformation. The shape of the wrap-influence(s) the user provides along with the user-defined transformations, determines the deformation applied to the wrap-base. Maya generates deformation effects based on the differences between the wrap-influence(s) and the wrap-base. Any difference in position, orientation, or scale between the wrap-base and the wrap-influence(s) results in a deformation of the wrap-base.
Just like with any other Maya deformer, the resolution and the topology of the wrap-influence mesh are not modified, only the positions of the points are changed. The position of the points the user selects are modified w.r.t. to the calculations inside the deform() function. The built-in MPxDeformerNode internally handles this. The resolution of the wrap-influence affects the occuring deformations and the computational time.
mayaWrapDeformer relies on a global UV-parametrization of the input wrap-influence object(s), which comes for free for any model generated in Maya. A vector and a distance are assigned to each vertex of the wrap-base pointing from the UV-coord onto the wrap-influence object. UV coordinates, in contrast to XYZ, are intrinsic coordinates and artists can edit them in the same way they modify vertex positions.
mayaWrapDeformer supports painted weights and the user can control their values interactively. This way the transitional influence between the wrap-influence and the wrap-base has a smooth fall off. Once painted weights are activated (note that the routine needs to be commented-out and the C++ code to be re-compiled) the rigger can use Paint Attributes Tool from the Modify Menu allowing her more explicit control.
Functionality
The user feeds input geometry to the plug-in and applies the deformation module, which modifies the input and produces the desired output geometry.
Example of use
The user selects and deforms a number of vertices on the wrap-influence object and the plug-in automatically computes the deformed positions of the wrap-base. The order of selection really is important. Alternatively, I modified a MEL script written by Erick Miller so that the user gets troubleshooting info when she picks the wrap-influence and wrap-base in the wrong order or selects an unsupported polygonal format.
Remarks
The topology of the mesh to be deformed should be known in advance and remain fixed before one generates the deformer. That is, the rigger should not change the resolution of the wrap-influence once the plug-in is loaded otherwise the behavior is undefined. This is not a real issue though: the user may modify the topology of the mesh after mayaWrapDeformer is plugged into Maya, by unloading the deformer first, modify the topology of the deformable mesh and then load the deformer again.
Build Instructions
The plug-in is implemented exclusively in Maya's C++ API favoring performance and robustness. I compiled the source for Maya 2012 on Mac OSX (Snow Leopard) with g++ 4.2.1(Maya 2011 plug-ins need to be compiled with g++ 4.0, which is not available via MacPorts and did not really want to build g++ 4.0 from source) having modified 'buildconfig' and 'makefile' courtesy Autodesk in order to get the necessary *.bundle directly without an intermediate xcodeproj. Note that Maya's 2010 version and upcoming ones were re-built from scratch with Qt for implementing better & user-friendlier GUI's so favoring Qmake instead of Cmake for platform-independent builds is a better choice considering Maya's dependency on Qt for GUI creation. Finally, I used the terminal shell app that ships with Maya so that I didn't have to manually configure environment values like MAYA_LOCATION.
Tests
The plug-in is tested for a wrap-influence (low-res mesh) consisting of maximum ~8,7K vertices - it might work for an influence meshes of higher resolution. As for 2012, Maya's built-in Wrap deformer maximum limit was max 1024 vertices. Note that:
- Typically there is no practical merit of having an influence with more than a few thousand vertices.
- The resolution of the wrap-influence affects plug-in's loading and computational time.
Regarding the wrap-base, the plug-in was tested for a wrap-base of ~100K vertices, close to the typical size of a 3D mesh used in production.
Revision History
- 20 February 2018, edited Wiki
- 21 July 2015, added part of the source
- 19 Dec 2014, updated Wiki
- 30 June 2012, Documentation
- 15 June 2012, compiled on Mac OSX (Snow Leopard) with g++ 4.2.1 for Maya 2012.
- 31 July 2011, fixed a bug causing a run-time crash.
- 24 June 2011, finished a toy-version of the wrap deformer for Maya 2011 on Fedora Linux.
Extensions
- 2015, TODO build for Maya 2015 and compare with built-in Shrink Wrap Deformer
- Alternative routines for getting faster access to the Input Geometry MObject
- As for 2012, Maya's routines for nearest points and normal computations were notoriously buggy. Many reasonable alternatives exist.
References
[00] Alec Jacobson, Zhigang Deng, J.P. Lewis, Skinning: Real-time Shape Deformation, ACM SIGGRAPH 2014 Course
[01] Erick Miller and Paul Thuriot, Hyper-Real Facial & Body Rigging.
Autodesk's Maya Master Class series, Custom Character Toolkit DVD, SIGGRAPH 2004.
Check: https://www.goodreads.com/book/show/2895109-maya-hyper-realistic-creature-creation-with-dvd