As per the discussions in this thread, I have decided to try my hand at writing a normalization script for managing bone groups. This is my first Blender script, but I am satisfied with the functionality I have been able to achieve with it! The script provides the following capabilities:Normalizes the entire mesh (per vertex) by distributing all weights evenly, or preserving 100% groups based on 3 rules:[INDENT]1.)If there are no 100% groups, all weights are evenly distributed.
2.)If there are more than one 100% groups, they are divided evenly, and all other memberships are removed.
3.)If there is just one 100% group, it becomes the owner of the vert and all other influences are removed.
It also provides a “mode” which allows you to update the selected/active group and normalize its weights by either preserving the weights entirely, or distributing them evenly. Non-bone groups are left untouched.
As well, the peak (100%) value can be set, and there is a tolerance setting to determine the minimum value of a 100% weight.
[/INDENT]It is a little confusing to explain in writing, which is why I made a video screencast to demonstrate the basic use of the script. I’ve also attached a demo file (updated to 1.1) in the rigging thread with a dummy rig to test on (since I just noticed attachments are disabled here!). The latest version of the script will continue to be posted on my ‘google pages’ page, which is also linked from my blog.
Again, this is an alpha release, so it likely has bugs to find! Please report any bugs or suggestions to this thread.
Version 1.1 - 2.49 released July 17 2009
-removes weights with 0% influence (instead of assigning with 0 values, keeps weights clean)
-normalizeOverlapping() more or less fixed but still not quite right so normalization() left as default
I just wanted to tell you that this script is a life saver!
I rig armor for a game, and it requires that each bone has weight of no more than 1. Which would mean, if I didn’t have this script, that I would have to edit and triple check every single vertice against all the bones in the vicinity to make sure all the weights added up to exactly one.
Yes there is a script in the paint menu. I was playing around with it before I wrote this script.
However I have been unable to determine the rules of it. I certainly don’t get the same behaviour from it as I do with this script.
It can also be a drag to select Paint->Normalize/Scale weight, and re-configure your settings every time you want to use it, instead of just reaching over and clicking a big button with your settings intact.
If you use it, can you explain how it is you get the same behaviours with it? What are the settings you use?
I appreciate the feedback! I’m glad to hear you find it useful!
In my first attempts, I was trying to get the script to be interactive, so that you could turn the mode on and just paint normalized continuously. However I quickly realized it just wasn’t feasible for a high-level script, and went for the manual update style instead. The nice thing about that though, I think, is that you aren’t forced to have the mode either on or off, you can have both behaviours at the same time.
And I agree, if it wasn’t basic I don’t think I would have been able to write it lol. Having the script be adapted into the program would be cool, if enough users decide they want it. However, I think the nice thing about having the tool as a separate script is that it doesn’t have to even appear in the menu to confuse those who don’t need to use it… though I guess it also makes it hard to find for those who do!
Well I’m pleased to see that no one has encountered any bugs so far! :yes: However, I have been aware of a problem with the script that occurs when subtracting weights so I thought I should fix it up before it causes anyone any grief. It actually turned out to be a simple fix with just 2 lines of code in the assignWeights() function.
The problem was that the script was assigning all weights to 0… so once a vert was a member of a group, it remained that way. Say you had an influence of 1, and you painted it down to 0.5 and updated it. All the other groups (even with 0 values) would be scaled up. Which can lead to very unpredictable behaviour during long sessions. So now the 0 weights are removed entirely. The script is intended to be used with ‘add’ in the paint tool anways, but I just wanted to make sure that subtracting didn’t cause problems.
I think this also fixed the ‘double transform’ problem I was getting with the normalizeOverlapping() function I mentioned in the video. So that works now too, though it doesn’t produce the exact result I was hoping it would. I think the function currently in use is better, so I left it as the default. But in case you want to try the other function you can comment out line 464 and use line 465. The problem is just that it doesn’t allow you to paint on the overlapping area, but it will keep the active weight locked. I’ll keep thinking about how to do it with the lock, and being able to paint on the opposite side, but I don’t think it’s urgent.