-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.h
More file actions
147 lines (102 loc) · 3.96 KB
/
widget.h
File metadata and controls
147 lines (102 loc) · 3.96 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include "QPainter"
#include "QColor"
#include "QTime"
#include <iostream>
#include "limits.h"
#include "float.h"
#include "cmath"
#include "types.h"
#include "painter.h"
#include "scene.h"
#include "canvas.h"
#include "color.h"
#include <stdexcept>
#include <stdlib.h>
#include <thread>
#define THREADS 8
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = nullptr);
~Widget();
error show();
error show_render();
void set_lighting(bool param) {this->lighting = param; }
void set_diffuse(bool param) {this->diffuse = param; }
void set_mirror(bool param) {this->mirror = param; }
void set_shadow(bool param) {this->shadow = param; }
void set_reflection(bool param) {this->reflection = param; }
void set_multithreads(bool param) {this->multithreads = param; }
void set_movable_object(Point &point) {this->movable_object = &point; }
void spin_around_center(int dir_coeff);
void move_object();
void move_object(int x, int y, int z);
void move_object(int x, int y, int z, double step);
void rotate_camera(int pitch, int yaw, int roll);
void rotate_camera(int pitch, int yaw, int roll, double step_deg);
void init_lables();
double tests[10000];
int tests_n = 0;
int scene_param[6] = {1, 1, 1, 1, 1, 1};
private slots:
void on_pitch_button_clicked();
void on_yaw_button_clicked();
void on_roll_button_clicked();
void on_leftMoveButton_clicked();
void on_upMoveButton_clicked();
void on_rightMoveButton_clicked();
void on_downMoveButton_clicked();
void on_aheadMoveButton_clicked();
void on_backMoveButto_clicked();
void on_lightingCheckBox_stateChanged(int arg1);
void on_diffuseCheckBox_stateChanged(int arg1);
void on_mirrorCheckBox_stateChanged(int arg1);
void on_shadowCheckBox_stateChanged(int arg1);
void on_multithreadsCheckBox_stateChanged(int arg1);
void on_renderPushButton_clicked();
void on_timeTestPushButton_clicked();
void on_reflectionCheckBox_stateChanged(int arg1);
void on_cameraRadioButton_clicked();
void on_pointLightRadioButton_clicked();
void on_directionLightRadioButton_clicked();
void on_setPointIntensityPushButton_clicked();
void on_setDirectionIntensityPushButton_clicked();
void on_setAmbientIntensityPushButton_clicked();
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void on_pushButton_7_clicked();
void on_timeTestPushButton_4_clicked();
void on_timeTestPushButton_2_clicked();
void on_timeTestPushButton_3_clicked();
void on_pushButton_4_clicked();
private:
Ui::Widget *ui;
error make_render();
error calculate_render(Painter &painter, borders brds);
error closest_intersection(double &closest_t, int &closest_sphere_i, std::vector<Shape *> &shapes, int shapes_number, Point origin, Vector direction, double t_min, double t_max);
error trace_ray(Color &color, std::vector<Shape *> &shapes, int shapes_number, Light **lights, int lights_number, Point origin, Vector direction, double t_min, double t_max, int depth=4);
error canvas_to_viewport(double &Vx, double &Vy, int x, int y, fov_t fov, size_int size);
error intersect_ray_sphere(double &t1, double &t2, Sphere sphere, const Point O, Vector direction);
double intersect_ray_triangle(Triangle triangle, const Point O, Vector direction);
error compute_lighting(double &intensity, Point P, Vector N, std::vector<Shape *> &shapes, int shapes_number, Light **lights, int lights_number, int specular, Vector V);
Vector reflect_ray(Vector v1, Vector v2);
Canvas *canvases[THREADS];
Painter *painters[THREADS];
Scene *scene;
Point *movable_object;
bool lighting = 1;
bool diffuse = 1;
bool mirror = 1;
bool shadow = 1;
bool reflection = 1;
bool multithreads = 1;
};
#endif // WIDGET_H