Load and save bone animation between characters

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

Moderators: Víctor Paredes, Belgarath, slowtiger

ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Load and save bone animation between characters

Post by ponysmasher »

I'm working on a script to let me save and load skeleton animations so I can reuse walkcycles and stuff on other characters (with similar bone layout).

So far it's going pretty well. Example gif below:
Image

I saved the animation of the character on the left and loaded it onto the characters on the right. (the reason the front arm deforms on the middle character is I used some point animation on the original characters arm which, obviously, isn't saved/loaded)

The way it works right now is the script only saves animation from named bones and loads it onto bones with the same name. So for example, these three characters front arms consist of bones named "upper front arm", "lower front arm", "front hand" and so on.

It will save animation between the start and end frames of the projects and right now it can only save/load rotation and position, so no keyframe interpolation, cycling, scale e.t.c.

Now before I spend more time on this I want to make sure that no such script has already been done. Has it? Because this could take some effort to make really good and I'd rather not do unnecessary work.

If you want to play with it you can download it here: http://dauid.com/tools/scripts/loadsaveboneanim.zip

But remember:
*It's still in very early development.
*You have to name the bones whose animation you want to save/load.
*It won't work if the characters were created facing different directions:
Image
*Right now named bones have to have unique names
*It's a menu script so put it in the anime studio/scripts/menu/third party folder. For example, on my system the path is C:\Program Files (x86)\Smith Micro\Anime Studio Pro 7\scripts\menu\Third Party

Things I'm hoping to be able to do:
*Save/load more data. Cycling, scale, key interpolation, bone locking e.t.c.
*The option to load animation into an action.
*Not requiring unique names (for example being able to load a two legged animation onto a four legged character)
*Load animation between characters facing different directions
User avatar
ulrik
Posts: 1087
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Post by ulrik »

This look great, your goals with this script also looks very promising, great work!!
I think Vern made a script to load and save animation as well, I don't know the status of that script, and if it is working the way your script does.
Verns script should be somewhere in the forum, I will look for it.
User avatar
ulrik
Posts: 1087
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Post by ulrik »

I found the page with Heyverns scripts:
viewtopic.php?t=7842
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Damn it, I blame the lousy search function...

I'm going to check out Vern's script and just count this as a learning experience.
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Hm, doesn't seem to work in ASP7.

Well at least most of the heavy work has already been done.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Dude! Man! Great minds think alike!

What annoys me is how FREAKING FAST you are guys are duplicating my work! :) I spent a lot of time coming up with my bone animation save/load scripts. Can I ask how much time you spent on this? Just for my own curiosity. My save/load scripts had one tiny issue. No "key interpolation". I since have fixed that so everything is saved and loaded including interpolation. However, I added this way back with some new script additions added inversion 6 and I have to track it down. I had this sinking feeling that my updated version got "lost" during some reinstalls of AS during betas. I know that during the version 6 updated I discovered that key interpolation was added. That was not available previously so key interpolation had to be the same for all keys which was VERY annoying. I had actually started reading the actual file format trying to extract the interpolation data... BAD IDEA very difficult.

I am looking at your script to see how got this far so FAST! Man I am a SLOW script programmer. :). I think I am saving more bone data. I tried to get as much info as possible into my file format.

Feel free to rip apart my save/load bone animation scripts and steal as much as you want. I am going to track down the key interpolation versions I made more recently.

-vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Here's the updated version!!!!

I found it! It was buried DEEP DEEP deep under cover (Eddie Murphy quote I think ;))

http://www.lowrestv.com/images/files/sa ... ion_v1.zip

This version SHOULD save everything related to bones, constraints, length, scale, blah blah blah. The load script is the big gizmo for that stuff. Basically the save bone animation script saves everything by default, then you can pick and choose what to import when using the import bone animation script.

This one also saves bone interpolation which was added in v6. I fixed a bug that was caused in v7. I think v7 scripting may have changed slightly. There was some code I used that worked fine in v6 but had to be modified slightly to work in v7. It might have been my error, not sure yet.

There is a check box at in the import, to "Overlay Animation". This means any animation imported is "added" to animation that already exists.

You can also import into an action directly. Just create an action first, have it active and then import animation into the action. This is REALLY cool.

-vern
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Awesome! Thank you so much, Vern!

As for time spent, maybe a day? But it's just bone angle and position and far from all the features of your script.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

ponysmasher wrote:Awesome! Thank you so much, Vern!

As for time spent, maybe a day? But it's just bone angle and position and far from all the features of your script.
Phew! Yes I was a bit relieved when I checked out your script. :). I kept thinking about he hours, days, weeks?... fiddling with that set of scripts and thought "HOLY CRAP HE DID IN A COUPLE OF DAYS!" :)

I am thrilled with this latest version of my scripts. Finally got the key interpolation. That was the huge big gigantic missing element back before version 6. This one had been sitting around for a while and I never finished it up.

I still want to add some more features... like "scaling" for different "sized" characters and different bone offset with the same rig. Right now it really works best with "identical" bone rigs... usually with the same character rig or at least very little changes in the rig.

I also need to change the load script so the check box descriptions are more... uh... "human readable" instead of the "code" versions of the bone properties. ;)

-vern
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

heyvern wrote:I still want to add some more features... like "scaling" for different "sized" characters and different bone offset with the same rig. Right now it really works best with "identical" bone rigs... usually with the same character rig or at least very little changes in the rig.
Wow, that would be awesome. Actually, last night I was thinking how could it be possible. Maybe transforming angle data to percentage? Maybe adding or subtracting degrees to the new bone, instead of putting an specific angle on it?
Well, I'm not the superscripter :roll:, but I think I understand how the scripts works right now. The hard thing for my little head is to think how it could be done for character scaled differently.

Anyway, thanks you both, the scripts are fantastic :D
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Well, I managed to modify my script so that you can load rotations and positions relatively instead of absolutely:
Image

As you can see the character on the right has a crooked spine and the arm is way off to the right.

I did it in my script because I haven't dared to take on the task of understanding Vern's massive script yet, but now we know it works.
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

And after cracking that nut it was easy to create the option to flip the animation:
Image
The right shape was created as a mirror image of the left.
Without flipping the animation it would load like this (with relative rotation):
Image

All I had to do in the script was just subtract the angle and x position instead of adding.
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Image
:D

This whole relative animation thing will probably come in handy.
You could have a basic walk cycle and then load it on to for example a guy who is slumped down or someone leaning back.
You might need to do some tweaking but you'd be mostly there.
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Fourth post in a row...

I tried what I was talking about in the previous post:
Image

These guys all have the same animation loaded onto them. I only changed their positions on frame 1 before loading the saved animation and voilà!

I've added scaling and locked bones to my script which is all I need for now but if Vern has some time over maybe he could incorporate relative animation and flipping in his script? :wink:

Then we would have the ultimate load and save of bone animation.

Feel free to look at my script: http://www.dauid.com/tools/scripts/loadsaveboneanim.zip

There are lots of comments so I hope it's understandable.
User avatar
ulrik
Posts: 1087
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Post by ulrik »

ponysmasher wrote:Fourth post in a row...

I tried what I was talking about in the previous post:
Image

These guys all have the same animation loaded onto them. I only changed their positions on frame 1 before loading the saved animation and voilà!

I've added scaling and locked bones to my script which is all I need for now but if Vern has some time over maybe he could incorporate relative animation and flipping in his script? :wink:

Then we would have the ultimate load and save of bone animation.

Feel free to look at my script: http://www.dauid.com/tools/scripts/loadsaveboneanim.zip

There are lots of comments so I hope it's understandable.
It's looking great :) and to have the relative rotation is a nice feature!

Well done and thanks for sharing!

regards Ulrik
Post Reply