# Autodesk maya; Stretchy Ik on/off switch

 08 August 2012 FaustVII New Member portfolio Marquis n/a Campbell, USA Autodesk maya; Stretchy Ik on/off switch Hey i'm new to the site and am rigging a character using the three joint chain system. I'm semi experienced with rigging but wanted to rig something of my own. I did a tutorial on how to create a stretchy ik chain using expressions but realized there was no way to turn it on and off but with trial and error i figured i could do it or "fake it" using constraints. similar to weighting orient constraints in a ik/fk switch 3 joint chain system. I wrote down what i did so i don't forget and just wanted to "double check" my thinking. create joint chain ex// Arm/elbow/wrist create ik Go to create/measuring tools/distane then (holding v key) select the "arm" joint and "wrist" joint parent locator to "wrist" joint select ik handle and move until joint chain is completely straight. write down distance given then go to window/animation editors/expression editor name your expression (Example Stretchy joint chain) enter expression: (**This expression was provided from the book "The Art of rigging"** which is an amazing book that is uber helpful!! Numbers given are for example purposes) if (distanceDimensionShape1.distance >= 12.9 ) { //Stretch! arm.scaleX = (distanceDimensionShape1.distance / 12.9) ; elbow.scaleX = (distanceDimensionShape1.distance / 12.9) ; } else { //Do not Stretch arm.scaleX = 1 ; elbow.scaleX = 1 ; **to add other joints you would just add, underneath elbow.scalex ex// forearm.scalex = (distanceDimensionShape1.distance / 12.9); If there are no errors then move joint chain and joints should stretch the wrist won't stretch unless you specify otherwise. reason why the scale is set to X is because that is the axis that ,by default, follows the joint chain. I realized theres no real way to turn the stretch on and off without knowing some kind of expression or something so i figured constraints could work. This is what I came up with bring ik handle to original location create a control curve/object, give it a name ex//Ik Wrist cntrl In the channel box, add a float attribute named ex//IK Stretch minimum 0 max 1 default 0 and point constrain the distance end locator to the curve/object. create another locator and v snap it to the distance start locator, give it a name ex// distance helper Freeze transformations Point constrain the "distance helper" to the " IK Wrist cntrl" in outliner or hypergraph, select the distance end's point constraint. This should have two values just below the offset. ex// Distance Helper1W0 = 1 Wrist CNTRL1W1 = 1 go to window/animation editors/set driven key/set select the "wrist cntrl" as the driver and the point constraint as the driven. change the value of the "wrist cntrl" ikstretch to 0 select the point constraint then theand the distance helper to 0 leaving the wrist cntrls value at 1. select the point constraint then the Distance Helper1W0 = 1 Wrist CNTRL1W1 = 1 change the distance helper to weight to 0 leave the wrist cntrl's weight at 1 in the driver window select the controller, then the attribute in the driven window select the point constraint and the values press key, select the controller in the driver window, change the attribute to 1 select the point constraint in the driven window and change the Distance Helper1W0 =1 Wrist CNTRL1W1 = 0 and then press key. this should have created the setup for an on and off switch for the stretching of the joint chain. like i said, i figured this out through trying to think of the best way to do this kind of a setup through simple weighting of constraints. Kind of like how you would do a ik/fk setup using 3 joint chains. I just wanted to make sure that this process would be ok if i were to add this to a rig and then animate with said rig any criticism or additional input is greatly appreciated. share quote
 08 August 2012 gagex2z PRO portfolio gagex2z Tampa, USA It's an interesting solution. I admit, I'm curious to see how it performs. Generally I've always found that expressions take much longer to evaluate only behind the dreaded wrap deformer and Cloth simulation in resources demanded. From my research stretch oftentimes seems to be implemented via: SDK via mel to make the translate X of the elbow and wrist keep uniform distance. Just have the SDK in the graph editor set to linear on post infinity. The advantage to this method is that using a blendAttr node you can greate a really awesome elbow locking system for pinning a elbow or knee in place. To turn the stretchy system on or off since we're having the final chain follow the stretchy using translation I just key the weight of the point constraint to determine whether the final chain follows the Ik or not. Technically the Ik arm is always stretchy but since it's using utility nodes or a sdk and not expressions the evaluation doesn't affect the mesh verts. Or: via utility nodes: 2 multiply /divide and a condition node. and another for normalizing scale OR using zeth willie's awesome measure joint chain that allows for proper scaling without plugging the master's scale directly into a multiply divide node's input 1x. again to turn it on or off you key the scale constraint you use to make the final arm follow the stretch. I also want my FK arm to have stretching ability so this requires a bit more of a work around using a stretch grp that's controlled via FK stretch activated by the IK 2 FK switch option. I hope that might help you in your studies. If anyone more knowledgeable seems something off with my method please let me know. share quote
 08 August 2012 ldunham1 Character TD portfolio Lee Dunham Character Rigger Surrey, United Kingdom +1 to the utility nodes suggestion. That rarely (if ever) fails me and keeps things fairly quick. __________________ ldunham.blogspot.com share quote
 08 August 2012 FaustVII New Member portfolio Marquis n/a Campbell, USA Wow great feedback, @gagex2z, I completely didn't even think about using the graph editor. Both methods make sense, its just I'm not to keen on utility nodes although I'm told there easier to manage but that's something I probably need to get over.I will definitely try that out. @ldunham1, Thanks for the comment, I just wanted to let you know I used one of your scripts to fix the deformation order on my rig since there seems to be a bug with trying to do it in maya. Scripting is one thing that scares me and you make it look easy Very useful and appreciated feedback guys, Thanks! share quote
 08 August 2012 everyFrame Veteran portfolio Travis Miller Animationeer Hollywood, USA Whoa man, stop thinking right now. Let me enlighten you ") First, utility nodes to handle the stretch is the only viable solution. But there are easier ways of toggling the stretch on and off. Add an attribute on your ik controller called "allow stretch" and also "force stretch" Allow stretch [0-1, default 1] Force stretch [0-10, default 1] Translate this into utility nodes D = distance from root to controller (the stretch to distance) B = original total chain distance (both bones unstretched) J = original joint length (lets say this is the upArm joint for this example) Condition: If D is > B True: D - B / 2 * allow stretch + J / J * force stretch False: 1 * force stretch Keep in mind the order in which these need to be evaluated. I typed them left to right, in the order they should be evaluated. Running theoretical numbers through this will show why the eval order is crucial. Adjust for global scaling. By dividing this by whatever node your scaling And also, just a small little hint. You can reverse the effect of a toggle/switch by: *-1+1 Keep it simple Goodluck Last edited by everyFrame : 08 August 2012 at 05:24 PM. share quote
 08 August 2012 FaustVII New Member portfolio Marquis n/a Campbell, USA Sorry for the long response time. Thats also a really good idea, but like I said prior I'm kinda fresh to utility nodes. So trying in trying to understand what you said, essentially I'd have a multiple/divide node a condition node and the joints I want to stretch hook up the joint scale x to these nodes and walaa? Putting it simply share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.