HeyVern's scripts and tools - (focus on bones)

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
human
Posts: 688
Joined: Tue Jan 02, 2007 7:53 pm

Post by human »

heyvern wrote:I have found a ton of free resources for this type of "IK" chains in Actionscript and will try to convert it to lua for use with AS.
Where did you find these scripts?
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Just type:

"Flash Inverse kinematics"

into google.

Bunch of links.

This book has a free chapter in PDF... on... get this... IK!

http://www.friendsofed.com/book.html?isbn=1590595181

This one is cool:

http://www.levitated.net/daily/levIterativeIK.html

This is my favorite site:

http://www.gotoandplay.it/_articles/200 ... matics.php

That site is focused on Flash games but that doesn't limit its use for anything else you can think of. That article on IK is a bit old but still works.

I have to admit that I am taking some of this person's philosophy to heart. He signs of with this:
don't forget what Plato said: wisdom can't and mustn't be sold for money.
I will share my scripts but if I spend many months writing a book on using AS... I will have to charge something for it. I don't think Plato had utility bills and a mortgage. ;)

-vern
slice11217
Posts: 279
Joined: Thu Mar 30, 2006 6:12 pm
Location: Verona, New Jersey

Post by slice11217 »

Hey, Heyvern!

OK, so after your topic "How many of you use scripts with Anime Studio Pro?", I thought a lot about scripts and using them. Inspired by this, just the other day I installed my first script, the universal selection tool which you wrote. Boy, what a time saver!

I started wanting more scripts and one of the things I wanted was a way to copy paste and mirror bones. I did a search and found this thread. The only thing is, I notice that you start out saying that you're working on a copy/paste script but that you're having troubles with it. It sounds like you got it to work but I don't see a link to the script itself. Did you post it?

Also, I read the instructions for the Aim bone script and I saw the video you did but I'm still clueless as to what it actually does. Can you please explain it in more layman terms?

Thanks,

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

Post by heyvern »

The mirror bones script turned out to be harder than I expected.

Parented bones are a pain... plus... it isn't like a mirror point tool... you don't want the wrong bone selected by mistake on the other side. Parented bones are a pain because there locations are based on the parent not where you click the mouse. So if I click the mouse on one side I can't "reverse" the click location and pick the other side... the bone isn't there it is at the location relative to the parent. I had to jump through hoops to make that work properly.

Now the problem is that when you drag the bone... and it hits the mirrored location of the wrong bone... all the bones sort of "stick" together and move as one.

I could solve the whole thing and use NAMED bones (left, right) but I don't want to do that.

I am thinking of using bone children (first child, second child etc) instead of bone location. on the screen for the parented bones problem.

--------

I will try to put something together for the AIM script either tonight or tomorrow. I suppose it might be confusing.

-vern
slice11217
Posts: 279
Joined: Thu Mar 30, 2006 6:12 pm
Location: Verona, New Jersey

Post by slice11217 »

I guess I used the wrong terminology when I asked about 'mirror' bones. By 'mirror bones' I meant 'flip bones'. Some other software uses the term 'mirror' for 'flip' and I must have gotten confused. Anyway, flipping a bone, or hierarchy of bones would be useful in creating a symmetrical skeleton.

So....

I installed ThaNarie's Copy/Paste bones script and the result I get is kinda... wonky.

-Like nothing anyone else here has described so far. When I paste to the same layer, all the bones are in the same position as their originals but when I move them, they don't seem to be following the correct hierarchy. They move kind of oddly.

When I create a new layer and paste the bones there, they come in at wrong angles and positions, and not all of the linkage is right. I mean, really deformed looking.

I have auto naming turned off, I'd never noticed that option previously so I guess that was the default, and I know that had been an issue on the other thread.

My hope was to be able to copy the bones into another layer, somehow flip them, and then paste the new bones back into the original layer so that the structure I'd set up for a right arm would be identical (but flipped) to the left arm.

That kind of brings up another issue that would be better posted on the 'Feature Request' section of this forum: ruler guides. It's just something I realized was missing as I thought about other ways to do this. I know I could simply draw a horizontal line across the work area, but it would be nice to have a guide there instead.

So since I know you'd been toying with the copy/paste bones script Vern, I was wondering if you'd ever posted your new and improved version. I can't seem to find a link for it on this thread but it looks as though you might have cleaned up and improved the code for the script.

Please post it. It's one of these things that it's a little surprising it wasn't included in Anime Studio all along!

Thanks

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

Post by heyvern »

So since I know you'd been toying with the copy/paste bones script Vern, I was wondering if you'd ever posted your new and improved version.
I haven't finished it yet. I was using a scrolling list for bones and I got stuck. Copy/paste bones is hideously complex and made my head spin. It is just a total freaking nightmare for me. Those problems with ThaNarie's script are similar to the problems I have been having. Worse than that it often crashes AS so... not releasing it till I get that worked out.

I was sort of at a dead end because I have tons of bones and a scrolling list is my only option. Unfortunately scroll lists are very limited and makes the coding ten times harder. I am hoping a future update might either fix the lua code or add copy paste bones then I'm off the hook! ;)

My mirror bones tool script is almost ready. Once I get it done it kind of does something similar but you still have to create the opposite bones. They just don't have to be in the exact position. If you click on either side the opposite bone will "snap" into place to match.

I want to make a mirror bones menu script to do all of them at once then you could use the tool to do final positioning.

-vern
slice11217
Posts: 279
Joined: Thu Mar 30, 2006 6:12 pm
Location: Verona, New Jersey

Post by slice11217 »

heyvern wrote:Copy/paste bones is hideously complex and made my head spin. It is just a total freaking nightmare for me. Those problems with ThaNarie's script are similar to the problems I have been having. Worse than that it often crashes AS so... not releasing it till I get that worked out.

I am hoping a future update might either fix the lua code or add copy paste bones then I'm off the hook! ;)

My mirror bones tool script is almost ready.

I want to make a mirror bones menu script to do all of them at once then you could use the tool to do final positioning.

-vern
Hey Heyvern :) -(I like that, I don't know why)

So I think you already know about this, but I found a script that ALMOST works, but it works better for me than ThaNarie's copy/paste bones. It was posted back in 2005 when the world was young:

viewtopic.php?t=2115&highlight=clone+bone

It also allows for flipping the bones during the operation. Unfortunately, it doesn't seem to paste in place and it also seems to rotate the bones indiscriminately.

-I found a workaround for that last part though: if you go one frame forward and then rotate the bone to the proper position, you can then go to the "0" frame and copy the keyframe in. -Same strategy for the translation property as well.

I was only planning to use copy/paste bones for the skeleton construction phase anyway and for now this seems to work adequately (not fantastically, mind you, merely adequately). It solves a problem, it just happens to also create a problem as well.

So not being a coder myself, I was just wondering if this script could be developed a bit more to produce something more along the lines of what you were trying to accomplish. I mean, it copies right? It flips bones, right? It just happens to also... rotate on its own.... -and place the bones in the center as well. -But couldn't that be fixed?

Like you, I'm hoping that this might be in a future (NEAR future) update to AS.

By the way on a different subject, I've been looking at your aim bones stuff. Nice work. It's a very interesting idea, and I like it as a solution for animated foreshortening.

I'm not so sure how well it would work in a production environment though. I mean, the initial hurdle would be to get a team of animators up to speed on Anime Studio and using it as/is straight out of the box. Then here comes this secondary feature, -which even though it does something really useful, might be a little mind-boggling for the uninitiated. You know, the whole "bones that move other bones which themselves don't move when you try to move them" thing.

I think that for any given project it would be most effective to switch between standard AS animating and your aim script as needed. The linkups between standard and scripted animation would probably be the hotpoints. Is there any way to easily switch between using that script and animating normally? That would be cool.

Thanks,

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

Post by heyvern »

Is there any way to easily switch between using that script and animating normally? That would be cool.
My goal with all of my scripts is to make the "behind the scenes" stuff invisible. I want to create rig controls that are simple to animate with and you would never need to have access to any bones except those for controlling other bones. Animating "normally" would never be needed... and unfortunately due to how scripts work would be impossible.

... There is a bigger problem with the aim bone script I still need to work out. It involves linear translations vs. rotation. When you key frame bone translation it moves in a straight line. You never get proper bone rotation. This is very bad... very very bad. It means to actually rotate a bone you need a bunch of translation keys. I need to figure out a way to "lock" the aiming so normal rotation could be achieved. It's a tricky one.

The problem with "turning off" the layer script is how bones are controlled. If a bone is controlled by a script you can't move it any other way. It is very much like constraints, if you use a rotation bone constraint you can't rotate that bone by hand.

I've been experiementing with some kind of "toggle" that would "turn off" the script using another bone as some kind of switch. The problem there is that there would be a "jump" when the script takes control again.

This whole concept of "rig controlled" characters is how nearly all of the high end 3D studios work. Each studio probably has their own set of rigs with custom controls even if they use the same program. Most studios have "riggers" and "animators". The animator never changes or modifies the rig. They just use the "widgets" that the riggers create to move the characters around. If an animator needs a new type of control they go back to the guys who do that and ask them to put it in... I simplify the concept but you get the idea.

That is my goal with these scripts. I want to create a simple to animate rig... even with bunches of "hidden" bones, so the animator (me) doesn't have to worry about 50 bazillion key frames on 10 different layers.

I created a "text" script that can draw text when using a custom tool. I am thinking of modifying the LM_utility script so that text would appear with every tool in the palette. This would allow for labeling bones, drawing bone shapes only for those bones that need to be keyed and you could just turn off construction curves and never see the bones at all. I could use custom shapes to define specific bones for specific controls. It is very much like creating a "new GUI" with in AS itself.

-vern
human
Posts: 688
Joined: Tue Jan 02, 2007 7:53 pm

Post by human »

heyvern wrote:It is very much like creating a "new GUI" with in AS itself.
Then, at some pont, I hope you will do what people at e-frontier apparently never did: peruse a standard set of UI guidelines, developed by professionals who care about the user experience and who have solid methods for determining what users need.

I could probably fish out the guidelines developed by Microsoft, but since you are an Apple guy, I located the following Apple document:

http://developer.apple.com/documentatio ... ion_1.html

Hey, it's just for future reference if you make headway toward your dream.

I don't think you'll need it soon.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

AS is an "odd duck" as far as UI goes. I've embraced it and don't really have a problem with it being different.

The problem maintaining UI guidelines with scripting in AS is that you really can't do much with it... other than drawing shapes and text on the screen.

What excites me about drawing with the scripting UI in AS is how freaking gosh darn wizbang FAST it is. I wrote an entire paragraph of text with every letter of the alphabet upper and lower case, all the numbers, all the punctuation, set to anti-aliased, linked to a bone's scale and rotation... with NO noticeable delay in drawing to the screen and NO slow down while moving or rotating a bone.

I think I could create a script "library" of "shapes" like "3D-esque" knobs and buttons using the draw functions. This could be a fast and easy way to draw interface elements for tools.

We only see a teeny tiny aspect of what those draw functions can do. "Red lines", dots for vectors... what you can do is nearly as sophisticated as what can be drawn in AS itself... you just have to work really really hard to do it because there is no... "interface" or "tools" to draw these things. You have to specify specific pixel and point locations. So creating a library of scripted elements would mean that any one who writes a script and wants a "buton" or "gizmo" just adds a reference to the utility script "library" and bingo... it is drawn to the screen.

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

Added new script for copy and flipping bones.

Post by heyvern »

See the first post. I just finished a new script for copying and flipping bones for symmetrical rigs. Works pretty well.

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

Post by heyvern »

I just added a new script to go with the copy flip script. See my first post in the thread for a description and download.

This one changes or appends to the names of selected bones.

-vern
User avatar
jahnocli
Posts: 3471
Joined: Fri Oct 29, 2004 2:13 pm
Location: UK

Post by jahnocli »

Thanks a lot! You are very generous with your time and effort.
You can't have everything. Where would you put it?
slice11217
Posts: 279
Joined: Thu Mar 30, 2006 6:12 pm
Location: Verona, New Jersey

Re: Added new script for copy and flipping bones.

Post by slice11217 »

heyvern wrote:See the first post. I just finished a new script for copying and flipping bones for symmetrical rigs. Works pretty well.

-vern
WOW!!!

This is so totally cool! Thanks for coming through, Vern!!

What a timesaver this will be!

Hey, how did you learn to write these scripts?

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

Post by heyvern »

Hey, how did you learn to write these scripts?
Before buying Moho (Anime Studio's original name) I was pretty confident with Javascript and Actionscript. I was NOT an expert in either. I knew my way around, I could eventually understand and figure out how to do what ever I needed to do with enough manuals ;) and perseverance.

When I purchased Moho and discovered that ALL the tools were PLAIN TEXT SCRIPTS exactly like Javascript embedded in a web page, my jaw hit the floor.

The old saying "necessity is the mother of invention" was my main driving force. ;) A lot of things I didn't like about AS (moho) I jumped at the chance to change and "fix".

At first I was intimidated by the lua language used in AS but eventually it became quite clear it was very similar in many ways to JS or Actionscript. Through trial and error and studying the other scripts in the application and scripts others were creating I was able to learn it on my own.

Just in the last 6 months or so I have learned even more about it. The big hurdle is that there are no "real world" examples of scripting usage and implementation in the "Moho" scripting reference. A lot of guessing and trial and error was needed since I don't have any proper programming training.

The lua language fortunately is really very simple and easy to learn. If you can learn basic Javascript, or Actionscript lua is a piece of cake. Lua also has the benefit of being popular as an open source "back end" used in many computer games so there is quite a bit of resources and instructional materials on the web.

-vern
Post Reply