-
Notifications
You must be signed in to change notification settings - Fork 2
/
control.cpp
410 lines (385 loc) · 16.3 KB
/
control.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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#include "control.hpp"
#include <iostream>
#include <cmath>
std::string active = "arandomstring";
int multiplier = 1;
void control(int key, int scancode, int action, int mods) {
switch(key) {
case GLFW_KEY_B:
if(action == GLFW_PRESS && mods == 0)
b->keyframe();
if(action == GLFW_PRESS && mods == 1)
b->playback_init();
break;
case GLFW_KEY_F:
if(action == GLFW_PRESS || action == GLFW_REPEAT) {
if(mods == 0)
b->frames += multiplier;
else if(mods == 1)
b->frames -= multiplier;
if(b->frames < 0)
b->frames = 0;
std::cout << "Frames: " << b->frames << " " << std::endl;
}
break;
case GLFW_KEY_PERIOD:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1) {
multiplier++;
std::cout << "Multiplier: " << multiplier << std::endl;
}
break;
case GLFW_KEY_COMMA:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1 && multiplier > 1) {
multiplier--;
std::cout << "Multiplier: " << multiplier << std::endl;
}
break;
case GLFW_KEY_LEFT:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0) {
if(b->camera == 0)
b->rotate_y_ortho(-5);
if(b->camera == 1)
b->move_camera_p(-5);
}
else if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
if(b->camera == 1) {
b->lookat_x -= cos(b->camera_p*PI/180.0);
b->lookat_z += sin(b->camera_p*PI/180.0);
}
break;
case GLFW_KEY_RIGHT:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0) {
if(b->camera == 0)
b->rotate_y_ortho(5);
if(b->camera == 1)
b->move_camera_p(5);
}
else if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
if(b->camera == 1) {
b->lookat_x += cos(b->camera_p*PI/180.0);
b->lookat_z -= sin(b->camera_p*PI/180.0);
}
break;
case GLFW_KEY_UP:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0 && b->camera == 1)
b->move_camera_t(5);
else if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
if(b->camera == 1) {
b->lookat_z -= cos(b->camera_p*PI/180.0);
b->lookat_x -= sin(b->camera_p*PI/180.0);
}
break;
case GLFW_KEY_DOWN:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0 && b->camera == 1)
b->move_camera_t(-5);
else if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
if(b->camera == 1) {
b->lookat_z += cos(b->camera_p*PI/180.0);
b->lookat_x += sin(b->camera_p*PI/180.0);
}
break;
case GLFW_KEY_N:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0 && b->camera == 1)
b->move_camera_r(-0.1);
break;
case GLFW_KEY_M:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0 && b->camera == 1)
b->move_camera_r(0.1);
break;
case GLFW_KEY_V:
if((action == GLFW_PRESS) && mods == 0 && b->camera == 1)
b->camera_free = !b->camera_free;
break;
case GLFW_KEY_0:
if((action == GLFW_PRESS) && mods == 0)
b->camera = 0;
break;
case GLFW_KEY_1:
if((action == GLFW_PRESS) && mods == 0)
b->camera = 1;
break;
case GLFW_KEY_2:
if((action == GLFW_PRESS) && mods == 0)
b->camera = 2;
break;
case GLFW_KEY_R:
if((action == GLFW_PRESS) && mods == 0)
b->day = !b->day;
break;
case GLFW_KEY_C:
if((action == GLFW_PRESS) && mods == 0)
b->moon_toggle = !b->moon_toggle;
break;
/*Activating various parts*/
case GLFW_KEY_SPACE:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0) {
b->transformed = !b->transformed;
if(b->transformed) {
b->count_transform = 200;
b->count_elbows_in = 100;
}
else {
if(b->camera == 3)
b->camera = 1;
b->count_revert = 200;
b->count_elbows_out = 100;
}
}
break;
}
if(true) {
switch(key) {
case GLFW_KEY_3:
if(action == GLFW_PRESS && mods == 0)
b->camera = 3;
break;
case GLFW_KEY_W:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
b->dist = 0.1;
else
b->dist = 0;
break;
case GLFW_KEY_S:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
b->dist = -0.025;
else
b->dist = 0;
break;
case GLFW_KEY_A:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
b->turn = 5;
else
b->turn = 0;
break;
case GLFW_KEY_D:
if(( action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
b->turn = -5;
else
b->turn = 0;
break;
case GLFW_KEY_H:
if(( action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
b->headlight = !b->headlight;
break;
}
//return;
}
switch(key) {
case GLFW_KEY_Z:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "waist";
break;
case GLFW_KEY_T:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "l_shoulder";
break;
case GLFW_KEY_G:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "r_shoulder";
break;
case GLFW_KEY_Y:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "l_elbow";
break;
case GLFW_KEY_H:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "r_elbow";
break;
case GLFW_KEY_U:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "l_wrist";
break;
case GLFW_KEY_J:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "r_wrist";
break;
case GLFW_KEY_I:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "l_hip";
break;
case GLFW_KEY_K:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "r_hip";
break;
case GLFW_KEY_O:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "l_knee";
break;
case GLFW_KEY_L:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "r_knee";
break;
case GLFW_KEY_P:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "l_ankle";
break;
case GLFW_KEY_SEMICOLON:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "r_ankle";
break;
case GLFW_KEY_X:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 0)
active = "neck";
break;
/*Increase the active component in the X direction*/
case GLFW_KEY_Q:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
{
/*Waist Movement*/
if (active == "waist") b->move_waist_x(1);
/*Neck Movement*/
else if (active == "neck") b->move_neck_x(1);
/*Right Shoulder Movement*/
else if (active == "r_shoulder") b->move_right_shoulder_x(1);
/*Right Elbow Movement*/
else if (active == "r_elbow") b->move_right_elbow_x(1);
/*Left Shoulder Movement*/
else if (active == "l_shoulder") b->move_left_shoulder_x(1);
/*Left Elbow Movement*/
else if (active == "l_elbow") b->move_left_elbow_x(1);
/*Right Hip Movement*/
else if (active == "r_hip") b->move_right_hip_x(1);
/*Left Hip Movement*/
else if (active == "l_hip") b->move_left_hip_x(1);
/*Right Knee Movement*/
else if (active == "r_knee") b->move_right_knee_x(1);
/*Left Knee Movement*/
else if (active == "l_knee") b->move_left_knee_x(1);
/*Right Ankle Movement*/
else if (active == "r_ankle") b->move_right_ankle_x(1);
/*Left Ankle Movement*/
else if (active == "l_ankle") b->move_left_ankle_x(1);
/*Right Wrist Movement*/
else if (active == "r_wrist") b->move_right_wrist_x(1);
/*Left Wrist Movement*/
else if (active == "l_wrist") b->move_left_wrist_x(1);
}
break;
/*Decrease the active component in the X direction*/
case GLFW_KEY_A:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
{
/*Waist Movement*/
if (active == "waist") b->move_waist_x(-1);
/*Neck Movement*/
else if (active == "neck") b->move_neck_x(-1);
/*Right Shoulder Movement*/
else if (active == "r_shoulder") b->move_right_shoulder_x(-1);
/*Right Elbow Movement*/
else if (active == "r_elbow") b->move_right_elbow_x(-1);
/*Left Shoulder Movement*/
else if (active == "l_shoulder") b->move_left_shoulder_x(-1);
/*Left Elbow Movement*/
else if (active == "l_elbow") b->move_left_elbow_x(-1);
/*Right Hip Movement*/
else if (active == "r_hip") b->move_right_hip_x(-1);
/*Left Hip Movement*/
else if (active == "l_hip") b->move_left_hip_x(-1);
/*Right Knee Movement*/
else if (active == "r_knee") b->move_right_knee_x(-1);
/*Left Knee Movement*/
else if (active == "l_knee") b->move_left_knee_x(-1);
/*Right Ankle Movement*/
else if (active == "r_ankle") b->move_right_ankle_x(-1);
/*Left Ankle Movement*/
else if (active == "l_ankle") b->move_left_ankle_x(-1);
/*Right Wrist Movement*/
else if (active == "r_wrist") b->move_right_wrist_x(-1);
/*Left Wrist Movement*/
else if (active == "l_wrist") b->move_left_wrist_x(-1);
}
break;
/*Increase the active component in the Y direction*/
case GLFW_KEY_W:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
{
/*Waist Movement*/
if (active == "waist") b->move_waist_y(1);
/*Camera Movement*/
else if (active == "camera") b->rotate_y(5);
/*Neck Movement*/
else if (active == "neck") b->move_neck_y(1);
/*Right Shoulder Movement*/
else if (active == "r_shoulder") b->move_right_shoulder_y(1);
/*Left Shoulder Movement*/
else if (active == "l_shoulder") b->move_left_shoulder_y(1);
/*Right Hip Movement*/
else if (active == "r_hip") b->move_right_hip_y(1);
/*Left Hip Movement*/
else if (active == "l_hip") b->move_left_hip_y(1);
/*Right Ankle Movement*/
else if (active == "r_ankle") b->move_right_ankle_y(1);
/*Left Ankle Movement*/
else if (active == "l_ankle") b->move_left_ankle_y(1);
}
break;
/*Decrease the active component in the Y direction*/
case GLFW_KEY_S:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
{
/*Waist Movement*/
if (active == "waist") b->move_waist_y(-1);
/*Camera Movement*/
else if (active == "camera") b->rotate_y(-5);
/*Neck Movement*/
else if (active == "neck") b->move_neck_y(-1);
/*Right Shoulder Movement*/
else if (active == "r_shoulder") b->move_right_shoulder_y(-1);
/*Left Shoulder Movement*/
else if (active == "l_shoulder") b->move_left_shoulder_y(-1);
/*Right Hip Movement*/
else if (active == "r_hip") b->move_right_hip_y(-1);
/*Left Hip Movement*/
else if (active == "l_hip") b->move_left_hip_y(-1);
/*Right Ankle Movement*/
else if (active == "r_ankle") b->move_right_ankle_y(-1);
/*Left Ankle Movement*/
else if (active == "l_ankle") b->move_left_ankle_y(-1);
}
break;
/*Increase the active component in the Z direction*/
case GLFW_KEY_E:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
{
/*Waist Movement*/
if (active == "waist") b->move_waist_z(1);
/*Right Shoulder Movement*/
else if (active == "r_shoulder") b->move_right_shoulder_z(1);
/*Left Shoulder Movement*/
else if (active == "l_shoulder") b->move_left_shoulder_z(1);
/*Right Hip Movement*/
else if (active == "r_hip") b->move_right_hip_z(1);
/*Left Hip Movement*/
else if (active == "l_hip") b->move_left_hip_z(1);
/*Neck Movement*/
else if (active == "neck") b->move_neck_z(1);
/*Right Wrist Movement*/
else if (active == "r_wrist") b->move_right_wrist_z(1);
/*Left Wrist Movement*/
else if (active == "l_wrist") b->move_left_wrist_z(1);
}
break;
/*Decrease the active component in the Z direction*/
case GLFW_KEY_D:
if((action == GLFW_PRESS || action == GLFW_REPEAT) && mods == 1)
{
/*Waist Movement*/
if (active == "waist") b->move_waist_z(-1);
/*Right Shoulder Movement*/
else if (active == "r_shoulder") b->move_right_shoulder_z(-1);
/*Left Shoulder Movement*/
else if (active == "l_shoulder") b->move_left_shoulder_z(-1);
/*Right Hip Movement*/
else if (active == "r_hip") b->move_right_hip_z(-1);
/*Left Hip Movement*/
else if (active == "l_hip") b->move_left_hip_z(-1);
/*Neck Movement*/
else if (active == "neck") b->move_neck_z(-1);
/*Right Wrist Movement*/
else if (active == "r_wrist") b->move_right_wrist_z(-1);
/*Left Wrist Movement*/
else if (active == "l_wrist") b->move_left_wrist_z(-1);
}
break;
}
}