pub fn animate(&self, camera: Camera, shared_scene: Arc<Scene>, filename: &str) {
        let animate_start = ::time::get_time();
        let length = self.animate_to - self.animate_from;
        let total_frames = (self.fps * length).floor() as u32;

        // Allow one frame to be renderered while the previous one is being written
        let (frame_tx, frame_rx) = sync_channel(0);
        let (exit_tx, exit_rx) = sync_channel(0);

        let starting_frame_number = self.starting_frame_number;

        let filename = filename.to_string();
        thread::spawn(move || {
            for (frame_num, frame_data) in frame_rx.iter().enumerate() {
                let file_frame_number = starting_frame_number as usize + frame_num;

                let shared_name = format!("{}{:06}.ppm", filename, file_frame_number);
                ::util::export::to_ppm(&frame_data, &shared_name).expect("ppm write failure");
            }

            exit_tx.send(()).unwrap();
        });

        for frame_number in 0..total_frames {
            let time = self.animate_from + f64::from(frame_number) / self.fps;
            let lerped_camera = Animator::lerp_camera(&camera, time);
            let frame_data = self.renderer.render(lerped_camera, Arc::clone(&shared_scene));
            frame_tx.send(frame_data).unwrap();

            ::util::print_progress("*** Frame", animate_start, frame_number as usize + 1usize, total_frames as usize);
            println!("");
        }
        drop(frame_tx);

        exit_rx.recv().unwrap();
    }
// TODO: make this a Surface iterator so both single frame and animation
// process flows are similar
make this a Surface iterator so both single frame and animation
process flows are similar
make this a Surface iterator so both single frame and animation process flows are similar
pub fn animate(&self, camera: Camera, shared_scene: Arc<Scene>, filename: &str) {
        let animate_start = ::time::get_time();
        let length = self.animate_to - self.animate_from;
        let total_frames = (self.fps * length).floor() as u32;
        // Allow one frame to be renderered while the previous one is being written
        let (frame_tx, frame_rx) = sync_channel(0);
        let (exit_tx, exit_rx) = sync_channel(0);
        let starting_frame_number = self.starting_frame_number;
        let filename = filename.to_string();
        thread::spawn(move || {
            for (frame_num, frame_data) in frame_rx.iter().enumerate() {
                let file_frame_number = starting_frame_number as usize + frame_num;
                let shared_name = format!("{}{:06}.ppm", filename, file_frame_number);
                ::util::export::to_ppm(&frame_data, &shared_name).expect("ppm write failure");
            }
            exit_tx.send(()).unwrap();
        });
        for frame_number in 0..total_frames {
            let time = self.animate_from + f64::from(frame_number) / self.fps;
            let lerped_camera = Animator::lerp_camera(&camera, time);
            let frame_data = self.renderer.render(lerped_camera, Arc::clone(&shared_scene));
            frame_tx.send(frame_data).unwrap();
            ::util::print_progress("*** Frame", animate_start, frame_number as usize + 1usize, total_frames as usize);
            println!("");
        }
        drop(frame_tx);
        exit_rx.recv().unwrap();
    }
pub fn animate ( & self , camera : Camera , shared_scene : Arc < Scene > , filename : & str ) { let animate_start = :: time :: get_time ( ) ; let length = self . animate_to - self . animate_from ; let total_frames = ( self . fps * length ) . floor ( ) as u32 ; // Allow one frame to be renderered while the previous one is being written let ( frame_tx , frame_rx ) = sync_channel ( 0 ) ; let ( exit_tx , exit_rx ) = sync_channel ( 0 ) ; let starting_frame_number = self . starting_frame_number ; let filename = filename . to_string ( ) ; thread :: spawn ( move | | { for ( frame_num , frame_data ) in frame_rx . iter ( ) . enumerate ( ) { let file_frame_number = starting_frame_number as usize + frame_num ; let shared_name = format ! ( " " filename file_frame_number ) ; :: util :: export :: to_ppm ( & frame_data , & shared_name ) . expect ( " " ) ; } exit_tx . send ( ( ) ) . unwrap ( ) ; } ) ; for frame_number in 0 .. total_frames { let time = self . animate_from + f64 :: from ( frame_number ) / self . fps ; let lerped_camera = Animator :: lerp_camera ( & camera , time ) ; let frame_data = self . renderer . render ( lerped_camera , Arc :: clone ( & shared_scene ) ) ; frame_tx . send ( frame_data ) . unwrap ( ) ; :: util :: print_progress ( " " , animate_start , frame_number as usize + 1usize , total_frames as usize ) ; println ! ( " " ) ; } drop ( frame_tx ) ; exit_rx . recv ( ) . unwrap ( ) ; }
TODO: make this a Surface iterator so both single frame and animation
process flows are similar
TODO : make this a Surface iterator so both single frame and animation process flows are similar
&self
camera
Camera
shared_scene
Arc<Scene>
filename
&str
&self
camera
Camera
shared_scene
Arc<Scene>
filename
&str