-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.cpp
More file actions
128 lines (119 loc) · 4.51 KB
/
interface.cpp
File metadata and controls
128 lines (119 loc) · 4.51 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <iostream>
#include "tracing/tracing.h"
#include "math_classes/vec.h"
#include "glut_drawing/frame.h"
#include "objects/sphere.h"
#include "objects/point_source.h"
#include "objects/plane.h"
zyrt::rt zyrt::MainScene;
void print_mat() { // printing all materials
std::cout << "0. Black Plastic\n"
"1. Brass\n"
"2. Bronze\n"
"3. Chrome\n"
"4. Copper\n"
"5. Gold\n"
"6. Peweter\n"
"7. Silver\n"
"8. Polished Silver\n"
"9. Turquoise\n"
"10. Ruby\n"
"11. Polished Gold\n"
"12. Polished Bronze\n"
"13. Polished Copper\n"
"14. Jade\n"
"15. Obsidian\n"
"16. Peral\n"
"17. Emerald\n"
"18. Black Plastic\n"
"19. Black Rubber\n";
}
void add_object() { // getting info about adding object
std::cout << "Which object do you want to add?\n"
"1 - sphere\n"
"2 - plane\n"
"3 - light source\n"
"Please input number from 1 to 3: ";
std::string s;
std::cin >> s;
while (1) {
if (s == "1") { // case sphere
std::cout << "\nPlease input 3 double numbers - x, y, z coordinates: ";
double x, y, z, r;
std::cin >> x >> y >> z;
std::cout << "\nPlease input 1 double number - radius: ";
std::cin >> r;
print_mat();
std::cout << "\nPlease input 1 number - material from ^ list:\n";
int mt;
std::cin >> mt;
zyrt::shape *obj = new zyrt::sphere(vec(x, y, z), r, mt);
zyrt::MainScene << obj;
break;
} else if (s == "2") { // case plane
std::cout << "\nPlease input 3 double numbers - x, y, z coordinates of any point in this plane: ";
double x, y, z, x2, y2, z2;
std::cin >> x >> y >> z;
std::cout << "\nPlease input 3 double numbers - x, y, z coordinates of normal vector to this plane: ";
std::cin >> x2 >> y2 >> z2;
print_mat();
std::cout << "\nPlease input 1 number - material from ^ list:\n";
int mt;
std::cin >> mt;
zyrt::shape *obj = new zyrt::plane(vec(x2, y2, z2), vec(x, y, z), mt);
zyrt::MainScene << obj;
break;
} else if (s == "3") { // case light source
std::cout << "\nPlease input 3 double numbers - x, y, z coordinates: ";
double x, y, z;
std::cin >> x >> y >> z;
zyrt::point_source *obj = new zyrt::point_source(vec(x, y, z));
zyrt::MainScene << obj;
break;
} else { // case incorrect command
std::cout << "\nWrong command\nPlease input number from 1 to 3: ";
std::cin >> s;
}
}
}
void interface() { // adding objects while user want to
std::cout << "You are looking from (0,0,8) coordinates to (0, 0, 0)\n";
while (1) {
std::cout << "Do you want add one new object?\n"
"Print 1(yes) or 0(no): ";
std::string s;
std::cin >> s;
while (1) {
if (s == "0") {
return;
} else if (s == "1") {
add_object();
break;
} else {
std::cout << "\nPrint 1(yes) or 0(no): ";
std::cin >> s;
}
}
}
}
void std_pic() { // first standard picture
zyrt::shape *s = new zyrt::sphere(vec(0.0, 0.0, 5), 0.2, 6);
zyrt::shape *s2 = new zyrt::sphere(vec(-0.5, -0.5, 5), 0.3, 2);
zyrt::shape *p = new zyrt::plane(vec(1, 1, 0), vec(-1, -1, 0), 10);
zyrt::shape *s3 = new zyrt::sphere(vec(-0.1, 0.25, 5), 0.2, 17);
zyrt::point_source *x = new zyrt::point_source(vec(0, 7, 5));
zyrt::point_source *x2 = new zyrt::point_source(vec(1, 1, 6));
zyrt::MainScene << s << s2 << p << x << x2 << s3;
}
void std_pic2() { // second standard picture
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
zyrt::shape *s = new zyrt::sphere(vec(i, j, 0), 0.5, 16);
zyrt::MainScene << s;
}
}
zyrt::shape *p = new zyrt::plane(vec(0, 1, 0), vec(0, -1, 0), 5);
zyrt::point_source *x = new zyrt::point_source(vec(-10, 10, 0));
zyrt::point_source *x2 = new zyrt::point_source(vec(10, 10, 0));
zyrt::MainScene << x << x2 << p;
}