View Full Version : Rigging: Made a Skin Weights Transfer Script. Wanna try it?
02-11-2004, 02:45 PM
I was in the process of skinning a low poly character (this one (http://www.cgtalk.com/showthread.php?s=&threadid=111729)) and got really bored with maya's UV-based skin exporter/importer. I also checked out some other skin imoport/export scripts by Michael Bazhutkin and Michael Comet, but none of them really worked for me so I decided to write my own, aeSkinWeightsTransfer.
It works by importing the world space coordinates and skin weights of exported control points and compares them with the selected control point(s). The exported points closest to the selected point get their weights averaged and applied to the selected point, unless an exported point is found very close to the selected point, in which case the new weights are just copied from the exported point.
It should be able to transfer skin weights between objects of different type (Nurbs to poly etc), topology and UVs (in fact, export/import objects don't need UVs at all), and between multiple shape objects and single shape objects. The import/export objects can also have any, and different numbers of Skin Clusters.
I want to implement some kind of mirroring functionality so you can import weights from one side of a world axis to the other, but that hasn't been done yet.
Since I'm quite new to Mel - this is my first "user friendly" script (I've used MaxScript a bit before though) - I would appreciate very much if people here would test the script and see if it works the way it should. Or tell me if I've done something awkward, stupid, lame or unnecessary (or good for that matter) in the code.
I didn't know whether to post this here or in the Mel section, but I figured since it's aimed at riggers, not so much scripters, i'd reach the target audience better here.
Cheers in advance.
02-11-2004, 11:10 PM
it works for most of the joints, but I find the head verts aren't being weighted properly, they only have .5 weight to the correct bone. The other .5 is just missing -if I crank up the max distance it spreads the remaining .5 amongst a bunch of other joints. Originally all of the verts in the head are weighted completely to the head joint. These verts are the only verts in the model that aren't located closely to the joint they are influenced by, would that have something to do with it?
02-12-2004, 10:02 AM
Thanks for trying out the script, magilla, appreciate it.
Your error is a bit unexpected - are you saying that the weights of the head verts don't add up to 1.0?
The script normalizes the weights before applying them, so if the skin Cluster has normalize on, there should be two "buffers" to make sure the weights add up to 1.0 - the first being when the script normalizes them, and the second when the skin cluster normalizes them.
I'm pretty sure it has nothing to do with the distance to the joint - that's never taken into account when calculating the weights, only the distance to the Exported points.
Anyway, some error tracking:
*Could you post what all your settings were in the UI?
*Any other info, like the settings for the skin clusters etc would be valuable.
*How different was your Export object(s) from your Import object(s)?
*Any chance you could email me the export import file? I'll delete them right after error tracking.
I really want to get this to work, gonna have a look at the code today and see if I've missed something.
By the way, how fast is it for you? (check the script editor after exporting/importing for point count and time)
Thanks again for helping out.
02-12-2004, 06:30 PM
Some news about my intentions with this script:
I've decided to not implement the mirroring functunality - it's simply too difficult, and I want to get on with other stuff. What I am gonna do is include a tutorial in the docs on how to use aeSkinWeightsTransfer in combination with Maya's own Mirror Skin Weights to mirror dissimmilar or split, but roughly symmetrical shapes (maya's Mirror Skin Weights can only mirror weights across a single Skin Cluster).
I also intend to include an option to remove any Influence Transform(s) from the selected Skin Clusters that don't match the Exported Influence Transforms List. This will speed up the workflow for me at least, not having to remove all the tip joints etc. every time I re-skin.
Also, since I have made a procedure to keep the number of non-zero weights to a set number (alternatively, the maxInfluences attribute of each Skin Cluster), I might as well have an option to do only this, since you sometimes want to limit the number of influences for certain points to less than the Skin Cluster's maxInfluences attribute, plus you can override that attribute using mel so you may just want to clean up the weights and make sure the number isn't exceeded for any point.
Moreover, since you may only want to do any of the above two functions (remove new Influence Transform(s) and/or set number of non-zero weights), it will from now on be optional to actualy import weights.
Stay tuned for the update. :)
02-13-2004, 02:39 AM
687 Points were modified in 10.84 seconds.
I was weighting the same mesh that I saved the weights from. I tried a different model and it worked fine.
I had a look inside the .weight file that wasn't working and it didn't have any point info, just a list of influences.
I'll experiment some more and send some results through.
02-15-2004, 01:21 PM
There was a bug in the previous version which could cause one argument to be passed from the UI to the importer with the wrong value (I don't remember if it was that it always used "Query Each Skin Cluster" or that it never used it). Anyway, that has been fixed.
Also, actually importing weights is now optional, and users can choose to only remove new Influence Transforms, or only limit the number of non-zero weights on the selected points (in which case no export file needs to be loaded), or both.
All the mel files except the setup file have been changed since last version, so you need to either source them or reopen Maya before the changes take effect. I didn't include the icons or the setup file in this version as the file would have been too big, so you need to download the previous version for those if you haven't already done so.
Gonna start writing a proper documentation next.
02-16-2004, 09:29 PM
Can this be used for Rigid binds?
Im looking for a way to keep or transfer my riggid weights between two characters (its the same character duplicated) so i can make the UVs and not having a huge history and not loosing my rigid weights
Or even if i can transfer UVs between subdivision objects.
Or if this can transform rigid binds to smooth binds and viseversa?.
02-16-2004, 10:31 PM
Can this be used for Rigid binds?...Or if this can transform rigid binds to smooth binds and viseversa?
I'm afraid not. Both the exporter and the importer uses Skin Clusters, and Skin Clusters only work with smooth weights. I imagine it wouldn't be too hard to convert the scripts to work with rigid bind, but I haven't worked with rigid bind at all so for me it would be a bit too daunting a task to handle.
02-25-2004, 04:57 AM
this script kicks maya's "copy skinWeights" ass. (after fiddling with the settings a little)
why is it Alias can't do it as well as you?
although I dont really get why you have the "Limited Number of Non-Zero Weights" it seemed to only mess things up for me, with the default of ON...
nice work though... :applause:
02-25-2004, 05:07 AM
hay, Anders Egleus.
whats up with your website?
I cant download any of you animations... or demo reel..
02-25-2004, 12:18 PM
why is it Alias can't do it as well as you?
Lol! Because I'm unemployed and more desperate? :shrug:
I would be very grateful if you could be more specific about what gets messed up when Limited Number of Non-Zero Weights is on. The option is there because Maya doesn't seem to automatically limit the Non-Zero Weights according to the Skin Cluster's maxInfluences attribute when Weights are set with Mel instead of the Paint Weights tool or Component editor. I hope it's not a bug.
I cant download any of you animations... or demo reel.. Check your private messages.
Thanks for testing it.
04-21-2004, 02:40 AM
Would love for this to work. Already works better than Maya's CopyWeights, (it's consistent at least) but it seems to grab a few random points when exporting. At the moment, it's binding parts of my face to legbones, and parts of my tail to upper arm bones, among other things. Which I find really strange since about 80% of the points seem to have worked perfectly.
Any help you can give me on this would be lovely. (-:
04-22-2004, 01:57 AM
Nevermind, my model's just demented. Script works great though! (-:
04-22-2004, 09:42 PM
I've had that problem at one point too. Never investigated it very thoroughly though. Logically this would happen if there's an inconsistency between the list of bones that were exported and the ones bound to the clusters that you import to, but errors aren't always as logical as you'd like. I've tried to forsee this in the script but I might have done something wrong. Unfortunately I can't work on it until june as I'm involved in a small film project, but there has been a bug when importing which could be worked around by just restarting Maya. That's all I can say to help at this point I'm afraid.
04-22-2004, 11:40 PM
I did manage to track down the problem. While it still acted like the model was properly skinned, the weights listed in the component editor were completely off. I'm guessing this is a result of all the work I did on the model while it was skinned. Your script was exporting and re-importing these screwy values without fail 100% of the time though.
Thanks for the wonderful script!
04-23-2004, 09:05 AM
Here's my workflow when using the script while skinning low poly that's very topology sensitive for correct deformations:
*Concentrate on one joint and skin it as well as possible with the current topology.
*Export the weights.
*Do any changes possible to get better deformations without changing the topology.
*Determine what changes to topology are necessary to get better deformations.
*Go to bind pose and kill the history.
*Rework the topology around the joint.
*Re-skin and reimport the weights with Remove New Influence turned on.
*Fiddle with the weighting some more.
Possibly repeat the above steps before exporting the weights and moving on to the next joint area.
08-01-2004, 04:03 PM
Haven't had a chance to play with the options (have 3 weeks worth of work to complete in the next 3 days), but using the default settings, it appeared to work VERY well.
Been wanting to try this script for awhile now, and it was worth the wait. If I knew it was this simple, I would have tried it months ago. You saved my ass with this script. Thanks a ton.
01-17-2006, 11:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.