PDA

View Full Version : Parent Switching and Blending


backwheelbates
09-19-2006, 12:31 AM
Hi,

Im looking for some ideas for parent constraint switching. Im rigging a robot character that flys and walks(lots of back and forth). So at one point it will walk(using IK to control the limb in world space) and at another point it will fly(using IK in the local space of the main body). Ive parent constrained a locator to a worldspace null and to a character body null, and under that locator Ive put the animation control with an attribute to shift parents on the locator.

worldspace\
>>>>>>>>>constrained locator> keyable control shape
robotspace/



My problem is that when I shift parents the control shape shifts to different positions. Its similar to shifting an arm IK handle between hip space and world space.

Thanks for any ideas!!

Eric

darkjedi1929
09-19-2006, 01:33 AM
Yeah, well, that is supposed to happen. Correct me if I am wrong here, when you constrain an object to another, it just stores the offset values of the object at the point where it's constrained and then using those offsets, drives the rots and translates. Therefore is you have two parents, there will be a "POP" when you shift parents. The simple solution is this: if you are shifting from parent A to parent B, first move parent B to parent A's position (use the xform command, preferably) and then change the attribute. You can also write a MEL to do this whole thing in the background...

Hope this helps.

backwheelbates
09-19-2006, 05:34 PM
Thanks DarkJedi1929. That worked pretty well. I just melscripted A(WorldSpace) locator to lock to the position/orientation of B(RobotSpace) locator until the control is switched back to A locator. I left B locator alone because its constrained already to the character's main body. It works great going forward in the timeline, but because the scripting/position is dependant on B's previous position, it doesnt really work to scrub back and forth. Its not a perfect solution, but I think it will work for this situation.

Thanks again,

Eric

StephG
09-19-2006, 07:08 PM
What I would recommend is to make a control window where you switch between parenting states. The control switch would run a script that looks something like this:


float $pos[] = `xform -q -ws -t "ObjectName"`;//gets the current position
float $rot[] = `xform -q -ws -ro "ObjectName"`;//gets the current rotation

setAttr "ObjectNameParentConstraint.weightattribute1" 0;
setAttr "ObjectNameParentConstraint.weightattribute2" 1;

xform -ws -t $pos[0] $pos[1] $pos[2] "ObjectName"`;/*puts the position before switch back on the object*/
xform -ws -t $rot[0] $rot[1] $rot[2] "ObjectName"`;/*puts the rotation before switch back on the object*/


I used to use scriptJobs for this, but they're notoriously annoying when you scrub backwards and the switching attribute changes, especially if you have autoKey on.

Making a control window also works much more reliably when you have a multi character situation, if you have all the characters in the scene listed in a textScrollList or pulldown menu.

darkjedi1929
09-20-2006, 09:07 AM
Thanks DarkJedi1929. That worked pretty well. I just melscripted A(WorldSpace) locator to lock to the position/orientation of B(RobotSpace) locator until the control is switched back to A locator. I left B locator alone because its constrained already to the character's main body. It works great going forward in the timeline, but because the scripting/position is dependant on B's previous position, it doesnt really work to scrub back and forth. Its not a perfect solution, but I think it will work for this situation.

Hmmm....to make it interdependent, how about grouping B to itself, moving this new group's pivot to B, and then applying the method? This seems to work fine for me.

CGTalk Moderation
09-20-2006, 09:07 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.