Rigging: Made a Skin Weights Transfer Script. Wanna try it?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  02 February 2004
Rigging: Made a Skin Weights Transfer Script. Wanna try it?

Hi everyone.

I was in the process of skinning a low poly character (this one) 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.
Attached Files
File Type: zip aeskinweighttransfer.zip (17.8 KB, 157 views)
  02 February 2004
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 February 2004
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 February 2004
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 February 2004
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 February 2004

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.
Attached Files
File Type: zip aeskinweightstransfer08.zip (16.5 KB, 133 views)
  02 February 2004
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?.
'If you wait until everything is perfect before you take that first step, you will stand in place forever.'
  02 February 2004
Quote: 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 February 2004
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...

Make something idiot proof and they'll just build a better idiot
  02 February 2004
hay, Anders Egleus.

whats up with your website?
I cant download any of you animations... or demo reel..
Make something idiot proof and they'll just build a better idiot
  02 February 2004
Quote: why is it Alias can't do it as well as you?

Lol! Because I'm unemployed and more desperate?

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.

Quote: I cant download any of you animations... or demo reel..
Check your private messages.

Thanks for testing it.
  04 April 2004
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. (-:
My webpage: www.TahleN.com
  04 April 2004
Nevermind, my model's just demented. Script works great though! (-:
My webpage: www.TahleN.com
  04 April 2004

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 April 2004
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!
My webpage: www.TahleN.com
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:52 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.