This repository has been archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.h
192 lines (186 loc) · 4.38 KB
/
events.h
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//
// events.h
// CG_Projeto
//
// Created by Dylan Perdigão on 27/10/2020.
//
//Projections
#include "illumination.h"
#define PERSPECTIVE 0
#define ORTHOGONAL 1
#ifndef events_h
#define events_h
///timer
GLint msec = 10;
///observador
GLfloat theta = acos(-1)/2;
GLfloat obsP[] = { 0, 2.5, 10};
GLfloat obsT[] = { obsP[0] - cos(theta), obsP[1], obsP[0] - sin(theta) };
float angleZ = 95;
int projectionType = 0;
int zoom=2;
///porta
GLfloat maxDoorShift=16;
GLfloat maxWindowShift=1;
GLfloat maxDoorAngle=100;
GLfloat mainDoorPosX;
GLfloat secDoorAngle;
GLfloat windowPosY;
///malha
GLint dim = 32; //numero divisoes da grelha
void Timer(int value){
glutPostRedisplay();
glutTimerFunc(msec, Timer, 1);
}
void keyboard(unsigned char key, int x, int y) {
switch (key) {
case '1':
isDay = !isDay;
if (isDay) {
for(int i=0;i<3;i++){
sunAmb[i] = SUN_LIGHT;
}
}else{
for(int i=0;i<3;i++){
sunAmb[i] = MOON_LIGHT;
}
}
break;
case '2':
isTorchON = !isTorchON;
break;
case '3':
if (torchIntensity > INTENSITY_MIN){
torchIntensity -= INTENSITY_STEP;
}
break;
case '4':
if (torchIntensity < INTENSITY_MAX){
torchIntensity += INTENSITY_STEP;
}
break;
case 'r':
case 'R':
isRed=!isRed;
break;
case 'g':
case 'G':
isGreen=!isGreen;
break;
case 'b':
case 'B':
isBlue=!isBlue;
break;
///Specualr
case 'c':
case 'C':
originalCoef=!originalCoef;
break;
///deslocamento porta direita esquerda
case 'd':
case 'D':
if(mainDoorPosX<0){
mainDoorPosX++;
}
break;
case 'a':
case 'A':
if(mainDoorPosX>-maxDoorShift){
mainDoorPosX--;
}
break;
///deslocamento janela cima baixo
case 'w':
case 'W':
if(windowPosY<maxWindowShift){
windowPosY+=0.1;
}
break;
case 's':
case 'S':
if(windowPosY>0){
windowPosY-=0.1;
}
break;
///deslocamento porta secundaria abrir fechar
case 'q':
case 'Q':
if (secDoorAngle>-maxDoorAngle){
secDoorAngle-=3;
}
break;
case 'e':
case 'E':
if (secDoorAngle<0){
secDoorAngle+=3;
}
break;
///projeção
case 'p':
case 'P':
switch (projectionType) {
case ORTHOGONAL:
projectionType=PERSPECTIVE;
break;
case PERSPECTIVE:
projectionType=ORTHOGONAL;
break;
}
break;
///Zoom
case 'o':
case 'O':
switch (zoom) {
case 2:
zoom=4;
break;
case 4:
zoom=1;
break;
default:
zoom=2;
break;
}
break;
///Malha
case 'm':
case 'M':
if(dim<512){
dim*=2;
}else{
dim=1;
}
break;
///EXIT
case 27:
exit(0);
break;
}
updateLights();
glutPostRedisplay();
}
void keysNotAscii(int key, int x, int y) {
switch (key) {
case GLUT_KEY_UP:
obsP[0] -= 0.5 * cos(theta);
obsP[2] -= 0.5 * sin(theta);
break;
case GLUT_KEY_DOWN:
obsP[0] += 0.5 * cos(theta);
obsP[2] += 0.5 * sin(theta);
break;
case GLUT_KEY_LEFT:
theta -= 0.1;
break;
case GLUT_KEY_RIGHT:
theta += 0.1;
break;
default:
break;
}
obsT[0] = obsP[0] - cos(theta);
obsT[2] = obsP[2] - sin(theta);
updateLights();
glutPostRedisplay();
}
#endif /* events_h */