-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexecise_3.4.cpp
More file actions
47 lines (39 loc) · 1.42 KB
/
Copy pathexecise_3.4.cpp
File metadata and controls
47 lines (39 loc) · 1.42 KB
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
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkSphereSource.h>
auto main() -> int {
const auto sphere_source = vtkSphereSource::New();
sphere_source->SetRadius(1.0);
const auto sphere_smapper = vtkPolyDataMapper::New();
sphere_smapper->SetInputConnection(sphere_source->GetOutputPort());
const auto sphere_actor = vtkActor::New();
sphere_actor->SetMapper(sphere_smapper);
sphere_actor->GetProperty()->SetColor(1.0, 1.0, 1.0);
sphere_actor->GetProperty()->SetAmbient(0.5);
sphere_actor->GetProperty()->SetDiffuse(0.5);
sphere_actor->GetProperty()->SetDiffuseColor(1.0, 0.0, 0.0);
sphere_actor->GetProperty()->SetAmbientColor(0.0, 0.0, 1.0);
const auto render = vtkRenderer::New();
render->AddActor(sphere_actor);
render->SetBackground(0.1, 0.2, 0.4);
const auto wind = vtkRenderWindow::New();
wind->AddRenderer(render);
wind->SetSize(300, 300);
for (int i = 0; i < 10000; ++i) {
wind->Render();
sphere_actor->GetProperty()->GetDiffuseColor()[0] -= 0.001;
sphere_actor->GetProperty()->GetDiffuseColor()[2] += 0.001;
sphere_actor->GetProperty()->GetDiffuseColor()[2] -= 0.001;
sphere_actor->GetProperty()->GetDiffuseColor()[1] += 0.001;
}
sphere_source->Delete();
sphere_smapper->Delete();
sphere_actor->Delete();
render->Delete();
wind->Delete();
return 0;
}