Username
Password
Auto-login
Show my name in the online users list
Not a member?
Please register.
Forgot your password?
(1) October 2008
(2) May 2008
(1) January 2008
(1) November 2007
(2) September 2007
(7) August 2007
(2) July 2007
(1) June 2007
(3) May 2007
(4) April 2007
(8) March 2007
(9) February 2007
Parent to Surface script
Posted: Jul 26, 2007 - 03:24 PM
Category: mel scripts
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.
In order to post any comments, you must be logged in!
  Posted by freed.saul@btinternet.com  on  06 Dec, 2007  at  03:29 PM

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?

  Posted by freed.saul@btinternet.com  on  09 Nov, 2007  at  02:42 PM

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.

  Posted by Duncan Brinsmead  on  27 Jul, 2007  at  07:57 AM

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. 

  Posted by jbunger  on  27 Jul, 2007  at  01:56 AM

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. 

 
Page 1 of 1 pages