-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtilities.flow
More file actions
751 lines (663 loc) · 19.7 KB
/
Copy pathUtilities.flow
File metadata and controls
751 lines (663 loc) · 19.7 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
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
import("AssignNames.flow");
import("Math.flow");
import("Utilities.msg");
import("ZealPad.flow");
bool controller;
// Global Variables
global float camRot_X;
global float camRot_Y;
global float camRot_Z;
global float camPos_X;
global float camPos_Y;
global float camPos_Z;
// Regular text window
void Message(int messageId)
{
MSG_WND_DSP();
MSG(messageId);
MSG_WND_CLS();
}
// System text window
void SystemMessage(int messageId)
{
MSG_WND_DSP();
MSG_SYSTEM(messageId);
MSG_WND_CLS();
}
// System text window with options
int SystemMenu(int messageId, int optionsMsgId)
{
MSG_WND_DSP();
MSG_SYSTEM(messageId);
int selection = SEL(optionsMsgId);
MSG_WND_CLS();
return selection;
}
// "What Should I Do?" style menu
int Menu(int optionsMsgId)
{
int selection = SEL_GENERIC_NOT_HELP(-1, optionsMsgId);
return selection;
}
// "What Should I Do?" style menu with caption
int NameMenu(int nameMsgId, int optionsMsgId)
{
int selection = SEL_GENERIC_NOT_HELP(nameMsgId, optionsMsgId);
return selection;
}
// "What Should I Do?" style menu with caption and descriptions
int DescriptionMenu(int nameMsgId, int optionsMsgId)
{
int selection = SEL_GENERIC(nameMsgId, optionsMsgId);
return selection;
}
// "What Should I Do?" style menu with 0-9 digit entry,
// returns int with a set number of digits
int NumberMenu(int digitCount, int nameMsgId)
{
if (controller)
{
//return InputNumber(digitCount);
}
int number = 0;
for (int i = 0; i < digitCount; i++)
{
int digit = NameMenu(nameMsgId, Options_Digits);
if (digit == -1)
{
// Returns -1 if cancelled before any number has been entered
if (i == 0)
{
return -1;
}
else
break;
}
number *= 10;
number += digit;
}
PUTS("NumberMenu returned: ");
PUT(number);
return number;
}
// Same as above but goes up to 10, only selected once
// with no confirmation. Used for Confidant Rank
int NumberMenuTen()
{
int selection = Menu(Options_DigitsTen);
return selection;
}
// "What Should I Do?" style menu with 0-9 digit entry,
// returns float with decimal value
float FloatMenu()
{
int i = 0;
float ipart = 0;
while (true && !PAD_CHK_PRESS(PadButton.L2))
{
float digit = Menu(Options_Digits);
if (digit == -1)
{
// Number should only equal negative one if we cancel
// before entering anything.
if (i == 0)
return -1;
else
break;
}
ipart *= 10;
ipart += digit;
i++;
}
i = 0;
float fpart = 0;
while (true && !PAD_CHK_PRESS(PadButton.L2))
{
float digit = Menu(Options_Digits);
if (digit == -1)
break;
fpart *= 10;
fpart += digit;
i++;
}
if (ConfirmFloat(ipart, fpart) == 0)
{
return -1;
}
float number = ipart + (fpart / Pow(10, i));
return number;
}
int ConfirmNumber(int number)
{
SET_MSG_VAR(0, number, 0);
if (SystemMenu(Message_ConfirmNumberInput, Options_YesNo) == 0)
return 1;
else
return 0;
return -1;
}
int ConfirmFloat(int number, int fractionalPart)
{
SET_MSG_VAR(0, number, 0);
SET_MSG_VAR(1, fractionalPart, 0);
if (SystemMenu(Message_ConfirmFloatInput, Options_YesNo) == 0)
return 1;
else
return 0;
return -1;
}
// Show XYZ values of player's current translation/rotation in debug log
void PrintPosition()
{
PUTS("Joker Translation:");
int pcHandle = FLD_PC_GET_RESHND(0);
PUTS("X:");
PUT(FLD_MODEL_GET_X_TRANSLATE(pcHandle));
PUTS("Y:");
PUT(FLD_MODEL_GET_Y_TRANSLATE(pcHandle));
PUTS("Z:");
PUT(FLD_MODEL_GET_Z_TRANSLATE(pcHandle));
PUTS("Joker Rotation:");
PUTS("X:");
PUT(FLD_MODEL_GET_X_ROTATE(pcHandle));
PUTS("Y:");
PUT(FLD_MODEL_GET_Y_ROTATE(pcHandle));
PUTS("Z:");
PUT(FLD_MODEL_GET_Z_ROTATE(pcHandle));
}
// Turn a flag on or off (depending on user input, if confirm == true)
void ToggleFlag(int flagId, bool confirm)
{
// Prevent disabling Mod Menu
if (flagId != 320 && flagId != 11781)
{
// If no confirmation dialog, silently toggle flag
if (!confirm)
{
if (BIT_CHK(flagId))
BIT_OFF(flagId);
else
BIT_ON(flagId);
}
else
{
// Display flag number and status, ask user whether to turn on or off
SET_MSG_VAR(0, flagId, 0);
if (BIT_CHK(flagId) == 1)
{
if (SystemMenu(Message_ToggleActiveFlag, Options_OnOff) == 1)
BIT_OFF(flagId);
}
else if (BIT_CHK(flagId) == 0)
{
if (SystemMenu(Message_ToggleInactiveFlag, Options_OnOff) == 0)
BIT_ON(flagId);
}
}
}
}
void FlagStatus(int flagId)
{
SET_MSG_VAR(0, flagId, 0);
if (BIT_CHK(flagId) == 1)
SystemMessage(Msg_FlgEnabled);
else
SystemMessage(Msg_FlgDisabled);
}
void ReloadCurrentField()
{
/* Royal Start */
if (FLD_GET_MAJOR() != 21 && FLD_GET_MINOR() != 1)
{
/* Royal End */
CALL_FIELD(FLD_GET_MAJOR(), FLD_GET_MINOR(), 0, 0);
/* Royal Start */
}
else
{
FLD_MY_PALACE_ENTER();
}
/* Royal End */
}
void ReloadPreviousField()
{
if (FLD_GET_MAJOR() != FLD_GET_PREV_MAJOR() || FLD_GET_MINOR() != FLD_GET_PREV_MINOR())
{
CALL_FIELD(FLD_GET_PREV_MAJOR(), FLD_GET_PREV_MINOR(), 0, 0);
}
}
void DetectController()
{
// Detect controller
if (!controller)
{
controller = PAD_CHK_PRESS(PadButton.Any);
}
}
// Apply new rotation/translation to a model until mode is exited
void TransformModel(int reshandle)
{
int joker = FLD_PC_GET_RESHND(0);
// Require a controller
DetectController();
if (!controller)
return;
// Zoom camera out
FLD_SET_CAMERA_FAR_MODE(0);
if (joker != reshandle)
{
// Match Joker's rotation/translation
FLD_MODEL_SET_TRANSLATE(reshandle, FLD_MODEL_GET_X_TRANSLATE(joker), FLD_MODEL_GET_Y_TRANSLATE(joker), FLD_MODEL_GET_Z_TRANSLATE(joker), 0);
FLD_MODEL_SYNC_TRANSLATE(reshandle);
FLD_MODEL_SET_ROTATE(reshandle, FLD_MODEL_GET_X_ROTATE(joker), FLD_MODEL_GET_Y_ROTATE(joker), FLD_MODEL_GET_Z_ROTATE(joker), 0);
FLD_MODEL_SET_VISIBLE(reshandle, 1, 0);
// Hide Joker model
FLD_MODEL_SET_VISIBLE(joker, 0, 0);
}
// Velocity to add per frame
const float ADD_VELOCITY_PER_PRESS = 1.3f;
bool rotateMode = false;
bool precisionMode = false;
float velocity_x = 0f;
float velocity_y = 0f;
float velocity_z = 0f;
float velocity_rot_x = 0f;
float velocity_rot_y = 0f;
float velocity_rot_z = 0f;
int runs = 0;
GetCameraRotation();
float camRot_Y_Rad = 180 - camRot_Y * 3.14159f / 180;
// Wait for all buttons to be released
while (PAD_CHK_PRESS(PadButton.Any)) { SYNC(); }
// Stop executing when Circle button is pressed
while (!PAD_CHK_PRESS(PadButton.Circle))
{
// Bring velocity closer to zero
++runs;
float multiplier = 1f;
if (runs > 5)
{
multiplier = 1f;
runs = 0;
velocity_x /= 6f;
velocity_y /= 6f;
velocity_z /= 6f;
velocity_rot_x /= 6f;
velocity_rot_y /= 6f;
velocity_rot_z /= 6f;
}
// Change mode
if (PAD_CHK_TRIG(PadButton.Select))
{
if (rotateMode)
rotateMode = false;
else
rotateMode = true;
}
if (PAD_CHK_TRIG(PadButton.Start))
{
if (precisionMode)
precisionMode = false;
else
precisionMode = true;
}
// Increase velocity
if (PAD_CHK_PRESS(PadButton.Cross))
multiplier *= 3f;
if (PAD_CHK_PRESS(PadButton.Triangle))
multiplier *= 5f;
// Decrease velocity
if (PAD_CHK_PRESS(PadButton.Square))
multiplier /= 5f;
if (precisionMode)
multiplier /= 3f;
// Move forward/backward
if (PAD_CHK_PRESS(PadButton.R2))
{
velocity_y += ADD_VELOCITY_PER_PRESS * multiplier;
}
if (PAD_CHK_PRESS(PadButton.L2))
{
velocity_y -= ADD_VELOCITY_PER_PRESS * multiplier;
}
// Move forward and backward based on camera rotation
if (PAD_CHK_PRESS(PadButton.Up) || (ANALOG_ASTICK_CHECK(0, AnalogStick.Up, 0)))
{
velocity_x -= ADD_VELOCITY_PER_PRESS * multiplier * SIN(camRot_Y_Rad);
velocity_z += ADD_VELOCITY_PER_PRESS * multiplier * COS(camRot_Y_Rad);
}
if (PAD_CHK_PRESS(PadButton.Down) || ANALOG_ASTICK_CHECK(0, AnalogStick.Down, 0))
{
velocity_x += ADD_VELOCITY_PER_PRESS * multiplier * SIN(camRot_Y_Rad);
velocity_z -= ADD_VELOCITY_PER_PRESS * multiplier * COS(camRot_Y_Rad);
}
if (PAD_CHK_PRESS(PadButton.Left) || ANALOG_ASTICK_CHECK(0, AnalogStick.Left, 0))
{
velocity_x += ADD_VELOCITY_PER_PRESS * multiplier * COS(camRot_Y_Rad);
velocity_z += ADD_VELOCITY_PER_PRESS * multiplier * SIN(camRot_Y_Rad);
}
if (PAD_CHK_PRESS(PadButton.Right) || ANALOG_ASTICK_CHECK(0, AnalogStick.Right, 0))
{
velocity_x -= ADD_VELOCITY_PER_PRESS * multiplier * COS(camRot_Y_Rad);
velocity_z -= ADD_VELOCITY_PER_PRESS * multiplier * SIN(camRot_Y_Rad);
}
// Rotate left/right/up/down using analog stick
if (ANALOG_ASTICK_CHECK(1, AnalogStick.Up, 0))
{
velocity_rot_x += ADD_VELOCITY_PER_PRESS * multiplier;
}
if (ANALOG_ASTICK_CHECK(1, AnalogStick.Down, 0))
{
velocity_rot_x -= ADD_VELOCITY_PER_PRESS * multiplier;
}
if (ANALOG_ASTICK_CHECK(1, AnalogStick.Left, 0))
{
velocity_rot_y += ADD_VELOCITY_PER_PRESS * multiplier;
}
if (ANALOG_ASTICK_CHECK(1, AnalogStick.Right, 0))
{
velocity_rot_y -= ADD_VELOCITY_PER_PRESS * multiplier;
}
// Tilt left/right
if (PAD_CHK_PRESS(PadButton.L1))
{
velocity_rot_z -= ADD_VELOCITY_PER_PRESS * multiplier;
}
if (PAD_CHK_PRESS(PadButton.R1))
{
velocity_rot_z += ADD_VELOCITY_PER_PRESS * multiplier;
}
// Get current position
float x = FLD_MODEL_GET_X_TRANSLATE(reshandle);
float y = FLD_MODEL_GET_Y_TRANSLATE(reshandle);
float z = FLD_MODEL_GET_Z_TRANSLATE(reshandle);
float rot_x = FLD_MODEL_GET_X_ROTATE(reshandle) + velocity_rot_x;
float rot_y = FLD_MODEL_GET_Y_ROTATE(reshandle) + velocity_rot_y;
float rot_z = FLD_MODEL_GET_Z_ROTATE(reshandle) + velocity_rot_z;
// Prevent flipping when rotating
if (rot_x < -359.9f)
rot_x = -359.9f;
else if (rot_x > 359.9f)
rot_x = 359.9f;
if (rot_y < -359.9f)
rot_y = -359.9f;
else if (rot_y > 359.9f)
rot_y = 359.9f;
if (rot_z < -359.9f)
rot_z = -359.9f;
else if (rot_z > 359.9f)
rot_z = 359.9f;
// Set new rotation
FLD_MODEL_SET_ROTATE(reshandle, rot_x, rot_y, rot_z, 0);
// Get new position values
x += velocity_x;
y += velocity_y;
z += velocity_z;
// Set new position values
FLD_PC_GET_RESHND(0);
FLD_MODEL_SET_TRANSLATE(reshandle, x, y, z, 0);
FLD_MODEL_SYNC_TRANSLATE(reshandle);
FLD_MODEL_SYNC_ROTATE(reshandle);
// Also reposition hidden Joker model so camera follows
if (joker != reshandle)
{
FLD_MODEL_SET_TRANSLATE(joker, x, y, z, 0);
FLD_MODEL_SYNC_TRANSLATE(joker);
}
SYNC();
}
// Show Joker model
if (joker != reshandle)
FLD_MODEL_SET_VISIBLE(joker, 1, 0);
PrintModelCoords(reshandle);
}
void PrintModelCoords(int reshandle)
{
PUTS("Model Pos X:");
PUTF(FLD_MODEL_GET_X_WORLD_TRANSLATE(reshandle));
PUTS("Model Pos Y:");
PUTF(FLD_MODEL_GET_Y_WORLD_TRANSLATE(reshandle));
PUTS("Model Pos Z:");
PUTF(FLD_MODEL_GET_Z_WORLD_TRANSLATE(reshandle));
PUTS("Model Rot X:");
PUTF(FLD_MODEL_GET_X_ROTATE(reshandle));
PUTS("Model Rot Y:");
PUTF(FLD_MODEL_GET_Y_ROTATE(reshandle));
PUTS("Model Rot Z:");
PUTF(FLD_MODEL_GET_Z_ROTATE(reshandle));
float qX = 0f;
float qY = 0f;
float qZ = 0f;
float qW = 0f;
EulerToQuatDeg(FLD_MODEL_GET_X_ROTATE(reshandle), FLD_MODEL_GET_Y_ROTATE(reshandle), FLD_MODEL_GET_Z_ROTATE(reshandle), out qX, out qY, out qZ, out qW);
PUTS("Model (Quaternion) Rot X:");
PUTF(qX);
PUTS("Model (Quaternion) Rot Y:");
PUTF(qY);
PUTS("Model (Quaternion) Rot Z:");
PUTF(qZ);
PUTS("Model (Quaternion) Rot W:");
PUTF(qW);
}
void AttachModel(int modelreshandle, int attachmenthandle)
{
int boneID = 0;
bool boneChanged = false;
while (!PAD_CHK_PRESS(PadButton.Circle))
{
if (PAD_CHK_PRESS(PadButton.Any))
{
if (PAD_CHK_TRIG(PadButton.Left) || PAD_CHK_PRESS(PadButton.L2))
{
if (boneID >= 1)
boneID--;
boneChanged = true;
}
if (PAD_CHK_TRIG(PadButton.Right) || PAD_CHK_PRESS(PadButton.R2))
{
boneID++;
boneChanged = true;
}
if (boneChanged)
{
FLD_MODEL_ATTACH_TRANSLATE(attachmenthandle, modelreshandle, boneID);
FLD_MODEL_ATTACH_ROTATE(attachmenthandle, modelreshandle, boneID);
PUTS("Bone ID:");
PUT(boneID);
boneChanged = false;
}
}
SYNC();
}
}
enum AnalogStick
{
Up,
Right,
Down,
Left
}
// Apply new rotation/translation to camera until mode is exited
void TransformCamera()
{
int joker = FLD_PC_GET_RESHND(0);
// Require a controller
DetectController();
if (!controller)
return;
// Get current camera rotation
GetCameraRotation();
GetCameraPosition();
CameraLock();
// Zoom camera out
FLD_SET_CAMERA_FAR_MODE(0);
// Velocity to add per frame
const float ADD_VELOCITY_PER_PRESS = 4f;
bool precisionMode = false;
float velocity_x = 0f;
float velocity_y = 0f;
float velocity_z = 0f;
float velocity_rot_x = 0f;
float velocity_rot_y = 0f;
float velocity_rot_z = 0f;
int runs = 0;
// Wait for all buttons to be released
while (PAD_CHK_PRESS(PadButton.Any)) { SYNC(); }
// Stop executing when Circle button is pressed
while (!PAD_CHK_PRESS(PadButton.Circle))
{
// Bring velocity closer to zero
++runs;
float multiplier = 1f;
if (runs > 5)
{
multiplier = 1f;
runs = 0;
velocity_x /= 6f;
velocity_y /= 6f;
velocity_z /= 6f;
velocity_rot_x /= 6f;
velocity_rot_y /= 6f;
velocity_rot_z /= 6f;
}
if (PAD_CHK_TRIG(PadButton.Start))
{
if (precisionMode)
precisionMode = false;
else
precisionMode = true;
}
// Increase velocity
if (PAD_CHK_PRESS(PadButton.Cross))
multiplier *= 3f;
if (PAD_CHK_PRESS(PadButton.Triangle))
multiplier *= 5f;
// Decrease velocity
if (PAD_CHK_PRESS(PadButton.Square))
multiplier /= 5f;
if (precisionMode)
multiplier /= 3f;
// Move up/down
if (PAD_CHK_PRESS(PadButton.R2))
{
velocity_y += ADD_VELOCITY_PER_PRESS * multiplier;
}
if (PAD_CHK_PRESS(PadButton.L2))
{
velocity_y -= ADD_VELOCITY_PER_PRESS * multiplier;
}
float camRot_Y_Rad = 180 - camRot_Y * 3.14159f / 180;
// Move forward and backward based on current camera rotation
if (PAD_CHK_PRESS(PadButton.Up) || (ANALOG_ASTICK_CHECK(0, AnalogStick.Up, 0)))
{
velocity_x -= ADD_VELOCITY_PER_PRESS * multiplier * SIN(camRot_Y_Rad);
velocity_z += ADD_VELOCITY_PER_PRESS * multiplier * COS(camRot_Y_Rad);
}
if (PAD_CHK_PRESS(PadButton.Down) || ANALOG_ASTICK_CHECK(0, AnalogStick.Down, 0))
{
velocity_x += ADD_VELOCITY_PER_PRESS * multiplier * SIN(camRot_Y_Rad);
velocity_z -= ADD_VELOCITY_PER_PRESS * multiplier * COS(camRot_Y_Rad);
}
if (PAD_CHK_PRESS(PadButton.Left) || ANALOG_ASTICK_CHECK(0, AnalogStick.Left, 0))
{
velocity_x += ADD_VELOCITY_PER_PRESS * multiplier * COS(camRot_Y_Rad);
velocity_z += ADD_VELOCITY_PER_PRESS * multiplier * SIN(camRot_Y_Rad);
}
if (PAD_CHK_PRESS(PadButton.Right) || ANALOG_ASTICK_CHECK(0, AnalogStick.Right, 0))
{
velocity_x -= ADD_VELOCITY_PER_PRESS * multiplier * COS(camRot_Y_Rad);
velocity_z -= ADD_VELOCITY_PER_PRESS * multiplier * SIN(camRot_Y_Rad);
}
// Rotate left/right/up/down using analog stick
if (ANALOG_ASTICK_CHECK(1, AnalogStick.Up, 0))
{
velocity_rot_x += ADD_VELOCITY_PER_PRESS * multiplier * 2;
}
if (ANALOG_ASTICK_CHECK(1, AnalogStick.Down, 0))
{
velocity_rot_x -= ADD_VELOCITY_PER_PRESS * multiplier * 2;
}
if (ANALOG_ASTICK_CHECK(1, AnalogStick.Left, 0))
{
velocity_rot_y += ADD_VELOCITY_PER_PRESS * multiplier * 2;
}
if (ANALOG_ASTICK_CHECK(1, AnalogStick.Right, 0))
{
velocity_rot_y -= ADD_VELOCITY_PER_PRESS * multiplier * 2;
}
// Tilt left/right
if (PAD_CHK_PRESS(PadButton.L1))
{
velocity_rot_z += ADD_VELOCITY_PER_PRESS * multiplier * 2;
}
if (PAD_CHK_PRESS(PadButton.R1))
{
velocity_rot_z -= ADD_VELOCITY_PER_PRESS * multiplier * 2;
}
// Get new position values
camPos_X += velocity_x;
camPos_Y += velocity_y;
camPos_Z += velocity_z;
camRot_X += velocity_rot_x;
camRot_Y += velocity_rot_y;
camRot_Z += velocity_rot_z;
float x;
float y;
float z;
float w;
EulerToQuatDeg(camRot_X, camRot_Y, camRot_Z, out x, out y, out z, out w);
// Set new position values
FLD_CAMERA_LOCK_INTERP(camPos_X, camPos_Y, camPos_Z, x, y, z, w, 0);
SYNC();
}
PrintCameraCoords();
}
void GetCameraRotation()
{
float x;
float y;
float z;
QuaternionToEuler(FLD_CAMERA_GET_X_ROT(), FLD_CAMERA_GET_Y_ROT(), FLD_CAMERA_GET_Z_ROT(), FLD_CAMERA_GET_W_ROT(), out x, out y, out z);
camRot_X = x;
camRot_Y = y;
camRot_Z = z;
}
void GetCameraPosition()
{
camPos_X = FLD_CAMERA_GET_X_POS();
camPos_Y = FLD_CAMERA_GET_Y_POS();
camPos_Z = FLD_CAMERA_GET_Z_POS();
}
void CameraUnlock()
{
while (FLD_CAMERA_CHECK_LOCK() != 0)
FLD_CAMERA_UNLOCK();
FLD_CAMERA_BEHIND_UNLOCK();
}
void CameraLock()
{
FLD_CAMERA_LOCK();
FLD_CAMERA_BEHIND_LOCK();
}
void PrintCameraCoords()
{
PUTS("Camera Pos X:");
PUTF(FLD_CAMERA_GET_X_POS());
PUTS("Camera Pos Y:");
PUTF(FLD_CAMERA_GET_Y_POS());
PUTS("Camera Pos Z:");
PUTF(FLD_CAMERA_GET_Z_POS());
float qX = 0f;
float qY = 0f;
float qZ = 0f;
float qW = 0f;
EulerToQuatDeg(camRot_X, camRot_Y, camRot_Z, out qX, out qY, out qZ, out qW);
PUTS("Camera Rot X:");
PUTF(qX);
PUTS("Camera Rot Y:");
PUTF(qY);
PUTS("Camera Rot Z:");
PUTF(qZ);
PUTS("Camera Rot W:");
PUTF(qW);
}