//! Dump a composite's scene nodes with their scale — the transform the static
//! assembler copies verbatim into a placement.
//! Usage: node_scale <container.xpr> <composite name>
use sylpheed_formats::mesh::scene_world_nodes;
fn main() {
    let a: Vec<String> = std::env::args().collect();
    let bytes = std::fs::read(&a[1]).expect("container");
    for n in scene_world_nodes(&bytes, &a[2]) {
        // Row norms of `m`: a rotation has all three at 1.0; anything else is a
        // scale baked into the matrix, which `s` does not show.
        let norm = |r: [f32; 3]| (r[0] * r[0] + r[1] * r[1] + r[2] * r[2]).sqrt();
        println!(
            "{:<26} s[{:7.3}{:7.3}{:7.3}]  |m rows|[{:7.3}{:7.3}{:7.3}]  t[{:9.1}{:9.1}{:9.1}]",
            n.resource,
            n.s[0], n.s[1], n.s[2],
            norm(n.m[0]), norm(n.m[1]), norm(n.m[2]),
            n.t[0], n.t[1], n.t[2]
        );
    }
}
