Knee pop… damper on n stretchy joints
(notes too long, attempt at coherence…)
Placing the knee damper into Andrew’s rig is a challenge. It has multiple bone scale controls, and a double knee joints setup.
The original script should work with controlled scaling, but I need to see where to insert the script so there won’t be unstable (cycling or conflicting) scale operations.
Investigate leg rig:
Stretchy_Limbs expression scales bones to reach overextended IK controllers.
This effect can be on/off.
Distance node (R_hip, R_anke) shows right leg longer than left.
The constant value 36.700 in DivScaleLimbs is the total length of all leg bones, confirmed by checking the thigh+shin+small_knee to be 36.7031111. So stretching should only occur when all knee angles are pi.
Full rig scale also affects the distance node. I suppose it corrects it for global scale difference. I’ll ignore this for now.
Fixed: frames where the controller’s exactly at full exstension, remains a scale=1.0.
/*expression error example
An expression linked channel is purple only when the expression has a direct assignment of form “obj.attr=value”. setAttr will not create expression link.
Linked channels update correctly up to 1 nesting (ie assignment is in a top scope like if, for clauses). 2 or more scope nesting may produce unstable results (eg if{ if{} }). One situation will have about 3 separate answers per frame depending on timescolling, step forward to frame, step backward to frame, & jump to frame.
Any non expression commands (like tag based, eval “ etc) makes the link unstable.
*/
if(joint25.rotateX<1){
if(time>1){
joint26.scaleX=2;
joint25.scaleX=2;
}
else{
joint26.scaleX=time*2;
joint25.scaleX=time*2;
}
}
Answer: I think this is undocumented in mayadocs? So I can destroy all expression links and make them purely “script-like”. Or limit the scope nesting. Placing non exp commands into a separate function gave the same unstable results. Not all the knee pop commands can convert to exp friendly, so I need to “scriptify” the whole expression.
Now it is STABLE! Damping works.
However, damper works under a particular scope of the scaling expressions, so when the leg transitions out of the damper scope, it is NOT smooth. Due to the leg still bent, so damper needs to stay active until knee is completely straight.
This also means both stretching needs a specific threshold length, and the damper needs to use a particular distance measure. It’s trivial and working when a leg has 2 bones, but a double knee changes distance assumptions.
Generalizations: IK chain, a start and end bone, n bones in between approximate an arc. OR, majority of leg length is start/end bones, and n very small bones in btw approximate 1 knee joint.
Error: bad approximation where answer either doesn’t converge, or converging from the wrong side of a limit.
Error 1: Theta extracts an offcenter angle, so:
smaller theta (than true knee theta) => smaller x2
Fix: No need for virtual tri. Just angle of the virtual knee.
Error 2: smaller leg length => smaller x2
Fix: need to assume thigh, shin form equilateral triangle. Obtuse triangles (with partially unknown lengths) require more calculation.
(…blah blah TMI…assume full equilateral symmetry…)
Ratio: 0.963 //using $lThigh as triangle side
Ratio is constant when correcting (using original theta1), suggests equation is correct to a constant error.
Ratio: 1.041 //using $lShin as triangle side
Thigh and shin lengths different: 17.22805234, 18.66578588
Use avg length helps approx.
Ratio: 1.0 //WOW! Equations exactly match => approximation correctness.
Once theta2, the corrective angle, is applied, it all works smoothly. WOOT!!!
Video of leg:
stretch: original stretchy to reach overextended IK control
damp: this script
damp+stretch: the 2 working happily
No Comments Yet
Be the first to comment!



