Bone morph dials script

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

Autex
Posts: 23
Joined: Mon Jan 09, 2012 12:44 pm
Location: Germany

Post by Autex » Fri Feb 10, 2012 10:49 am

Ha! Ya'll are awesome. How come I hadn't found that video yet myself?? :oops: But excellent, that's definitely a clever way to do it, thanks.
Hammer down on an empty chamber
RichardU
Posts: 155
Joined: Sun Mar 20, 2011 6:53 pm
Location: Atlanta

Post by RichardU » Fri Feb 24, 2012 9:02 pm

Is there anyway to reset the orientation of a Morph Dial? i.e. I want my morph bone to point to 9:00 and for that to be the "neutral" position. Instead, my neutral position is 12:00.
jonbo
Posts: 896
Joined: Thu Apr 08, 2010 2:53 am

Post by jonbo » Fri Feb 24, 2012 10:16 pm

I think 12:00 is the default. Rudiger would probably need to change it in the script. You can, however, use layer rotate on the morph dials bone layer to rotate it -90 degrees. But then all of the morph bones would then have 9:00 as the default neutral position.
funksmaname
Posts: 3107
Joined: Tue May 29, 2007 11:31 am
Location: Nelson, New Zealand

Post by funksmaname » Sat Feb 25, 2012 12:58 am

here's an idea (not tested):
You could set up a bone at the normal 12:00 position, but have it's angle control 1:1 by another bone which isn't named as a MD bone where it starts pointing left... that way it should work as expected when rotated?

Let us know how it goes!
jonbo
Posts: 896
Joined: Thu Apr 08, 2010 2:53 am

Post by jonbo » Sat Feb 25, 2012 1:09 am

Tried that first Funk before I suggested rotating the layer, it didn't work. Not sure why. The MD bone did rotate with the control bone on frame zero but wouldn't move on other frames.
funksmaname
Posts: 3107
Joined: Tue May 29, 2007 11:31 am
Location: Nelson, New Zealand

Post by funksmaname » Sat Feb 25, 2012 2:03 am

- deleted msg -
Last edited by funksmaname on Sat Feb 25, 2012 2:26 am, edited 1 time in total.
funksmaname
Posts: 3107
Joined: Tue May 29, 2007 11:31 am
Location: Nelson, New Zealand

Post by funksmaname » Sat Feb 25, 2012 2:12 am

I managed to do it... easy to do, hard to explain - here's a screencast

http://youtu.be/4i5_7Bgwjpk

The thing to note is that the 2 bone is a child of the 1 bone, and going to the main time line makes the MD affect the shape in its original state, so you need to rotate the bone at frame 1 so that it puts the influence back to 0 - in this case, 9 o'clock.

the odd thing was that when recording the screen cast i needed to move the bone -45degrees, but when I tried it before recording i had to rotate the bone +135degrees - i guess i must have created the bones differently, so just rotate it until its back to 0, and if it's not at 9 o'clock, rotate the parent bone till the MD bone is facing west on frame 1.
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger » Sat Feb 25, 2012 2:37 am

The short answer is no, but Funk and Jonbo have offered some good suggestions that should work.

Another thing you could try is making the morph dial a child of another unnamed bone that you rotate counter-clockwise by 90 degrees on frame 1.

If you wanted to try changing the script, the relevant code is on line 154 of rt_bake_morph_dials.lua:

Code: Select all

            -- Up is 0, right is 1.0, clockwise is positive
            weights[name] = (-bone.fAnimAngle:GetValue(frame)+math.pi/2) / (math.pi/2)
To make 9:00 the neutral position, it should just be a matter of adding math.pi instead of math.pi/2, ie:

Code: Select all

            -- Left is 0, up is 1.0, clockwise is positive
            weights[name] = (-bone.fAnimAngle:GetValue(frame)+math.pi) / (math.pi/2)
Last edited by Rudiger on Tue Feb 28, 2012 3:13 am, edited 1 time in total.
jonbo
Posts: 896
Joined: Thu Apr 08, 2010 2:53 am

Post by jonbo » Sat Feb 25, 2012 2:40 am

Wow Funk, that's really interesting. I wonder why it works but it does. Just tried it. Once again, you da man! :)
RichardU
Posts: 155
Joined: Sun Mar 20, 2011 6:53 pm
Location: Atlanta

Post by RichardU » Sat Feb 25, 2012 5:47 am

Awesome feedback for a fantastic script. Thanks.
Breinmeester
Posts: 294
Joined: Thu May 13, 2010 2:01 pm

Post by Breinmeester » Tue Feb 28, 2012 4:37 pm

Rudiger wrote:

Code: Select all

            -- Up is 0, right is 1.0, clockwise is positive
            weights[name] = (-bone.fAnimAngle:GetValue(frame)+math.pi/2) / (math.pi/2)
Where did you even find that a bone's angle is in 2*pi counterclockwise? Trial and error?

This scripting for Moho needs a manual!
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger » Sun Mar 04, 2012 11:30 am

Breinmeester wrote:
Rudiger wrote:

Code: Select all

            -- Up is 0, right is 1.0, clockwise is positive
            weights[name] = (-bone.fAnimAngle:GetValue(frame)+math.pi/2) / (math.pi/2)
Where did you even find that a bone's angle is in 2*pi counterclockwise? Trial and error?

This scripting for Moho needs a manual!
Well, there is an html manual, but it has been out of date since AS6. I think it comes with the AS installation now, in the "Extra Files" folder.

Other than that, I use lots of print statements to do things like printing out the angle while I rotate the morph dials.
Psynema
Posts: 31
Joined: Fri Aug 13, 2010 8:43 am

Post by Psynema » Wed Mar 14, 2012 7:27 am

Took me a long time to understand everything but think I have it working.

Only thing is it doesn't seem to do fill changes, which blend morphs can, however, Blendmorphs are too slow anyways compared to this so no big whoop.

Though it does seem nerve wracking riggging a character this complex - I'm afraid I'll mess something up with the bones etc.


So how it it when it's actually NESTED a few levels deep in a skeleton - all good?

Also keep getting errors for both buttons - says attempting to refer to a nil on line 117 on both scripts.
Psynema
Posts: 31
Joined: Fri Aug 13, 2010 8:43 am

Post by Psynema » Thu Mar 15, 2012 6:02 am

So is there no way to see changes LIVE or does leaving that box checked always cause errors I'm confused if I installed correctly. Thanks.
Autex
Posts: 23
Joined: Mon Jan 09, 2012 12:44 pm
Location: Germany

Post by Autex » Wed Apr 18, 2012 11:51 am

Awhile ago someone (myself included) had written that Anime using Morph Dials would crash as soon as you change a bone's name and deselect. I'm not sure anymore what the solutions to that were (mostly because I'm too lazy to search thru the entire thread again) but I've noticed that, this crash seems to only happen when I have a control bone controlling other MD bones (for example sad;happy;etc) and I were to erase or change the name of my "sad" MD bone or erase the bone entirely. A way around this would just be to change the name of the bone or erase it from the control bone's "list," then you should be safe.
Hammer down on an empty chamber
Post Reply