Skip to main content

Linear Interpolation Expression Based

20 Mar 2024 Advance Skeleton has its own driving system and even features pose interpolation. Unfortunately, it does not work well if the rig is asymetrical. Hence, making a separate simple script below.

This one works for most cases since its for a scapula driver where it will most likely be rotated in one axis.

But maybe implement an expression based RBF next time?

proc float lerp(float $a, float $b, float $t) {
return (($b - $a) * $t) + $a;
}


// Rotate X
float $minBase = 0.0;
float $maxBase = -40.0;
float $minTarget = 0.0;
float $maxTarget = -2.958;

float $orig_val = FKScapula_R.rotateY;
float $new_val = lerp($minTarget, $maxTarget, ($orig_val - $minBase) / ($maxBase - $minBase));
FKExtrashoulderPad01_R.rotateX = $new_val;

22 June 2022 Another usage for linear interpolation but to mirror the Set Driven Key Relationship. I find myself using this compared to SDK since SDK is broken once you delete the node but expression based connection still works as long as you have a consistent name

// Define the input attribute
float $input = AimEye_M.right_eye_blink;

// Define the input range
float $inputMin = 0.0;
float $inputMax = 1.0;

// Define the output range
float $outputMin = 0.0;
float $outputMax = 30.0;


// Calculate the normalized value (0 to 1)
float $normalizedValue = ($input - $inputMin) / ($inputMax - $inputMin);

// Map the normalized value to the output range
float $mappedValue = $outputMin + ($normalizedValue * ($outputMax - $outputMin));

// Assign the mapped value to the desired attribute
upper_eyelid_R_main_jnt.rotateY = $mappedValue;


Another version:

// Define the input attribute
float $input = AimEye_M.right_eye_blink;

// Define the input range
float $inputMin = 0.0;
float $inputMax = 1.0;

// Define the output range
float $outputMin = 0.0;
float $outputMax = 30.0;


// Calculate the normalized value (0 to 1)
float $normalizedValue = ($input - $inputMin) / ($inputMax - $inputMin);

// Map the normalized value to the output range
float $mappedValue = $outputMin + ($normalizedValue * ($outputMax - $outputMin));

// Assign the mapped value to the desired attribute
upper_eyelid_R_main_jnt.rotateY = $mappedValue;

////////////////////////////////

// Define the output range
float $outputMin = 0.0;
float $outputMax = 0.601;


// Calculate the normalized value (0 to 1)
float $normalizedValue = ($input - $inputMin) / ($inputMax - $inputMin);

// Map the normalized value to the output range
float $mappedValue = $outputMin + ($normalizedValue * ($outputMax - $outputMin));

// Assign the mapped value to the desired attribute
upper_eyelid_R_02_jnt.translateX = $mappedValue;


////////////////////////////////

// Define the output range
float $outputMin = 0.0;
float $outputMax = 0.32;


// Calculate the normalized value (0 to 1)
float $normalizedValue = ($input - $inputMin) / ($inputMax - $inputMin);

// Map the normalized value to the output range
float $mappedValue = $outputMin + ($normalizedValue * ($outputMax - $outputMin));

// Assign the mapped value to the desired attribute
upper_eyelid_R_01_jnt.translateX = $mappedValue;

/////////////////////////////////

// Define the input attribute
float $input = AimEye_M.left_eye_blink;


// Define the output range
float $outputMin = 0.0;
float $outputMax = 30.0;


// Calculate the normalized value (0 to 1)
float $normalizedValue = ($input - $inputMin) / ($inputMax - $inputMin);

// Map the normalized value to the output range
float $mappedValue = $outputMin + ($normalizedValue * ($outputMax - $outputMin));

// Assign the mapped value to the desired attribute
upper_eyelid_L_main_jnt.rotateY = $mappedValue;

/////////////////


// Define the output range
float $outputMin = 0.0;
float $outputMax = -0.601;


// Calculate the normalized value (0 to 1)
float $normalizedValue = ($input - $inputMin) / ($inputMax - $inputMin);

// Map the normalized value to the output range
float $mappedValue = $outputMin + ($normalizedValue * ($outputMax - $outputMin));

// Assign the mapped value to the desired attribute
upper_eyelid_L_02_jnt.translateX = $mappedValue;

////////////////////////////////

// Define the output range
float $outputMin = 0.0;
float $outputMax = -0.32;


// Calculate the normalized value (0 to 1)
float $normalizedValue = ($input - $inputMin) / ($inputMax - $inputMin);

// Map the normalized value to the output range
float $mappedValue = $outputMin + ($normalizedValue * ($outputMax - $outputMin));

// Assign the mapped value to the desired attribute
upper_eyelid_L_01_jnt.translateX = $mappedValue;