diff --git a/tools/src/main.rs b/tools/src/main.rs index 3e4bdb7..d90421b 100644 --- a/tools/src/main.rs +++ b/tools/src/main.rs @@ -10,7 +10,8 @@ use openexr::core::frame_buffer::{FrameBuffer, Slice}; use openexr::core::header::Header; use openexr::core::output_file::OutputFile; use openexr::core::{Compression, PixelType}; -use pointcache::{MDDFrame, MDDSeekableFile, Point, PointCache}; +use pointcache::{AnimationInfo, MDDFrame, MDDSeekableFile, Point, PointCache}; +use std::io::Write; use std::{error::Error, fs::File}; pub const MAX_IMAGE_DIM: usize = 16384; @@ -106,6 +107,17 @@ fn write_point_image( Ok(()) } +// Not used because blender always starts frame frame zero so this info is useless +fn write_animation_info(filename: &str, info: AnimationInfo) -> Result<(), Box> { + let data = format!( + "{{ \"total_frames\": {}, \"total_points\": {}, \"start_frame\": {}, \"end_frame\": {}, \"fps\": {} }}\n", + info.total_frames, info.total_points, info.start_frame, info.end_frame, info.fps + ); + let mut file = File::create(filename)?; + file.write_all(data.as_bytes())?; + Ok(()) +} + #[derive(Debug, Clone, Copy)] enum PointState { Unseen, @@ -164,12 +176,7 @@ fn main() { let mask: Vec = mask_last.iter().map(PointState::mask_value).collect(); - write_mask_image( - &(basename.clone() + "_mask.exr"), - &mask, - info.total_points, - ) - .unwrap(); + write_mask_image(&(basename.clone() + "_mask.exr"), &mask, info.total_points).unwrap(); let mut pixels: Vec = Vec::with_capacity(total_varying * (info.total_frames)); @@ -205,7 +212,7 @@ fn main() { } write_point_image( - &(basename + ".exr"), + &(basename.clone() + ".exr"), &pixels, total_varying, info.total_frames,