-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtexture_mapping.cpp
48 lines (38 loc) · 1.53 KB
/
texture_mapping.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "vtkABI.h"
#include "vtkActor.h"
#include "vtkBMPReader.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkPlaneSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"
#include "vtkTexture.h"
#include "platform.h"
int main() {
const auto bmp_reader = vtkSmartPointer<vtkBMPReader>::New();
bmp_reader->SetFileName(
(fs::canonical("Data").string() + "/masonry.bmp").c_str());
const auto texture = vtkSmartPointer<vtkTexture>::New();
texture->SetInputConnection(bmp_reader->GetOutputPort());
texture->SetInterpolate(VTK_TRUE);
const auto plane_source = vtkSmartPointer<vtkPlaneSource>::New();
const auto plane_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
plane_mapper->SetInputConnection(plane_source->GetOutputPort());
const auto plane_actor = vtkSmartPointer<vtkActor>::New();
plane_actor->SetMapper(plane_mapper);
plane_actor->SetTexture(texture);
const auto render = vtkSmartPointer<vtkRenderer>::New();
render->AddActor(plane_actor);
const auto render_window = vtkSmartPointer<vtkRenderWindow>::New();
render_window->AddRenderer(render);
const auto interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
const auto interactor_style
= vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
interactor->SetInteractorStyle(interactor_style);
interactor->SetRenderWindow(render_window);
interactor->Initialize();
render_window->Render();
interactor->Start();
}