Skip to content

jaynus/spine

Repository files navigation

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();

About

spine runtime wrapper in rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published