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.
hey duncan
i am having a very weird problem. i have a tons of objects parented to a skin surface using ur script.
but.
mental ray wont render them unless i unparent from the follicle.
what a nightmare.
any ideas?
hey duncan. just to say thanks. i am directing a music video with a huge amount of objects that need to be stuck to a character.
i have tried a few things until i found this script, whihc made everythin fall into place. the fact it work in hirarchy adn not contraints is beutifull. so well done.
A mix of both methods is usually best. Create single quad plane proxies for all your buttons and make them cloth. Then attach the detailed button models to these cloth planes with the parentToSurface script. You can also set the collide thickness on the cloth buttons to match the thickness of your real buttons.
Thanks Duncan. I’ve done buttons and other attachments on nCloth in two ways; one with follicles (which will be much easier now!), and by making the objects nCloth and keeping them in place using component to component restraints. I’ve found that the second method takes more computing power to simulate and is more troublesome, but you can get decent results using either method. I would guess that the best reason for doing it the second way is that you can make the buttons weigh more and pull the cloth down as they react to gravity.




