Page 1 of 3

Instant limb *Major update, now a tool*

Posted: Sun Jul 18, 2010 10:14 pm
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.

Posted: Sun Jul 18, 2010 11:39 pm
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.

Posted: Mon Jul 19, 2010 12:58 am
by sbtamu
Awesome, draw 2 bones and arm is done.

Thanks ponysmasher

Posted: Mon Jul 19, 2010 2:22 am
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!

Posted: Mon Jul 19, 2010 5:09 am
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

Posted: Mon Jul 19, 2010 5:47 am
by F.M.
What versions of Moho/AS does this script work with?

Posted: Mon Jul 19, 2010 6:37 am
by Genete
Another really pro script!
-G

Posted: Mon Jul 19, 2010 7:50 am
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
---------------------------------------------------------------------------------------------------------------------------------

Posted: Mon Jul 19, 2010 8:11 am
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. :(

Posted: Mon Jul 19, 2010 9:01 am
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

Posted: Mon Jul 19, 2010 10:25 am
by ulrik
Fantastic script, and you share it with us as well, thanks! (you must be from sweden, right? :wink: )

Posted: Mon Jul 19, 2010 11:04 am
by DK
Wow!!!! Thanks ponysmasher.....this script is simply stunning. It also works on AS5.6...even better :)

Cheers
D.K

Posted: Mon Jul 19, 2010 11:24 am
by Imago
There is the possibility to use more than two bones?
Like to rig fingers, animal legs, braids...

Posted: Mon Jul 19, 2010 11:37 am
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.

Posted: Mon Jul 19, 2010 11:48 am
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).