|
Feedback
Posted: Jul 27, 2007
Category: MEL
Here is a script for sticking objects onto a deforming surface(click to download):
parentToSurface.mel This mel command allows one to attach selected objects to a selected mesh or nurbs surface. The objects will follow any deformation or transformation of the surface. To use put this script in your local scripts directory. In Maya select object(s) followed by a mesh or nurbs surface to attach to then enter "parentToSurface" in the command line. A follicle node will be created at the point on surface closest to the center of the object and the object will be parented to this follicle. Note that if the surface to attach to is a mesh it must have well defined UVs that range from 0-1 with no areas sharing the same value. For convenience drag the parentToSurface string onto the shelf to make a shelf button. This command uses the follicle node, which is normally used by the hair system. The follicle node is currently the only node in maya that can derive a rotate and translate based on a uv position for both meshes and nurbs surfaces. I found that I was explaining the complicated workflow of how to setup a follicle node in this manner so frequently that it was worth creating this script, which is much easier to use. One use of this script might be to attach buttons to a cloth object, or any deforming surface. For the example animation stuckOnCloth.avi the workflow was simply to first position all the button objects( in this case pipes, cones and cylinders ) in the desired position then select them followed by the cloth mesh and run this command. After one has attached an objects with this command one can also move it across the surface by editing the uv value on the follicle nodes. Also the node is parented to the follicle, so one is free to rotate and position the button object as desired with respect to the follicle. As with all the scripts on my blog, please feel free to modify and share with others. | |||||