Instant limb *Major update, now a tool*

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:

Instant limb *Major update, now a tool*

Post by ponysmasher »

************************************************************
Update september 2010

It was really hard to have to set the settings in the small preview window so the script is now a tool that updates directly in the workspace.

Here's a video: http://www.youtube.com/watch?v=vtJHgcmoC8s

And here's the script: http://dauid.com/tools/scripts/ds_instant_limb_tool.zip

************************************************************
My most advanced script yet: http://dauid.com/tools/scripts/ds_instant_limb.zip

Video: http://www.youtube.com/watch?v=f_9UoP93k-Q
EDIT: Ignore the first limitation that I mention.

Preemptive answers to questions:

-But ponysmasher, I don't rig my limbs like this script does, what about me?

Sorry but I write scripts for me first and foremost and this is how I prefer to rig them.

-But ponysmasher, couldn't you just as well create one limb and then import that in other projects? Why write a script?

Shut up, that's why...
No, but this is faster, more flexible and a lot cooler. :P

-But ponysmasher, will you never rig a limb manually again?

Sure I will. Sometimes you want more detailed limbs or limbs in another style or whatever, but in a lot of situations this will do.
I'll probably use it for legs the most.

-But ponysmasher, what about the two limitations that you mention in the video?

EDIT:Thanks to HeyVern the first limitation is gone.
Last edited by ponysmasher on Mon Sep 20, 2010 9:12 pm, edited 2 times in total.
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 »

Wow!
But Ponysmasher... I actually haven't a but. It is awesome!
thank you very much!
It's great, really great and smart. Love it, just love it.

Thank you so much, I'm a fan.

Note: I think that people using Debut (which haven't menu scripts) can add this script as button on tool palette. That should work.
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
sbtamu
Posts: 1915
Joined: Tue Dec 15, 2009 5:05 am
Location: Texas
Contact:

Post by sbtamu »

Awesome, draw 2 bones and arm is done.

Thanks ponysmasher
Sorry for bad animation

http://www.youtube.com/user/sbtamu
User avatar
neeters_guy
Posts: 1614
Joined: Mon Sep 14, 2009 7:33 pm
Contact:

Post by neeters_guy »

If there was an award for best script of the year, this would be it! Truly amazing. (I guess this makes all those Mandcon arm rig threads obsolete now.) Thanks!
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

As a scripter I say this is WICKED FREAKING COOL! Wow! I hope the new influx of scripting talent will help push SM to put more script features in AS for the future.

I will check out the "parent bone" code you commented out. Maybe I can help out with that. You should check out my "copy flip bones" script. I had to deal with the parenting of bones and calculating positions etc. It might help out. It was a PAIN to figure it all out but the end result is actually fairly simple.

-vern
F.M.
Posts: 497
Joined: Thu Nov 04, 2004 4:29 pm
Location: Between my ears

Post by F.M. »

What versions of Moho/AS does this script work with?
Last edited by F.M. on Mon Jul 19, 2010 4:13 pm, edited 1 time in total.
"and then Man created god!"
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Another really pro script!
-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Dude!

here's the code to fix the parent bone stuff. Turned out to be simpler than I hoped! Only 6 lines of code! Woohoo!

This code replaces the stuff you commented out. It starts around line 295. Basically it just follows up the bone chain adding the rotations. At the end after the loop it uses the "fRestMatrix" of the bone and transforms the final position for the vectors layer points. The fRestMatrix of a bone is the "absolute" position that includes all of the parent bones.

I tried to use the matrix to get the rotation in one step but it doesn't appear to be possible. This works great though.

Code: Select all

self.parentbone=skel:Bone(self.lowerbone.fParent) --Get parent bone of selected bone
		if (self.parentbone.fParent>-1) then
            local bParent = self.lowerbone.fParent
            while bParent >-1 do
                local bone = skel:Bone(bParent)
                self.upperAngle = self.upperAngle + bone.fAngle
                bParent = bone.fParent
            end
            self.parentbone.fRestMatrix:Transform(self.upperPos)
		else
            self.upperPos=self.parentbone.fPos
            self.upperAngle=self.parentbone.fAngle
    end
---------------------------------------------------------------------------------------------------------------------------------
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Ooooh, thank you Vern!!!

I have to try it out when I get home.

I wrote the script during last weeks vacation and only had sporadic internet access so most of the time I had to make do with the scripting documentation and the scripts I had on my laptop.

Whenever my girlfriend relaxed with some solitaire, I relaxed with some Lua scripting :D

I was actually thinking about the whole matrix thing and if I could use it but suddenly the vacation was over. :(
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Ponysmasher,

Gllad to help out. Fantastic script. I was looking at your code for the vector drawing stuff... all that... math... my head starts to spin... I actually got a bit woozy and nauseous. :) I get so lost trying to figure that stuff out. What kind of "coding" background do you have?

I wish I wish so much I had paid attention in math class when I was younger. They always say that you will need that knowledge later in life but you don't realize it's true until it's too late. :) I spent years and years as an artist never needing algebra... sheesh... NOW I need it.

-vern
User avatar
ulrik
Posts: 1087
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Post by ulrik »

Fantastic script, and you share it with us as well, thanks! (you must be from sweden, right? :wink: )
User avatar
DK
Posts: 2849
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Post by DK »

Wow!!!! Thanks ponysmasher.....this script is simply stunning. It also works on AS5.6...even better :)

Cheers
D.K
User avatar
Imago
Posts: 698
Joined: Wed Dec 10, 2008 9:48 am
Location: Sardinia

Post by Imago »

There is the possibility to use more than two bones?
Like to rig fingers, animal legs, braids...
Sorry for my bad english... Q_Q
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

The link in the first post has been updated with Vern's fix. It works great! You're the bonemaster, Vern :)

I also changed it so that all the settings are remembered until you either restart AS or click "reset settings".
heyvern wrote:Ponysmasher,
I was looking at your code for the vector drawing stuff... all that... math... my head starts to spin... I actually got a bit woozy and nauseous. :) I get so lost trying to figure that stuff out. What kind of "coding" background do you have?
It looks worse than it is really. It's just sinus and cosinus over and over again to find points on a circle.

I don't have any real coding background but my brother (who makes games) has talked about using sinus and cosinus to rotate things around other things so I was familiar with that whole thing.

I've also learned that you can find out an angle between two point by using the formula:

Code: Select all

angle=math.atan2(y2-y1, x2-x1)
Now I just have to find a use for that as well...
ulrik wrote:Fantastic script, and you share it with us as well, thanks! (you must be from sweden, right? :wink: )
Because of my evil socialist tendency to share? :) But yes, jag är svensk alright.
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Imago wrote:There is the possibility to use more than two bones?
Like to rig fingers, animal legs, braids...
Not at the moment, no.

It's possible to implement though, it "only" requires time (which I'm short on at the moment).
Post Reply