Master/Control bone "multibone" layer scripts...
Moderators: Víctor Paredes, Belgarath, slowtiger
Master/Control bone "multibone" layer scripts...
These scripts have been completely changed. If you were using the old ones... your file won't work the same.
Just some small modifications will make it work again though.
I rewrote this set of scripts to allow controlling multiple bones on different layers from one master bone layer. You can download the zip file that includes a demonstration project. You may have to relink the scripts to the layers.
If you have more questions just post them here.
Here is a quick description of how it works:
Name the bones any dang thing you want. Just make sure each master and control bone have the same name and end with .mcb
rtthigh.mcb
On frame 0 assign the bone_master_v1.lua script to the master bone layer.
On frame 0 assign the bone_control_v1.lua script to any slave or controlled bone layers. As many as you want for that one master bone layer.
You can delete bones that aren't needed... BUT you must maintain the bone parenting up to the bone that needs to be controlled.
In the example the "blue" arms don't have leg bones or a head bone. But it needs the hip, torso and all the arm bones.
If you want multiple separate master/slave relationships you need to make a copy of each script and change the variable indicated in the comments... not that bad really. I would like just one set of scripts I just haven't figured it out yet.
IMPORTANT!!
The master bone layer must be below any controlled bone layer in the layer hierarchy!
Sorry about this... I couldn't figure out why this is so... and I have yet to find a solution. But for now the master bone layer must be last. It must be below any bone layers controlled by it.
It still works if it isn't but... there is a one frame "lag" updating the bones translation and rotation. This was the problem I have had since I started this... I only just figured out it had to do with layer order.
Known issues
Occassionally if you scrub really fast through the time line the script will sort of... break. If that happens or you get an error... just click on frame 0 again and everything will go back to normal.
When animating the master bone layer, the slave bone layers will not update immediately. You must click on the frame in the time line or scrub the time line to force the bones to update.
-------------------------
To make it easy, create the master bone layer first. Name all the bones just the way you want them and include .mcb at the end of each bone name that you want to control. You can leave the .mcb extension off of a bone and it won't be controlled.
For instance some kind of object in the hand of a character... that bone could be a child of the hand bone and controlled by the hand bone... but the object bone could be independantly translated and rotated.
After creating the master bone layer you can duplicate it... and put it anywhere in the layer structure you want.
You could for example put copies of a controlled bone layer inside different groups with masking to create complex masking that is still controlled by one bone layer.
Comments and suggestions are welcome. Any expert coders want to fix this thing and make it better... pleeeeeese.... I would be ever so greatful.
I have been using these scripts on almost all of my current projects... for masking... interacting characters... etc. I really like it and it saves time. You don't have to keep copying and pasting animated bone layers into different spots for layered effects.
The slaved bones can be anywhere in the layer hierarchy... anywhere... and they always work... they just have to be above the master layer of course.
http://www.lowrestv.com/moho_stuff/bone_master2.mov
http://www.lowrestv.com/moho_stuff/bone ... script.zip
-Vern
Just some small modifications will make it work again though.
I rewrote this set of scripts to allow controlling multiple bones on different layers from one master bone layer. You can download the zip file that includes a demonstration project. You may have to relink the scripts to the layers.
If you have more questions just post them here.
Here is a quick description of how it works:
Name the bones any dang thing you want. Just make sure each master and control bone have the same name and end with .mcb
rtthigh.mcb
On frame 0 assign the bone_master_v1.lua script to the master bone layer.
On frame 0 assign the bone_control_v1.lua script to any slave or controlled bone layers. As many as you want for that one master bone layer.
You can delete bones that aren't needed... BUT you must maintain the bone parenting up to the bone that needs to be controlled.
In the example the "blue" arms don't have leg bones or a head bone. But it needs the hip, torso and all the arm bones.
If you want multiple separate master/slave relationships you need to make a copy of each script and change the variable indicated in the comments... not that bad really. I would like just one set of scripts I just haven't figured it out yet.
IMPORTANT!!
The master bone layer must be below any controlled bone layer in the layer hierarchy!
Sorry about this... I couldn't figure out why this is so... and I have yet to find a solution. But for now the master bone layer must be last. It must be below any bone layers controlled by it.
It still works if it isn't but... there is a one frame "lag" updating the bones translation and rotation. This was the problem I have had since I started this... I only just figured out it had to do with layer order.
Known issues
Occassionally if you scrub really fast through the time line the script will sort of... break. If that happens or you get an error... just click on frame 0 again and everything will go back to normal.
When animating the master bone layer, the slave bone layers will not update immediately. You must click on the frame in the time line or scrub the time line to force the bones to update.
-------------------------
To make it easy, create the master bone layer first. Name all the bones just the way you want them and include .mcb at the end of each bone name that you want to control. You can leave the .mcb extension off of a bone and it won't be controlled.
For instance some kind of object in the hand of a character... that bone could be a child of the hand bone and controlled by the hand bone... but the object bone could be independantly translated and rotated.
After creating the master bone layer you can duplicate it... and put it anywhere in the layer structure you want.
You could for example put copies of a controlled bone layer inside different groups with masking to create complex masking that is still controlled by one bone layer.
Comments and suggestions are welcome. Any expert coders want to fix this thing and make it better... pleeeeeese.... I would be ever so greatful.
I have been using these scripts on almost all of my current projects... for masking... interacting characters... etc. I really like it and it saves time. You don't have to keep copying and pasting animated bone layers into different spots for layered effects.
The slaved bones can be anywhere in the layer hierarchy... anywhere... and they always work... they just have to be above the master layer of course.
http://www.lowrestv.com/moho_stuff/bone_master2.mov
http://www.lowrestv.com/moho_stuff/bone ... script.zip
-Vern
Last edited by heyvern on Wed Jul 19, 2006 12:08 am, edited 5 times in total.
I wanted to give a little background on why I did this and how powerful and usefull it could be.
It involves the limitations of masking mostly... that's where it started anyway. It also involves multiple characters interacting and being able to animate all the bones from one layer.
In some cases I would like to have masking in completely separate bone layers... yet I need these masks and masked objects to be controlled by the exact same bones in another layer or group.
For instance I use a lot shading and soft edge effects. This can cause a blurry halo around shapes.
I can hide this using a mask. But what about an arm over the body? If I use basic masking on the whole body including the arms in that bone layer a "blurry halo" shows up when the arms pass over the body and the halo is not masked. The body is part of the same mask as the arms.
So... duplicate that bone layer with the arms... delete the other bones and everything else but the arms and move the arms out into another group with different masking outside of the main body...
... but now I have all the bones for the arms in a separate layer... so I have to constantly switch layers to animate. And those layers can be nested as well... switching around can get complicated.
By using these scripts I can have as many duplicate bone layers for complex masking as I want. Just link those bones to a "master set" of bones... and I can animate ALL those layers from one bone layer.
I had another situation with two characters interacting. One arm of one needed to be in front of the other character... the other behind. Yes... put those parts on different layers... but now you have to switch from one arm layer to the other just to animate... slows down the creativity.
Imagine having all the parts of the body each in a separate bone layer in any order you want.
With these scripts you can control ALL of those parts from one "master set" of bones. No more switching layers to animate different parts.
Not only that but you could even have a bone layer with no vector layers in it at all controling all the other bones.
Yes... still editing changes to the bones positions on all those layers might be tricky if you need to later... but the control this gives you is pretty powerful.
I plan to continue improving these scripts. They are really cool... for me anyway.
Thank you 7feet! Never would have thought to try this on my own without your inspiration.
-Vern
It involves the limitations of masking mostly... that's where it started anyway. It also involves multiple characters interacting and being able to animate all the bones from one layer.
In some cases I would like to have masking in completely separate bone layers... yet I need these masks and masked objects to be controlled by the exact same bones in another layer or group.
For instance I use a lot shading and soft edge effects. This can cause a blurry halo around shapes.
I can hide this using a mask. But what about an arm over the body? If I use basic masking on the whole body including the arms in that bone layer a "blurry halo" shows up when the arms pass over the body and the halo is not masked. The body is part of the same mask as the arms.
So... duplicate that bone layer with the arms... delete the other bones and everything else but the arms and move the arms out into another group with different masking outside of the main body...
... but now I have all the bones for the arms in a separate layer... so I have to constantly switch layers to animate. And those layers can be nested as well... switching around can get complicated.
By using these scripts I can have as many duplicate bone layers for complex masking as I want. Just link those bones to a "master set" of bones... and I can animate ALL those layers from one bone layer.
I had another situation with two characters interacting. One arm of one needed to be in front of the other character... the other behind. Yes... put those parts on different layers... but now you have to switch from one arm layer to the other just to animate... slows down the creativity.
Imagine having all the parts of the body each in a separate bone layer in any order you want.
With these scripts you can control ALL of those parts from one "master set" of bones. No more switching layers to animate different parts.
Not only that but you could even have a bone layer with no vector layers in it at all controling all the other bones.
Yes... still editing changes to the bones positions on all those layers might be tricky if you need to later... but the control this gives you is pretty powerful.
I plan to continue improving these scripts. They are really cool... for me anyway.

Thank you 7feet! Never would have thought to try this on my own without your inspiration.
-Vern
Okay I slapped this moho file together... please... don't judge the hideous content... it is ugly and thrown together in 20 minutes.
===================================
OLD FILE WAS HERE... no good. Use the link in the first post.
===================================
I set it up with copies of the control script for each body part; head, body, left arm... etc.
In the folder after you unzip it is the project and a folder with the scripts. Hopefully the scripts should stay linked to the project. If not you would need to relink them. The scripts are named so you know which bone layer gets which script.
The top layer, MCB (master control bones) gets the bone_master.lua script.
This is the most extreme scenario. Each body part is its own bone layer. You can put them in any order... put them in groups... move them anywhere you want and you still animate from the "MCB (master control bones)" layer at the top of the layer list.
Note also that each bone part layer has the "chain" of bones up to that bone... otherwise the script won't know where to put it so to speak.
You could also do the exact same thing with only one control script... but you would need to either... leave all the bones in place for each layer... or use bone offset to put each bone part into place... similar to what we do when using bone offset for region binding.
For example... without using bone offset on layer 0 the head bone layer needs to have all the parent bones up to the top bone... the neck, the torso, the hips (1.mstr1) (The hips are the parent) in order to have the bones in those "part" layers positioned properly.
Also I didn't bother renaming all the bones. In most cases they all have exactly the same name as the master bones and each other. Doesn't matter with the script. It just matches the numbers of the control to the master... name makes no difference.
It is a bit slow when animating... it doesn't update as quick as I would like but still... I really like how this is going. It isn't that slow and the final render will be perfect.
I realize now I could add a bunch of stuff to this... like... somehow "copying" bone offset so that the whole chain of bones isn't needed for each layer... stuff like that...
Another cool thing! You can use flexible binding on different bone layers without worrying about the bones effecting other parts of the mesh on different layers!!!
I used this trick for a dress on one of my characters. I needed flexible binding just on the dress... the dress was controlled by bones in the body on my master bone layer... but controlled on a separate bone layer with flexible binding.
-Vern
===================================
OLD FILE WAS HERE... no good. Use the link in the first post.
===================================
I set it up with copies of the control script for each body part; head, body, left arm... etc.
In the folder after you unzip it is the project and a folder with the scripts. Hopefully the scripts should stay linked to the project. If not you would need to relink them. The scripts are named so you know which bone layer gets which script.
The top layer, MCB (master control bones) gets the bone_master.lua script.
This is the most extreme scenario. Each body part is its own bone layer. You can put them in any order... put them in groups... move them anywhere you want and you still animate from the "MCB (master control bones)" layer at the top of the layer list.
Note also that each bone part layer has the "chain" of bones up to that bone... otherwise the script won't know where to put it so to speak.
You could also do the exact same thing with only one control script... but you would need to either... leave all the bones in place for each layer... or use bone offset to put each bone part into place... similar to what we do when using bone offset for region binding.
For example... without using bone offset on layer 0 the head bone layer needs to have all the parent bones up to the top bone... the neck, the torso, the hips (1.mstr1) (The hips are the parent) in order to have the bones in those "part" layers positioned properly.
Also I didn't bother renaming all the bones. In most cases they all have exactly the same name as the master bones and each other. Doesn't matter with the script. It just matches the numbers of the control to the master... name makes no difference.
It is a bit slow when animating... it doesn't update as quick as I would like but still... I really like how this is going. It isn't that slow and the final render will be perfect.
I realize now I could add a bunch of stuff to this... like... somehow "copying" bone offset so that the whole chain of bones isn't needed for each layer... stuff like that...
Another cool thing! You can use flexible binding on different bone layers without worrying about the bones effecting other parts of the mesh on different layers!!!
I used this trick for a dress on one of my characters. I needed flexible binding just on the dress... the dress was controlled by bones in the body on my master bone layer... but controlled on a separate bone layer with flexible binding.
-Vern
Last edited by heyvern on Tue Jul 18, 2006 11:58 pm, edited 1 time in total.
sounds like exactly what i've been hoping for since first reading about 7feet's master bone script.... the possibilities this could afford are HUGE.
really looking forward to testing this out when I have the time!!!
really looking forward to testing this out when I have the time!!!
Create cartoon characters and comics in minutes: www.bitstrips.com
Thanks for the comments.
I have been using this now for almost all of my animations for a 7 minute pitch I am putting together. I keep finding a need for it.
What I have found with extensive use is bone naming needs to be fixed. That will be my first update.
Currently the way I implemented it was... short sighted... I have problems thinking out side the box sometimes.
The funny thing is... the names of the bones are already "captured" by the script and then I go to all this trouble requiring a numbered extension... very stupid... what I should do is link the bones by name only as was suggested in another thread on this topic. This would make it much easier to set up the Moho project.
I want the bones for both master and control to be able to have the same name so you can just duplicate a bone layer and not have to change all of the bone names. That is how it works now... but having to keep track of numbering the bones... when they could just have the same name... seems silly.
... my head hurts...
-Vern
I have been using this now for almost all of my animations for a 7 minute pitch I am putting together. I keep finding a need for it.
What I have found with extensive use is bone naming needs to be fixed. That will be my first update.
Currently the way I implemented it was... short sighted... I have problems thinking out side the box sometimes.
The funny thing is... the names of the bones are already "captured" by the script and then I go to all this trouble requiring a numbered extension... very stupid... what I should do is link the bones by name only as was suggested in another thread on this topic. This would make it much easier to set up the Moho project.
I want the bones for both master and control to be able to have the same name so you can just duplicate a bone layer and not have to change all of the bone names. That is how it works now... but having to keep track of numbering the bones... when they could just have the same name... seems silly.
... my head hurts...
-Vern
haven't had the chance to try it out yet -
but from just imagining using it, it seems to me that an added trick that would really make it easier to set up such a rig would be the ability to somehow copy bones or groups of bones between bone layers...
say I have a foot skeleton and a hand skeleton (both layers duplicated of course), and I want to create a master bone layer that controls all the bones in both/all subskeletons - how do I copy the intricate bone-rig from 2 skeletons into 1?
I'm sure the copy bones issue has come up in other threads... just wondering if anyone ever found a solution. Or, heyvern, what's your strategy for controlling multiple skeletons at once?
but from just imagining using it, it seems to me that an added trick that would really make it easier to set up such a rig would be the ability to somehow copy bones or groups of bones between bone layers...
say I have a foot skeleton and a hand skeleton (both layers duplicated of course), and I want to create a master bone layer that controls all the bones in both/all subskeletons - how do I copy the intricate bone-rig from 2 skeletons into 1?
I'm sure the copy bones issue has come up in other threads... just wondering if anyone ever found a solution. Or, heyvern, what's your strategy for controlling multiple skeletons at once?
Create cartoon characters and comics in minutes: www.bitstrips.com
Currently there is no "easy" way to copy bones between layers... or even inside layers.
I just duplicate the bone layer. If I get really really ambitious... I sometimes will copy bones using a text editor... this is not fun.
-------------------
I have discovered something with this set of scripts that makes me very happy though...
The bones that control the actual points or vectors should be "perfect"... meaning... set them up carefully as you would normally so they work properly... but...
The master bones don't have to be!
The way I use this the master bones don't actually do anything... or control anything. So it doesn't really matter how close they are to the same position or angle of the bones they control.
Lately I actually use this intentionally...
I put spine control bones off to the side a character so I can easily grab and move those bones.
-----------------
I have just finished fixing my bone control scripts but I am still fiddling.
You only need one control script for as many bone layers as you need. It works great thanks to the tip from Fazek, our new "7feet".
I changed the naming requirements so you just put a simple extension on the end of the name of any "bone pair" you want controlled/mastered.
The only problem is... if you need more than one "set" or pair of master/control bones you still need to duplicate and modify the scripts.
I see no way around this. The master bone "list" must be accessible to the controlled bones layer script. The only way to do that is with a global variable... so... you need to make that variable unique for each pair of scripts.
Not nearly as bad as needing a script for each layer as before. That was a pain.
I plan to upload a new version once I finish playing around with it. I keep getting this weird bug where the script stops working and you have to click on frame 0 to "reset" it.
-Vern
I just duplicate the bone layer. If I get really really ambitious... I sometimes will copy bones using a text editor... this is not fun.
-------------------
I have discovered something with this set of scripts that makes me very happy though...
The bones that control the actual points or vectors should be "perfect"... meaning... set them up carefully as you would normally so they work properly... but...
The master bones don't have to be!
The way I use this the master bones don't actually do anything... or control anything. So it doesn't really matter how close they are to the same position or angle of the bones they control.
Lately I actually use this intentionally...
I put spine control bones off to the side a character so I can easily grab and move those bones.
-----------------
I have just finished fixing my bone control scripts but I am still fiddling.
You only need one control script for as many bone layers as you need. It works great thanks to the tip from Fazek, our new "7feet".

I changed the naming requirements so you just put a simple extension on the end of the name of any "bone pair" you want controlled/mastered.
The only problem is... if you need more than one "set" or pair of master/control bones you still need to duplicate and modify the scripts.
I see no way around this. The master bone "list" must be accessible to the controlled bones layer script. The only way to do that is with a global variable... so... you need to make that variable unique for each pair of scripts.
Not nearly as bad as needing a script for each layer as before. That was a pain.
I plan to upload a new version once I finish playing around with it. I keep getting this weird bug where the script stops working and you have to click on frame 0 to "reset" it.
-Vern
Re: Master/Control bone "multibone" layer scripts.
I think this comes out because Moho calculating the geometrical parameters within the rendering pass. ie. it calculates the geometry of the first layer, calls LayerScript, renders the first layer, calculates the geometry of the second layer and so on. I think this was the original order and the Layerscript solution added later to this system. Without LayerScript, this works perfectly. To use the LayerScript with full of its power, I think it would be better to calculate the geometry of all layers before rendering, in a separated pass. With this, a LayerScript would be able to modify any geometrical parameters in any (other) layers (think how powerful...). I think this is not a big overhead in memory, and it doesn't slows the rendering at all. I hope changing Moho this way would remain compatible with the existing LayerScripts.heyvern wrote: IMPORTANT!!
The master bone layer must be below any controlled bone layer in the layer hierarchy!
Because of this, my MeshInstance script works the same way as yours, except I made only a single LayerScript for all of the layers and it decides that the actual layer is a master or a copy, from the layer's name. This solution is good because you can simply rename the layer if the order is wrong.
- - - Fazek
Thanks Fazek,
That makes sense the way you describe it... I was putting "update bone matrix" code all over the place... I thought maybe it had something to do with that or... maybe I could "trick" it into updating... <sigh>
The funny part was before I knew what the heck was causing it... sometimes it did sometimes it didn't... had no idea it was the order of the layers. Very funny in hind sight. If it was a snake it would have bit me.
Actually... at first I didn't even realize there was a problem. On duplicated controlled layers I would delete the meshes I didn't need... or make them invisible... so I never saw that they were "offset" and the renders were fine... just off by one frame (I didn't really know that).
It wasn't until I had two layers visible that were controlled... one was off a frame the other wasn't... drove me nuts.
-----------
Good tip for making it one script! Seems obvious now. It is easy to name the layers to match the script.
I will have to try that when I get a chance. It took me an age to get where I am now... had to force myself to post it even with some of the issues.
I felt bad keeping it to myself... I use it like crazy. It really is POWERFUL. I don't think it is obvious what it can do until you start to play with it.
I have a project with some CRAAAZY masking... group layers inside group layers... and.. all controlled by one bone layer... I never even open that group folder anymore... scary.
One script... man! If I can get that working it will be almost perfect.
-vern
That makes sense the way you describe it... I was putting "update bone matrix" code all over the place... I thought maybe it had something to do with that or... maybe I could "trick" it into updating... <sigh>
The funny part was before I knew what the heck was causing it... sometimes it did sometimes it didn't... had no idea it was the order of the layers. Very funny in hind sight. If it was a snake it would have bit me.

Actually... at first I didn't even realize there was a problem. On duplicated controlled layers I would delete the meshes I didn't need... or make them invisible... so I never saw that they were "offset" and the renders were fine... just off by one frame (I didn't really know that).
It wasn't until I had two layers visible that were controlled... one was off a frame the other wasn't... drove me nuts.

-----------
Good tip for making it one script! Seems obvious now. It is easy to name the layers to match the script.
I will have to try that when I get a chance. It took me an age to get where I am now... had to force myself to post it even with some of the issues.
I felt bad keeping it to myself... I use it like crazy. It really is POWERFUL. I don't think it is obvious what it can do until you start to play with it.
I have a project with some CRAAAZY masking... group layers inside group layers... and.. all controlled by one bone layer... I never even open that group folder anymore... scary.
One script... man! If I can get that working it will be almost perfect.
-vern
I'm in the midst of trying this out now, since I'm about to start a big animation and having master/control bones would really come in handy...
but I find that the lag between positioning the master bones and seeing the control bones update is too much of a disconnect. When I'm posing a character, I need to see how it looks while I'm posing it in realtime.
Any insight on why this gap is the way it is, and whether it can be somehow fixed?
I was also checking out 7feet's similar script, which had stranger results but at least worked in realtime. perhaps a comparison of the 2 methods might yield a clue??
but I find that the lag between positioning the master bones and seeing the control bones update is too much of a disconnect. When I'm posing a character, I need to see how it looks while I'm posing it in realtime.
Any insight on why this gap is the way it is, and whether it can be somehow fixed?
I was also checking out 7feet's similar script, which had stranger results but at least worked in realtime. perhaps a comparison of the 2 methods might yield a clue??
Create cartoon characters and comics in minutes: www.bitstrips.com
Layers are 'userdata' type structures in Moho but you can expand them with any custom variable. (userdata is a 'frontend' for a C program to communicate with Lua programs). This may cause a solution if the layer searching and calculating takes too much time:
- use one master Layerscript which calculates all possible parameters for all of the layers and puts the results as 'cached' variables, into the controlled layers.
- then, in the controlled layers. the LayerScript just copies the results from the cached variables into the real variables (perhaps with a little calculation, if it depends on the actual geometry).
It is also possible to use a global variable to exchange common parameters between layers with a 'calculated' name, use _G[string_variable_or_expression].
I have a very rough idea how to use any layer as a virtual master. It must be done with the bone (or point) modifying tool. If you change something by hand in a controlled layer, it searches the other layers and change the thing there too. In this case, you don't need to use LayerScript, but perhaps this is not working well between the keyframes.
- use one master Layerscript which calculates all possible parameters for all of the layers and puts the results as 'cached' variables, into the controlled layers.
- then, in the controlled layers. the LayerScript just copies the results from the cached variables into the real variables (perhaps with a little calculation, if it depends on the actual geometry).
It is also possible to use a global variable to exchange common parameters between layers with a 'calculated' name, use _G[string_variable_or_expression].
I have a very rough idea how to use any layer as a virtual master. It must be done with the bone (or point) modifying tool. If you change something by hand in a controlled layer, it searches the other layers and change the thing there too. In this case, you don't need to use LayerScript, but perhaps this is not working well between the keyframes.
- - - Fazek