This commit is contained in:
Spencer Killen 2024-01-02 10:48:00 -07:00
parent ccf290f070
commit cc792cfb1b
Signed by: sjkillen
GPG Key ID: 3AF3117BA6FBB75B
1 changed files with 15 additions and 8 deletions

View File

@ -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<dyn Error>> {
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<f32> = 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<Point> = 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,