Skip to content
Snippets Groups Projects
Commit 3ff3fdf5 authored by Ali Can Demiralp's avatar Ali Can Demiralp
Browse files

Video writing works.

parent 6bd24041
Branches
No related tags found
No related merge requests found
#include <algorithm>
#include <cstdint>
#include <vtkAVIWriter.h>
#include <vtkOSPRayPass.h>
#include <vtkPNGWriter.h>
#include <vtkPolyDataMapper.h>
......@@ -41,18 +42,23 @@ std::int32_t main(std::int32_t argc, char** argv)
renderer ->AddActor (pd_actor );
renderer ->AddVolume(ug_volume);
std::cout << "Setting up image writer.\n";
std::cout << "Setting up image and video writers.\n";
auto window_to_image = vtkSmartPointer<vtkWindowToImageFilter>::New();
auto image_writer = vtkSmartPointer<vtkPNGWriter> ::New();
auto video_writer = vtkSmartPointer<vtkAVIWriter> ::New();
window_to_image->SetInput (window);
image_writer ->SetInputConnection(window_to_image->GetOutputPort());
// TODO: Video writer.
video_writer ->SetInputConnection(window_to_image->GetOutputPort());
video_writer ->SetFileName ("video.avi");
video_writer ->SetQuality (2);
video_writer ->SetRate (settings.update_rate); // 24
video_writer ->Start ();
std::cout << "Starting render.\n";
auto current_time = 0.0f;
auto counter = 0;
auto last_slice = -1;
while (current_time < settings.key_frames.back().time)
while (current_time < settings.key_frames.back().time && counter < 10)
{
std::cout << "Rendering frame " << counter << ".\n";
......@@ -77,11 +83,13 @@ std::int32_t main(std::int32_t argc, char** argv)
window ->Render ();
image_writer->SetFileName((std::string("frame_") + std::to_string(counter) + std::string(".png")).c_str());
image_writer->Write ();
video_writer->Write ();
current_time += settings.update_rate;
counter ++;
}
std::cout << "Finished render.\n";
video_writer->End();
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment