finger flexion sourced from oriels
This commit is contained in:
parent
9cc71fdcd1
commit
54ba006027
1 changed files with 38 additions and 0 deletions
|
@ -51,4 +51,42 @@ public class Rig
|
||||||
held = down;
|
held = down;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float FingerFlex(Hand hand, FingerId id, float deadzone = 0.15f)
|
||||||
|
{
|
||||||
|
float fingerFlex = (Vec3.Dot(
|
||||||
|
Vec3.Direction(
|
||||||
|
hand.Get(id, JointId.Tip).position,
|
||||||
|
hand.Get(id, JointId.KnuckleMinor).position
|
||||||
|
),
|
||||||
|
Vec3.Direction(
|
||||||
|
hand.Get(id, JointId.KnuckleMid).position,
|
||||||
|
hand.Get(id, JointId.KnuckleMajor).position
|
||||||
|
)
|
||||||
|
) + 1f) / 2;
|
||||||
|
float fingerTrim = 0f + deadzone; // 180°
|
||||||
|
return Math.Max(fingerFlex - fingerTrim, 0f) / (1 - fingerTrim);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float KnuckleFlex(Hand hand, FingerId id, float deadzone = 0.15f)
|
||||||
|
{
|
||||||
|
float knuckleFlex = (Vec3.Dot(
|
||||||
|
Vec3.Direction(
|
||||||
|
hand.Get(id, JointId.KnuckleMid).position,
|
||||||
|
hand.Get(id, JointId.KnuckleMajor).position
|
||||||
|
),
|
||||||
|
Vec3.Direction(
|
||||||
|
hand.Get(id, JointId.KnuckleMajor).position,
|
||||||
|
hand.Get(id, JointId.Root).position
|
||||||
|
)
|
||||||
|
) + 1f) / 2;
|
||||||
|
float knuckleTrim = 0.5f + deadzone; // 90°
|
||||||
|
return Math.Max(knuckleFlex - knuckleTrim, 0f) / (1 - knuckleTrim);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Flexion(Hand hand, FingerId id, float deadzone = 0.15f)
|
||||||
|
{
|
||||||
|
float flexion = KnuckleFlex(hand, id, deadzone) * FingerFlex(hand, id, deadzone);
|
||||||
|
return flexion * flexion; // why assume this curve?
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue