Control any bone from any other bone (in the project!)

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Post by Rasheed »

7feet (Brian), if you want me to send you a ZIP archive (containing the .mov and .moho files) via e-mail, please send me a PM and I do it.
_____

Just some thoughts about the script.

I thought using only one script instead of two would be better. In that case the master and control bone can be in the same bone layer.

Furthermore, if one of the bone names .ctrl or .mstr is missing, the script should perhaps not report a LUA console message, but simply do nothing.
_____

A cool variation on the script could be to create a kind of "follow-the-leader script", in which the controls copy the path of the master, instead of the movements. So, the controls do exactly what the master does, but delayed by a certain amount of frames.

The script should establish how many frames ago the master was closest to the position of the control. This then is the frame lag between master and control. In the first few frames, the control should just stay at the same relative position and in such a way that it will cross the path of the master. When the control is near a position the master occupied some frames ago, follow-the-leader part kicks in.
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Post by Rasheed »

Rasheed wrote: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.
Well, I looked into this and it proved to be a lot more complex than I originally thought. It's no simple tweaking, but the scripts should be completely rewritten.

The idea is as follows:
Script for the control bone(s):
• In frame 0, check for any named bones which have more than 5 characters and end with ".ctrl". Retrieve the name without the ".ctrl" and that's the bone's name. Put all the variables in arrays.
• Outside frame 0, check for every named control bone if there is a master bone with the same name, and do the same relative changes to the control bone as was recording for the master bone.

Script for the master bone(s):
• In frame 0, do the similar name check as in the control bone script and put all the variables in arrays.
• Outside frame 0, for every named master bone, record the changes relative to frame 0 in the corresponding arrays.

Of course, programming is in the finer details and it takes time to write good code (especially if one is not familiar with the Lua language).

The purpose of all this is to enable several master-control combinations, and therefore do more complex synchronized animation automatically, just by naming the bones correctly, putting the scripts in and moving the master bones.
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

Post by bupaje »

@7feet

Tried to send you this privately so as not to embaress myself with my occasionally incoherent postings but it is still sitting in my Outbox for some reason so figured I'd risk it.

I was sneaking a look at the forums from work and had the beginnings of an idea.

I saw this image in the Bug forum



Image

and it made me wonder about a post your made regarding embedded scripts. You suggested in your script thread

"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."

which made me wonder if you could do something like link the light source, ball (or other object) and shadow so that the ball rotates so it faces the light as it bounces and the shadow could move so that it follows a ray from the light, through the ball to get its location. You can see why I didn't want to post it as I can't quite get it out.

Here is a very quick illustration


Image

Not sure if the idea makes sense but figured it might be a way to have shadows appear to react to a light source and maybe do some other stuff.

If it is a wacky idea then I apologize, just firing it off during a break at work. :)

Regards,

Burt
[url=http://burtabreu.animationblogspot.com:2gityfdw]My AnimationBlogSpot[/url:2gityfdw]
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Not really wacky at all. Got me thinkin'. Off the top I don't think it would be so hard if it's for a single light source. Let me ponder a bit...
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

Post by bupaje »

That's a relief, I was considering deleting it just in case. :)

I meant to say that the highlight on the ball would rotate to face the light source.

Also thinking it might be possible to do other stuff with this but if you do come up with something (easy enough for me ;) ) then I'll make samples instead of trying to explain. :)
[url=http://burtabreu.animationblogspot.com:2gityfdw]My AnimationBlogSpot[/url:2gityfdw]
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

7feet wrote: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.
it is tragic that this information was lost.

Any chance of getting an update on how to do this?

Having duplicate controlled skeletons would be really, really handy!
Create cartoon characters and comics in minutes: www.bitstrips.com
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

7feet wrote: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.
i am resuming my request for the multibone info. please let me know!!!
Create cartoon characters and comics in minutes: www.bitstrips.com
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

one more time -

pretty please - any hints at how to make this work for multiple bones at once? this could be sooo powerful, but my attempts at using it for more than one bone at a time are yeilding strange and somewhat buggy results....

also, now's the time i need it most - trying to finish a complex character within the next week.

if there was ever a script that deserved to be nudged a bit further to perfection, it was this one....
Create cartoon characters and comics in minutes: www.bitstrips.com
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

BA,

I made my own revised version for multiple bones here:

http://www.lostmarble.com/forum/viewtopic.php?t=3465



-vern
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

thanks vern,

i tried yours, and it seemed easy to set up and use - but the fact that the controlled bone didn't update in realtime made it less useful to me... for this to be truly effective, since I can't see the bones that are being controlled, I need to see the effects as I'm manipulating the master bone, in realtime.

I've gotten 7feet's script to work as far as having 2 control bones (in separate layers) controlled by 1 master bone (in its own layer), but once you start dealing with multiple bones within the same layer (either master or control), it breaks down.

What would be the ultimate would be a combination of your script and his script, so that you could set as many relationships as you want and then tweak them in realtime...
Create cartoon characters and comics in minutes: www.bitstrips.com
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

I'll have to look at that script again, I've learned a fair bit since I wrote it and it shouldn't be too hard to make it much more flexible. Just as soon as I get myself moved. If I do, I thought I had a place lined up, and then the bastids backed out on me. Scrambling for a new place on the last day of the month really, really sucks. But I will do some work on it, I gots me a few ideas...
teotoon
Posts: 135
Joined: Wed Aug 04, 2004 7:19 am
Location: Turkey

Post by teotoon »

Hey BA,

I have a tip for Heyvern's script: I don't know why, but if you turn on the onion skin (somewhere in the timeline), you can see the movements in real time...
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I have found it depends on how comlex the file is too.

I have really small simple files that update in real time. When they get big with lots of bones and layers... it doesn't.

I have no idea why. Probably a memory issue. My script might not be... uh... sleek and trim.

;)

-vern
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

7feet wrote:I'll have to look at that script again, I've learned a fair bit since I wrote it and it shouldn't be too hard to make it much more flexible.
Hey 7feet, if you can update this sometime soon, you will be upgraded from hero to SUPERhero, in my books....

trying to finish a character this week, for an animation that must start in 2 weeks...

by the way, good luck on the move! or, if it's already happened, I hope it all worked out... I was in the same boat last time I moved. Found the place the night before the 1st, signed the lease the next morning, moved in that afternoon. Stressful indeed! Remember to set up your computer before anything else... ;)
Create cartoon characters and comics in minutes: www.bitstrips.com
theos
Posts: 9
Joined: Tue Aug 29, 2006 4:52 pm

Bone parenting on two switches

Post by theos »

Hi there!

7feet, I tried your script and thought it could work on a hierarchy of bones but realized it might not have been written for this purpose. What I tried to achieve was having a character body in a root switch(for morphing the body) with a couple of parented bones (pelvis and torso) in it and wanted to link the head which is in another root switch with a bone in it, to the last bones of the chain in the body switch. I could then have a parented head to a body that are in two separate switches. At the moment the controled bone is rotating like the master bone but not following the translations of the tip of the end bone of the chain.
It seams like such an important feature to me that I'm a wondering how the rest of you are proceding to do this... Is there any other script doing this function (I tried the bone-master script but found it was slowing down the soft too much on more complex characters and was quite a setup for this simple function) or is it possible to adapt your script to eventually achieve this?

I'm used a lot to 3D soft and in them it is one of the most basic funtions, a simple bone parenting, I'm very puzzled why this is not possible in the core program...

Thanks for your time and for the great scripts you have done for that soft!
Post Reply