skelly
Crate for skeleton animation.
Optionally provides inverse-kinematics functionality.
Example
// build a skelly with leg and two arms.
let mut skelly = new;
let foot = skelly.add_root;
let leg = skelly.attach;
let waist = skelly.attach;
let left_shoulder = skelly.attach;
let left_arm = skelly.attach;
let left_palm = skelly.attach;
let right_shoulder = skelly.attach;
let right_arm = skelly.attach;
let right_palm = skelly.attach;
// Write global isometries of every joint into an array.
let mut globals = vec!;
skelly.write_globals;
IK example
let mut skelly = Skelly::<f32>::new();
let foot = skelly.add_root(Point3::origin());
let leg = skelly.attach(Vector3::z().into(), foot);
let waist = skelly.attach(Vector3::z().into(), leg);
let left_shoulder = skelly.attach(Vector3::z().into(), waist);
let left_arm = skelly.attach((-Vector3::x()).into(), left_shoulder);
let left_palm = skelly.attach((-Vector3::x()).into(), left_arm);
let right_shoulder = skelly.attach(Vector3::z().into(), waist);
let right_arm = skelly.attach(Vector3::x().into(), right_shoulder);
let right_palm = skelly.attach(Vector3::x().into(), right_arm);
use skelly::ik::fabrik::FabrikSolver;
// Using the skelly above, do some inverse-kinematics
let mut posture = Posture::new(&skelly);
let mut solver = FabrikSolver::new(0.01);
// move left palm to the foot.
solver.set_position_goal(left_palm, Point3::origin());
// Prepare global isometries array for every joint in the posture into an array.
let mut globals = vec![Isometry3::identity(); skelly.len()];
// Iteratively solve imposed constraints.
loop {
solver.solve_step(&skelly, &mut posture);
posture.write_globals(&skelly, &Isometry3::identity(), &mut globals);
// Use `globals` to render skelly in partially solved posture.
}
See [demo] for working example.
License
Licensed under either of
- Apache License, Version 2.0, (license/APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (license/MIT or http://opensource.org/licenses/MIT)
at your option.
Contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.