Jump to content

Bone Weight Copy in Blender 2.5x


Ashasekayi Ra
 Share

You are about to reply to a thread that has been inactive for 4591 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

While browsing BlenderArtist's site today for new addons, I saw that Jester_v01 updated the "bone weight copy" script from Blender 2.49 to work in Blender 2.57. The script copies weights from one model to another model (even if the vertex counts are different). It's great for making clothes for an avatar.

You can download the script from this thread.

However, the script doesn't work with the latest Blender 2.59. PKHG pointed out that there has been an API change.

After poking around in the file, I found that you only need to change two lines to get it to work with Blender 2.59.


Line 77: 
WSTargetVertsCo = [v.co*targetObject.matrix_world for v in targetObject.data.vertices]
Change to:
WSTargetVertsCo = [targetObject.matrix_world * v.co for v in targetObject.data.vertices]

Line 106:
v.co = v.co * baseObj.matrix_world
Change to:
v.co = baseObj.matrix_world * v.co

NOTE: Like the old 2.49 script, it takes time to calculate. However, it doesn't have a progress bar like the old script. So, Blender may look like it isn't responding, yet it is still working. The length of time you have to wait will depend on the interpolation setting that you pick and the number of vertices in the models.
Example: 824 vertices took 3 minutes to process with interpolation set to 1.

UPDATE:
You can find the latest version of Jester_v01's script (including my 2.59 patch and Gaia's extra functionality) here: http://blog.machinimatrix.org/bone-weight-copy-for-blender-2-59/

Video Tutorials:

  • Like 2
Link to comment
Share on other sites

  • Lindens


Ashasekayi Ra wrote:

While browsing BlenderArtist's site today for new addons, I saw that Jester_v01 updated the "bone weight copy" script from Blender 2.49 to work in Blender 2.57. The script copies weights from one model to another model (even if the vertex counts are different). It's great for making clothes for an avatar.

You can download the script from
.

However, the script doesn't work with the latest Blender 2.59. PKHG pointed out that there has been an API change.

After poking around in the file, I found that you only need to change two lines to get it to work with Blender 2.59.

Line 77: 
WSTargetVertsCo = [v.co*targetObject.matrix_world for v in targetObject.data.vertices]
Change to:
WSTargetVertsCo = [targetObject.matrix_world * v.co for v in targetObject.data.vertices]

Line 106:
v.co = v.co * baseObj.matrix_world
Change to:
v.co = baseObj.matrix_world * v.co

Woot!  Awesome news.

-prep

 

 

Link to comment
Share on other sites

Great news, I hope it makes it out into a real release soon :) Still on 2.49 thanks to rigged export issues, and bone weight copying missing in action.

By the way, I discovered something recently about doing bone weight copies using the "avatar.blend" that includes all the morph's. If you remove most of the vertex groups from the source avatar before doing the copy, your copies will go a great deal faster as the copier no longer has to find matches in your target mesh. And since none of those morph vertex groups have any use at all in the brave new mesh world, getting rid of them can't hurt, right? The long list of vertex groups includes all the facial emotes, and so on, so removing those does wonders for copy speed!

Unless of course morph'ing of meshes is coming soon?

 

Link to comment
Share on other sites


Fizz Savira wrote:

By the way, I discovered something recently about doing bone weight copies using the "avatar.blend" that includes all the morph's. If you remove most of the vertex groups from the source avatar before doing the copy, your copies will go a great deal faster as the copier no longer has to find matches in your target mesh. And since none of those morph vertex groups have any use at all in the brave new mesh world, getting rid of them can't hurt, right?

Well, yes and no ;-)

Yes: you only need the vertex groups starting with lowercase "m". All other vertex groups belong to morphs. Hence you could remove them from your blendfile and still get correct weights according to the SL specifications.

But: If you remove the morph groups, then the shape sliders no longer work in avatar.blend. As long as you do not use these sliders to tweek your mesh, you wont loose anything. And i suspect that only very few users have already discovered what actually can be done with the morph sliders ;-)

And here is one observation which might be important:

It appears to me that the bone weight copy only works, when the source mesh and the target mesh are both on visible layers during the copy. So either put both meshes on the same layer, or shift select the layers where the source and target mesh are located.

Link to comment
Share on other sites

I wouldn't necessarily wait for it to make it into the official release. All scripts aren't bundled with Blender. I've used plenty of useful one's over the years that never made it into the bundle.

As for the morphs, I strip them out of my donor avatar so that I can normalize and clean up weights, which get copied over to the clothing. However, I do keep a separate avatar on hand with the morphs still attached for other work.

Link to comment
Share on other sites

i have become curious again about programming ;-) So i have been talking to a blender developer, who is now looking after the progress bar. That part seems to be a blender internal thing and once it is done the bone weight copy can get a progress bar too ;-)

And i am thinking about adding a switch to the bone weight copy which would only copy/create the primary weight groups, aka those which are named exactly like the corresponding bones. That would allow to keep the morph groups intact... And it sounds to me like generally usefull.

Maybe it is also good to know, that you can install the script just like any other add on module from the File -> User Preferences page. You do not need to fiddle in the blender folders to get it to run.

Link to comment
Share on other sites


Gaia Clary wrote:

i have become curious again about programming ;-) So i have been talking to a blender developer, who is now looking after the progress bar. That part seems to be a blender internal thing and once it is done the bone weight copy can get a progress bar too ;-)

And i am thinking about adding a switch to the bone weight copy which would only copy/create the primary weight groups, aka those which are named exactly like the corresponding bones. That would allow to keep the morph groups intact... And it sounds to me like generally usefull.

Maybe it is also good to know, that you can install the script just like any other add on module from the File -> User Preferences page. You do not need to fiddle in the blender folders to get it to run.

That would be so great if it had a progress bar. I think some people will think it has crashed when it hasn't since there is no indicator of time left when you use it. Your idea of an on/off switch for morphs would be a nice addition as well.

Link to comment
Share on other sites

Darn and I just downloaded 2.59 tonight...I was using your tutorial for 2.49 in 2.57 and able to do everything up to the bone weight copy.

I hate to be a pain, but, where exactly do I have to poke to change those lines.

Your tutorial about rigging is incredible.

To find you and Gaia exchanging information is incredible...I direct as many people as I can to the two of you to learn about Blender, Sculptys and now mesh.

Thank you so much for all your hard work.

Link to comment
Share on other sites

  • download the file
  • open blender
  • File -> user preferences -> Add on modules -> install add on
  • navigate to the file, press "Install add on"
  • search the new entry named "3D View: Copy Bone Weights" in the list of Add-ons
  • enable it.
  • Save as Default

done

 

 

Link to comment
Share on other sites


Trix Braveheart wrote:

Darn and I just downloaded 2.59 tonight...I was using your tutorial for 2.49 in 2.57 and able to do everything up to the bone weight copy.

I hate to be a pain, but, where exactly do I have to poke to change those lines.

Your tutorial about rigging is incredible.

To find you and Gaia exchanging information is incredible...I direct as many people as I can to the two of you to learn about Blender, Sculptys and now mesh.

Thank you so much for all your hard work.

Thanks :) I'm glad to hear that you could use the tutorial to get through the process in Blender 2.57 too. I was worried it would confuse people using 2.5x versions since the UI is so different.  I probably should still update it just in case. As for changing Python scripts, I'll make a quicky video on how to change a line in a Python script tonight. It comes in handy if you use Blender a lot. 

Link to comment
Share on other sites

I may be doing this wrong, but this is the error I keep getting when I try and use the bone weight copy.

 

Traceback (most recent call last):  File "C:\Program Files\Blender Foundation\Blender\2.59\scripts\addons\space_view3d_copy_bone_weights.py", line 127, in execute    main(context)  File "C:\Program Files\Blender Foundation\Blender\2.59\scripts\addons\space_view3d_copy_bone_weights.py", line 98, in main    print(context.scene['BWCInter'])KeyError: 'bpy_struct[key]: key "BWCInter" not found'
location:<unknown location>:-1


Link to comment
Share on other sites

This file is not working for me. The console shows this error:

addon_utils.disable space_view3d_copy_bone_weights not loaded

None of the CBW shows in the Tool Shelf.

My install gives this error with each save of User Preferences: <!> event has invalid window

Anyone have any ideas?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4591 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...