use anymotion::prelude::*;

fn main() {
    println!("AnyMotion - Skeletal Animation Example\n");

    // 1. Create a test skeleton
    let skeleton = create_test_skeleton();
    println!("✓ Created skeleton with {} bones", skeleton.bones.len());

    // Validate topology
    skeleton.validate().expect("Skeleton validation failed");
    println!("✓ Skeleton topology validated");

    // 2. Create a test animation clip
    let clip = create_test_walk_clip().expect("Failed to create animation clip");
    println!(
        "✓ Created animation clip '{}' (duration: {}s)",
        clip.name, clip.duration
    );

    // 3. Sample the animation at different times
    println!("\nSampling animation:");
    for i in 0..=10 {
        let time = (i as f32 / 10.0) * clip.duration;
        if let Some((pos, _, _)) = clip.sample_bone("Hips", time) {
            println!(
                "  t={:.2}s: Hips position = ({:.3}, {:.3}, {:.3})",
                time, pos.x, pos.y, pos.z
            );
        }
    }

    // 4. Demonstrate animator component
    let animator = Animator::new(SkeletonHandle(0), AnimationClipHandle(0));
    println!("\n✓ Created Animator component");
    println!("  - Speed: {}", animator.player.speed);
    println!("  - Looping: {}", animator.player.is_looping);
    println!("  - Playing: {}", animator.player.is_playing);

    // 5. Demonstrate transform component
    let mut transform = Transform::default();
    transform.position.y = 1.0;
    let _matrix = glam::Mat4::from_scale_rotation_translation(
        transform.scale,
        transform.rotation,
        transform.position,
    );
    println!("\n✓ Created Transform component");
    println!(
        "  - Position: ({:.1}, {:.1}, {:.1})",
        transform.position.x, transform.position.y, transform.position.z
    );
    println!("  - Matrix computed successfully");

    println!("\n🎉 AnyMotion core functionality working!");
}
