2 releases

0.1.1 Feb 28, 2020
0.1.0 Feb 26, 2020

#6 in #spine


Used in spine

MIT license

710KB
18K SLoC

Rust 10K SLoC // 0.0% comments C 9K SLoC // 0.1% comments

Build Status Docs badge Crates badge

Spine rendering in glow

Rust Spine Runtime

These are high level, safe Rust bindings for the spine-c runtime by Esoteric Software

WIP Status

  • spine-c FFI Wrapper
    • Proof of concept example runs and animates

    • Struct Wrappers completion

      • Skeleton
        • SkeletonData
        • Skeleton
        • SlotData
        • Slot
        • Attachment
        • RegionAttachment
        • Bone
      • Animation
        • AnimationData
        • TaskEntry

      ....

Code Example

// Load the spine texture atlas
let atlas = Atlas::from_file("example.atlas", |atlas_page, path| {
    // Perform Texture loading into your renderer here. 
    // Return a u32 that will be used internally to reference the texture
    123
}).unwrap();

// Load the spine skeleton data from a binary file
let skeleton_data = SkeletonData::from_binary_file("example.skel", atlas).unwrap();
// Load the animation data from the associated skeleton
let animation_data = AnimationStateData::new(&skeleton_data);

// Spawn an instance of the skeleton animation. Each Skeleton+Animation combo references a unique skeleton and animation set.
let mut skeleton = Skeleton::new(&skeleton_data);
let mut animation = AnimationState::new(&animation_data);

// List available animations
skeleton_data.animations().iter().for_each(|a| {
    println!("Available Animation: {}", a.name());
});

// Set an active animation
animation.set_by_name(animations[0].name(), TrackIndex::zero(), true);

....

// Animations and skeletons are then updated as follows, which follows the spine runtime.
skeleton.update(delta_time_f32_seconds);

animation.update(delta_time_f32_seconds);
animation.apply(skeleton);

skeleton.update_world_transforms();

Dependencies

~0.3–1MB
~24K SLoC