Instant limb *Major update, now a tool*

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

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Instant limb *Major update, now a tool*

Postby ponysmasher » Sun Jul 18, 2010 10:14 pm

************************************************************
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
ponysmasher
 
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles

Postby Víctor Paredes » Sun Jul 18, 2010 11:39 pm

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.
Víctor Paredes - Former Moho 12 Product Manager
My Youtube Channel - My webinars
User avatar
Víctor Paredes
 
Posts: 4813
Joined: Wed Jan 26, 2005 12:18 am
Location: Ireland

Postby sbtamu » Mon Jul 19, 2010 12:58 am

Awesome, draw 2 bones and arm is done.

Thanks ponysmasher
Sorry for bad animation

http://www.youtube.com/user/sbtamu
sbtamu
 
Posts: 1902
Joined: Tue Dec 15, 2009 5:05 am
Location: Texas

Postby neeters_guy » Mon Jul 19, 2010 2:22 am

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
neeters_guy
 
Posts: 1547
Joined: Mon Sep 14, 2009 7:33 pm

Postby heyvern » Mon Jul 19, 2010 5:09 am

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
User avatar
heyvern
 
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Postby F.M. » Mon Jul 19, 2010 5:47 am

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!"
F.M.
 
Posts: 475
Joined: Thu Nov 04, 2004 4:29 pm
Location: Between my ears

Postby Genete » Mon Jul 19, 2010 6:37 am

Another really pro script!
-G
User avatar
Genete
 
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Postby heyvern » Mon Jul 19, 2010 7:50 am

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
---------------------------------------------------------------------------------------------------------------------------------
User avatar
heyvern
 
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Postby ponysmasher » Mon Jul 19, 2010 8:11 am

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
ponysmasher
 
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles

Postby heyvern » Mon Jul 19, 2010 9:01 am

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
heyvern
 
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Postby ulrik » Mon Jul 19, 2010 10:25 am

Fantastic script, and you share it with us as well, thanks! (you must be from sweden, right? :wink: )
ulrik
 
Posts: 1062
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden

Postby DK » Mon Jul 19, 2010 11:04 am

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

Cheers
D.K
User avatar
DK
 
Posts: 2336
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Postby Imago » Mon Jul 19, 2010 11:24 am

There is the possibility to use more than two bones?
Like to rig fingers, animal legs, braids...
Sorry for my bad english... Q_Q
User avatar
Imago
 
Posts: 698
Joined: Wed Dec 10, 2008 9:48 am
Location: Sardinia

Postby ponysmasher » Mon Jul 19, 2010 11:37 am

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.
User avatar
ponysmasher
 
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles

Postby ponysmasher » Mon Jul 19, 2010 11:48 am

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).
User avatar
ponysmasher
 
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests