Is there a script that can do this?

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

Post Reply
User avatar
synthsin75
Posts: 7114
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Is there a script that can do this?

Post by synthsin75 » Tue Jan 22, 2008 12:45 am

Okay, this could also be a feature request, but I figured I'd start here. I've been studying the bone constraints and parenting, and it seems a bit unbalanced.
What I've noticed is this:
Translate- a translated parent translates its child equally
- position constraint only works from a manually translated bone
Scale- a scaled parent will translate its child parallel to the direction of
scaling & to a ratio of its distance
- scale constraint only works from a manually scaled bone
Rotate- a rotated parent will translate its child around its pivot
- rotate constraint works from any rotating bone
Parenting seems to be equal in some way to a position constraint.

I assume the difference in how a rotation handles constraints has something to do with rotation being equal to manipulation (manipulate bone tool).
What I want to know is, is there a script that would make scale & translate constraints behave like rotate does?
If a bone is translated, by parenting to a scale or rotation bone, any bone position constrained to it should also translate. Having to use parenting doesn't let me control the percentage of translation.[/b]
User avatar
fiziwig
Posts: 197
Joined: Fri Jan 04, 2008 8:00 am

Post by fiziwig » Tue Jan 22, 2008 1:10 am

Looking at the internal logic it appears that every child bone's translation is relative to the parent bone. So a child bone of a rotating bone is not translating at all, relative to the parent, so there is no actual translation to pass on to a controlled bone.

I don't know if a script could do that, but I would think it's possible.

--gary
User avatar
synthsin75
Posts: 7114
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 » Tue Jan 22, 2008 1:31 am

So parenting isn't so much a translation-like constraint as it is a sort of 'lock to parent'? And a child has no absolute positional values that can be passed on, only the unchanging relative value to its parent?
And how does rotation differ? Is it that the relative change from pivot to tip is all internal to the bone?

Too...many...questions....bzzt! :wink:
User avatar
heyvern
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Tue Jan 22, 2008 1:42 am

These are known limitations to constraints. I have posted feature requests in the past to have the OPTION at least, to include the parent rotations/translations for constraints, AND to have multiple targets for constraints on one bone.

There is ANOTHER even more annoying problem with constraints. If you have an unparented bone that is the target and the constrained bone has a parent a translation constraint goes THE WRONG WAY. Because the bone is parented it's x and y seem to get "reversed".

While I wait for "upgrades" to constraints in a new version... I... uh... just keep scripting my own replacements. I just finished a new translation constraint that allows for the constrained bone to be moved separately from the target. You can move the constrained bone and it still follows along with the target bone but includes any addition translation you apply. Currently a constrained bone can't be translated or rotated depending on the constraint.

I almost cried when, after 2 days trying to pull this off and on my last test... IT WORKED! I jumped up and down and did a happy dance... then I went to bed. I had to use bone offset though which means you can't use bone offset on frame 0 with a bone that has that constraint. This is not a big deal I think. You can offset the parent bone if needed.

I could eliminate that by just changing the bone position on frame 1. I have found that to be a cool trick. Start the animation on frame 2, any scripted changes to frame 1 will be applied to the whole animation. I hate to do this though because it works "differently".

So far I have solutions for most of the "bugs" with constraints. My BIG project now is to put all of these new constraints into a utility/menu script so it will work more easily.

I want a job at Smith Micro baby! ;)

-vern
User avatar
synthsin75
Posts: 7114
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 » Tue Jan 22, 2008 2:01 am

There is ANOTHER even more annoying problem with constraints. If you have an unparented bone that is the target and the constrained bone has a parent a translation constraint goes THE WRONG WAY. Because the bone is parented it's x and y seem to get "reversed".
I'm trying to duplicate this to help me understand all the bone behavior, but I'm not getting this 'wrong way' constraint. I have one parent, its only child is position constrained to a third, unparented, bone. ?
User avatar
heyvern
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Tue Jan 22, 2008 4:51 am

I think the "wrong way" bug is related to how the bones are rotated. I run into it all the time.

Try this:
Draw a bone pointing up (use the shift key), this will be "Bone 1", without deselecting draw a child bone pointing to the right, this will be "Bone 2". Deselect all bones, draw a new bone pointing straight up, this will be "Bone 3". Now add a position constraint to "Bone 2" (pointing right) with "Bone 3" as the target.

When you drag "Bone 3" the constrained bone moves in the reversed orientation, X is Y and Y is X.

Technically... this could be considered "correct" behavior since the constrained bone's orientation is rotated. The X and Y have been rotated so X goes up and down and Y goes left to right. Even so... it is annoying when you don't want it do that. Sometimes (ALWAYS for me) you want the constraint to be based on the "world corrodinates", or the "global space". I often have to stick in several "extra" bones to "rotate" the axes of motion.

That is why I am adding that functionality to my own version of the translation constraint.

-vern
User avatar
synthsin75
Posts: 7114
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 » Tue Jan 22, 2008 6:50 am

Ah, I see now. I took that 'problem', and used it to test my assumption that parenting is handled something like bone locking. Using only bones 1&2 parented like you said, I constrained bone 2 to the position of bone 1. Then I locked bone 2. Now when I drag bone 1 I get something like your 'wrong way', but at a 45 degree angle, for verticle dragging, and I get a rotation dragging horizonally. I'll keep playing with this.
Post Reply