Control any bone from any other bone (in the project!)
Moderators: Víctor Paredes, Belgarath, slowtiger
Control any bone from any other bone (in the project!)
I wrote this one for Ramón. He said it's okay to share, and it's working right nice now so here we go.
Embedded scripts are great. I'm seeing a lot of possibilities. This one (well two, but they do one thing) allows you to have one bone (the Master), anywhere in the project, control any other bone (the Control). Nifty little trick.
So, how to work it. To keep things simple, and so you can name your bones (basically) what you want, I used an extension, kinda like the winduhs file extensions. The bone that you want to be the Master needs to have ".mstr" at the end of the bone name. Needless to say, you have to give names to at least a couple of bones, even if you normally don't. The bone you want the Master bone to control needs to have ".ctrl" at the end of it's name. As I said, it doesn't matter a bit where the bone layers are in relation to each other. They can be 2 root bone layers, or nested 20 layers deep inside each other. No difference.
Go to Frame Zero. It's not totally necessary, but you'll get pointless error messages in the Lua console window until you do, so might as well make it easy from the start. In the Bone layer that the Master bone lives in, open the Layer Properties window and click on the "Embedded script file" box, and choose this script: bone_master.lua. In the Bone layer the Control bone is in, choose this one: bone_control.lua.
Go and play. Anything that the Master bone does (rotation, translation and scaling), the Control bone will mimic, in realtime (or as close to realtime as your animation can do). It's a pretty efficient little script, so it shouldn't slow things down much at all.
If anyone want's to really use it and needs instructions on how to mod the script so you can run multiple copies, I'll post that when you ask. But mess with it, it's pretty cool.
Embedded scripts are great. I'm seeing a lot of possibilities. This one (well two, but they do one thing) allows you to have one bone (the Master), anywhere in the project, control any other bone (the Control). Nifty little trick.
So, how to work it. To keep things simple, and so you can name your bones (basically) what you want, I used an extension, kinda like the winduhs file extensions. The bone that you want to be the Master needs to have ".mstr" at the end of the bone name. Needless to say, you have to give names to at least a couple of bones, even if you normally don't. The bone you want the Master bone to control needs to have ".ctrl" at the end of it's name. As I said, it doesn't matter a bit where the bone layers are in relation to each other. They can be 2 root bone layers, or nested 20 layers deep inside each other. No difference.
Go to Frame Zero. It's not totally necessary, but you'll get pointless error messages in the Lua console window until you do, so might as well make it easy from the start. In the Bone layer that the Master bone lives in, open the Layer Properties window and click on the "Embedded script file" box, and choose this script: bone_master.lua. In the Bone layer the Control bone is in, choose this one: bone_control.lua.
Go and play. Anything that the Master bone does (rotation, translation and scaling), the Control bone will mimic, in realtime (or as close to realtime as your animation can do). It's a pretty efficient little script, so it shouldn't slow things down much at all.
If anyone want's to really use it and needs instructions on how to mod the script so you can run multiple copies, I'll post that when you ask. But mess with it, it's pretty cool.
Hmmm... It practically saved my life and seems that anybody are too much interested about it ...Well, anyway I'll take advantadge of this post to say you THANK YOU again for this and for all! , LOOK AFTER YOURSELF!!!
PS: By the way, very happy all be well/better CIAO!
PS: By the way, very happy all be well/better CIAO!
Last edited by Rai López on Sat Dec 03, 2005 11:32 am, edited 1 time in total.
Being a slow, dumb person I am having a hard time visualizing or understanding when and why one would want to use this bones script: "Anything that the Master bone does (rotation, translation and scaling), the Control bone will mimic".
Can somebody post an animation (before and after using the script) or give a real example of why one would want to do this? I would like to try it out, but can´t think of what situation I would use it in.
Can somebody post an animation (before and after using the script) or give a real example of why one would want to do this? I would like to try it out, but can´t think of what situation I would use it in.
As I understood it, the reason I was asked to write it was so that a neck bone (in layer A) could bypass layer B entirely ( I'm figuring it's just a head shape or the like), with layer C being a bone layer with a few things happening in it, one of them being a group layer that contains the facial features . The facial features would be attached to a bone in layer C, and that bone would be mimic a bone that was controlled by (note controlled by, so you can use percentages of movement) a standardly controlled bone in layer A. To move the features depending on how the head is "turned". Thats what I thought, but of course I could be wrong, and maybe Ramon will bring us up to speed if I am. But that's what I thought when I was writing it.
Another idea. You have a caracter who is looking to the sky, and looking back and forth. That head bone is deeeeep in the project. But back in the root layers, you have another bone layer. With a bone in it that is a lot longer than that neck bone, and has a (ball? mousquito? flying saucer?) attaced to the end of it. So, regardless of where the character looks, or where the various bones are in the project, that character is looking at that thang flyin' around, always. And that's kinda cool.
Another idea. You have a caracter who is looking to the sky, and looking back and forth. That head bone is deeeeep in the project. But back in the root layers, you have another bone layer. With a bone in it that is a lot longer than that neck bone, and has a (ball? mousquito? flying saucer?) attaced to the end of it. So, regardless of where the character looks, or where the various bones are in the project, that character is looking at that thang flyin' around, always. And that's kinda cool.
Here's the (rather trivial) little test file that we used to test out the workings of the script. Just to give you a feel of what it does. It's meaningless, but kinda fun to play with.
thanks 7feet and Ramon, I think this one can be really useful. It will allow deeper levels of animation to be made with greater ease.
Question: How tricky would it be to modify this to command chains of bones? Is it simply a matter of running the script multiple times, once for each bone?
Question: How tricky would it be to modify this to command chains of bones? Is it simply a matter of running the script multiple times, once for each bone?
Create cartoon characters and comics in minutes: www.bitstrips.com
Hey 7feet this sounds interesting. I don't have time to test it yet but I am wondering if it can be set so one Master can control several Control bones? The reason I ask is -if I am understanding this right- it might be useful for synchronizing the movement of several objects. For example you attach a master to several objects you want to be blown in the wind and then you just yank the Master bone to have the guys hair, chair and other objects blown at once.
I also did that test with a school of fish some time back if you might remember? They were all connected by bones and so I could animate the school by pulling the lead bone. Well if you could create multiple small groups like this and then attach them to a master bone you would have the option of moving each individually -say 5 small schools- and when needed have them all move together by dragging the master.
I also wonder if it might be possible to do what I suggested way back and emulate this somehow
http://www.digitalcarversguild.com/plug ... roductId=6
by using a master bone to control several mechanical movements -have gears spinning and so on using one Master bone to synchronize it all (one ring to rule them) -might not be clear since I haven't tested your script yet.
Anyway just a quick thought or two ...
I also did that test with a school of fish some time back if you might remember? They were all connected by bones and so I could animate the school by pulling the lead bone. Well if you could create multiple small groups like this and then attach them to a master bone you would have the option of moving each individually -say 5 small schools- and when needed have them all move together by dragging the master.
I also wonder if it might be possible to do what I suggested way back and emulate this somehow
http://www.digitalcarversguild.com/plug ... roductId=6
by using a master bone to control several mechanical movements -have gears spinning and so on using one Master bone to synchronize it all (one ring to rule them) -might not be clear since I haven't tested your script yet.
Anyway just a quick thought or two ...
[url=http://burtabreu.animationblogspot.com:2gityfdw]My AnimationBlogSpot[/url:2gityfdw]
The scripts are easy enough to understand (at least for me) and the description by 7feet is clear enough as well.
Here's a tiny fish tank animation
• fish.mov
• fish.moho
The big fish controls the relative positions, length and rotation of the three small fishes.
With a few modifications to the master and control scripts, one could even synchronize several named bones in one bone layer with bones which have identical bone names in other bone layers, so a bunch of different characters walk, jump etc. in synch. I will try that tomorrow.
Here's a tiny fish tank animation
• fish.mov
• fish.moho
The big fish controls the relative positions, length and rotation of the three small fishes.
With a few modifications to the master and control scripts, one could even synchronize several named bones in one bone layer with bones which have identical bone names in other bone layers, so a bunch of different characters walk, jump etc. in synch. I will try that tomorrow.
Vey sorry. I had written about a thousand words of very cool description on what to do with this damn thing and then Firefox crashed on me. I guess i.5 ain't so stable yet. So Quickstyle.
BA- yeah, not too hard. Not gonna retype the full instructions right now, but it's pretty easy.
bupaje - a version to control layer movements by the master bone momentarily (I think that one is pretty cool). If you want to use multiple versions of the Master script, that's a different thing, but as it stands you can assign as many vesions of the control script you like and those bone layers will be controlled. 2, a thousand, should be fine. For the blowing in the wind thing, you could put a variable in each version of the control script that would scale the movement of the master, so .... okay. one tree branch moves at 1 to 1 with the master, one farther back in the tree is 2 to 1, etc. That kinda tweak would be fun with your fish. -- Oh my. Just a thought, and I'm still not so solid on how Moho works in the guts. Could this technique be used to control bone layers within particle layers? On the fly? I think it might! Now, that would be cool. Because the script uses the same technique as the "hanging bone" script. Its continuously varying the "Frame Zero" values of the bone. So, because it's using a trick (crafty thought, thanks LM) to make Moho think those values are different every frame, it should be possible to diddle similarly with sublayers of particle layers.
Raheed - for some reason the link aink working. Sucks, I wanted to see what somebody else had done with it.
'Cuz Ramón's too scare to show us anything he's working on (yes, Ramón that was meant to be provocative).
And Toontoonz, stop beating yerself on the head. I know some dumb folks, and every one refuses to ask questions. Defines it for me. I won't go so far as saying there are no stupid questions ("whats yer sign" comes to mind) but they're few and far between, when you get a techminical.
BA- yeah, not too hard. Not gonna retype the full instructions right now, but it's pretty easy.
bupaje - a version to control layer movements by the master bone momentarily (I think that one is pretty cool). If you want to use multiple versions of the Master script, that's a different thing, but as it stands you can assign as many vesions of the control script you like and those bone layers will be controlled. 2, a thousand, should be fine. For the blowing in the wind thing, you could put a variable in each version of the control script that would scale the movement of the master, so .... okay. one tree branch moves at 1 to 1 with the master, one farther back in the tree is 2 to 1, etc. That kinda tweak would be fun with your fish. -- Oh my. Just a thought, and I'm still not so solid on how Moho works in the guts. Could this technique be used to control bone layers within particle layers? On the fly? I think it might! Now, that would be cool. Because the script uses the same technique as the "hanging bone" script. Its continuously varying the "Frame Zero" values of the bone. So, because it's using a trick (crafty thought, thanks LM) to make Moho think those values are different every frame, it should be possible to diddle similarly with sublayers of particle layers.
Raheed - for some reason the link aink working. Sucks, I wanted to see what somebody else had done with it.
'Cuz Ramón's too scare to show us anything he's working on (yes, Ramón that was meant to be provocative).
And Toontoonz, stop beating yerself on the head. I know some dumb folks, and every one refuses to ask questions. Defines it for me. I won't go so far as saying there are no stupid questions ("whats yer sign" comes to mind) but they're few and far between, when you get a techminical.