View Full Version : curve length into joint scale
02 February 2007, 02:40 AM
i want to have a pline ik
but i want the joints on the spline to scale to always match the length of the spline
so i want to basically take the spline length divide it by how ever many joints and pipe that into the joint scale in X
but i don't know how to get the curve length or spline length or whatever you call it
02 February 2007, 05:58 AM
This is a common setup for a stretchy spline ik. You'll basically want to get the length of the curve, divide that by the original undeformed length, and this will drive the appropriate scale axis on your joints.
First you have to have a spline ik chain setup. Then you create a curveInfo node:
createNode -n "spineScalerCurveInfo" curveInfo;
This node type gives you the length of a specific curve. Next, you select your spine curve's shape node using the attribute editor, along with the new curveInfo node. In the hypergraph, click the input and output connections view. Middle mouse drag the curve shape node over the curveInfo node to invoke the connection editor, and then connect the worldSpace attribute of the curve shape node on the right, and then the inputCurve attribute of the curveInfo node on the left. You have now connected the curve to the curveInfo node.
Next, you create another node, this time a multiplyDivide node, to divide the current curve length by the original curve length, deriving the scale value.
createNode -n "spineMultiplyDivide" multiplyDivide;
Select the curveInfo node, and this multiplyDivide node, and click input and output connections again in the hypergraph. Middle mouse drag the curveInfo over to the multiplyDivide to get the connection editor, and this time connect the arcLength attribute to any one of the input1X, 1Y or 1Z attributes (it dosen't matter which, you just need one axis to divide with). The multiplyDivide will now read the length of the curve in one of the input1 axis channels. What you have to do now is manually type in the value you see into the appropriate input2 channel (if you used 1X, input the value into 2X, etc.). Also, don't forget to set the multiplyDivide's operation to divide.
The result of this is that the node will constantly divide the length of the curve by the original length. If it's 16/16, you get a value of 1 (which is the default scale of your joints at creation). Move the curve points to increase the length, and the result will be greater than 1. What you have to do now is to connect the resultant output axis to the appropriate scale axis on all of your spline joints (except the tail end joint, you don't need to connect that one). Then all your joints will scale appopriately as your curve grows or shrinks.
02 February 2007, 05:44 PM
hey thanks alot !
thats great just what i needed
thanks for the indepth explination too.
any idea how to easily connnect that attr into 200 joints ?
02 February 2007, 06:56 PM
i used this to connect them fast
since i have alot of joints
but now i can't figure out how to blend the stretch on and off
i can turn it on and off with a condition or other ways
but i am not sure how to blend it on and off
02 February 2007, 07:11 PM
i used a blend colors node for that
seems to work
is that ok ?
02 February 2007, 01:35 AM
Yes, the blendColors node will work.
What I did with it was connect the curveInfo's ,arcLength to the blendColor's .color1R attribute, then manually typed the rest length of the curve into the .color2R attribute. I then connected the blender attribute to a control curve. Then finally I connected the .outputR to the already existing multiplyDivide node's .input2X, the one used to derive the joint scale.
This will provide you a switch that changes the divisor used to get the joint scale. When set to zero, the blend feeds a value into the multiplyDivide's .input2X value which is the same as the .input1X value, so the node always outputs a value of 1 when it divides. When set to 1, it blend color node feeds the original length of the curve, returning the original reaction of the setup.
02 February 2007, 01:35 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.