forked from Changa-Husky/VrChatDollyController
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDollyControl.py
More file actions
1944 lines (1764 loc) · 77.9 KB
/
DollyControl.py
File metadata and controls
1944 lines (1764 loc) · 77.9 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
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# DollyControlPyQt.py
# -*- coding: utf-8 -*-
import sys
import json
import math
import time
import threading
import os
import shutil
import copy
import numpy as np
from pythonosc.udp_client import SimpleUDPClient
from pythonosc.dispatcher import Dispatcher
from pythonosc import osc_server
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from scipy.spatial.transform import Rotation as R
import ctypes
from ctypes import wintypes
from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QLabel, QPushButton, QLineEdit, QSlider, QCheckBox, QFileDialog,
QScrollArea, QButtonGroup, QMessageBox)
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QFont, QGuiApplication
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QProgressBar
from PyQt6.QtCore import QTimer, QUrl
from PyQt6.QtMultimedia import QMediaPlayer, QAudioOutput
from PyQt6.QtGui import QIcon, QPixmap
import base64
# ----------------------------------------------------
# DollyControl V2.10 Changa Husky
#
# There are bugs I'm sure this was made for my own
# Filmmaking use but if others find it useful cool.
# ----------------------------------------------------
# --------------------------
# Helper: Compute Unity LookRotation as Euler Angles
# --------------------------
def compute_look_at_unity(camera_pos, target_pos, vertical_mode=False):
forward = target_pos - camera_pos
norm_fwd = np.linalg.norm(forward)
if norm_fwd < 1e-6:
return [0, 0, 0]
forward /= norm_fwd
world_up = np.array([0, 1, 0])
if abs(np.dot(forward, world_up)) > 0.99:
fallback_up = np.array([0, 0, 1])
if abs(np.dot(forward, fallback_up)) > 0.99:
fallback_up = np.array([1, 0, 0])
up_vec = fallback_up
else:
up_vec = world_up
right = np.cross(up_vec, forward)
norm_r = np.linalg.norm(right)
if norm_r < 1e-6:
norm_r = 1
right /= norm_r
up_corrected = np.cross(forward, right)
rot_matrix = np.column_stack((right, up_corrected, forward))
rot = R.from_matrix(rot_matrix)
euler = rot.as_euler('YXZ', degrees=True)
if vertical_mode:
vertical_adjust = R.from_euler('Z', 90, degrees=True)
final_rot = rot * vertical_adjust
euler = final_rot.as_euler('YXZ', degrees=True)
return euler.tolist()
# --------------------------
# Determine Export Path from Documents
# --------------------------
def get_documents_folder():
CSIDL_PERSONAL = 5
SHGFP_TYPE_CURRENT = 0
buf = ctypes.create_unicode_buffer(wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf)
return buf.value
documents_folder = get_documents_folder()
EXPORT_PATH = os.path.join(documents_folder, "VRChat", "CameraPaths") + os.sep
USED_LOCATIONS_PATH = os.path.join(EXPORT_PATH, "Used_Locations")
os.makedirs(USED_LOCATIONS_PATH, exist_ok=True)
PINS_PATH = os.path.join(EXPORT_PATH, "Bookmarks")
os.makedirs(PINS_PATH, exist_ok=True)
# --------------------------
# OSC Settings
# --------------------------
OSC_IP = "127.0.0.1"
OSC_PORT = 9000
OSC_PORT_RECEIVE = 9001
client = SimpleUDPClient(OSC_IP, OSC_PORT)
# --------------------------
# Dolly Settings & Globals
# --------------------------
MAX_RADIUS = 10.0
MAX_HEIGHT = 5.0
dolly_settings = {
"radius": 2.0,
"height": 0.0,
"points": 12,
"duration": 2.0
}
dolly_zoom = 45.0
dolly_speed = 3.0
aperture = 15.0
focal_distance = 2
dolly_zoom_exaggeration = 2.0 # Range: 1.0 to 5.0
user_points_limit = 15 # Range: 5 to 50
dolly_mode = 1 # 1 = Circle, 2 = Line, 3 = Elliptical, 4 = File Mode, 5 = Dolly Zoom Mode
start_position = {"X": 0.0, "Y": 0.0, "Z": 0.0}
exported_center = None
current_path_data = None
dolly_vertical = False
dolly_pause = False
PAUSE_DURATION = 60.0
lookat_x_offset = 0.0
lookat_y_offset = 0.0
view_target = None
use_view_target = True
arc_angle = 180.0
# These will be set by the UI:
use_view_target_checkbox = None
camera_offset = {"X": 0.0, "Y": 0.0, "Z": 0.0}
camera_rotation_offset = R.from_euler('XYZ', [0, 0, 0], degrees=True)
initial_dolly_distance = None
initial_dolly_zoom = None
reverse_dolly_zoom = False
loaded_path_data_original = []
loaded_file_label = None
dolly_zoom_btn = None
# Global UI widget references (set by the PyQt UI)
radius_slider = None
radius_entry = None
duration_slider = None
duration_entry = None
zoom_slider = None
zoom_entry = None
speed_slider = None
speed_entry = None
height_slider = None
height_entry = None
aperture_slider = None
aperture_entry = None
focal_distance_slider = None
focal_distance_entry = None
dz_exag_slider = None
dz_exag_entry = None
points_count_slider = None
points_count_entry = None
lookat_x_slider = None
lookat_x_entry = None
lookat_y_slider = None
lookat_y_entry = None
translation_step_slider = None
translation_step_entry = None
rotation_step_slider = None
rotation_step_entry = None
vertical_toggle = None
pause_toggle = None
reverse_zoom_checkbox = None
translation_step_value = 0.5
rotation_step_value = 1.0
# Global flag to disable export processing during target move.
target_move_mode = False
def update_arc_angle_slider(value):
"""
Update the global arc_angle when the slider value changes.
"""
global arc_angle, arc_angle_entry
arc_angle = round(float(value), 2)
arc_angle_entry.setText(str(arc_angle))
regenerate_path()
def on_arc_angle_entry_return():
"""
Update the global arc_angle when the text entry is modified.
"""
global arc_angle, arc_angle_entry
try:
val = float(arc_angle_entry.text())
# Clamp between 5 and 180.
val = max(5, min(180, val))
arc_angle = val
regenerate_path()
except ValueError:
pass
def get_desktop_folder():
CSIDL_DESKTOP = 0 # Desktop folder constant
SHGFP_TYPE_CURRENT = 0
buf = ctypes.create_unicode_buffer(wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_DESKTOP, None, SHGFP_TYPE_CURRENT, buf)
return buf.value
DESKTOP_PATH = get_desktop_folder()
PERFORM_MP3_PATH = os.path.join(DESKTOP_PATH, "perform.mp3")
print("Using MP3 file at:", PERFORM_MP3_PATH)
is_local = False # Global flag to set the islocal property on waypoints.
reverse_path = False # Global flag to reverse the generated path.
initial_import = True
ICON_BASE64 = b"""
AAABAAEAICAAAAEAIACo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4/F/8+Pxf/Pj8X/z4/F/89
PhX/UVIv/1laOP8+Pxf/Pj8X/z4/F/8+Pxf/Pj8X/z4/F/8+Pxf/Pj8X/z4/F/8+Pxf/Pj8X/z4/
F/8/Pxf/Pz8X/z0+Fv9ISCP/tbWp/tTU1Ziop6gs2NjXzaysnv9paUv/W1s6/1tbOv9aWzr/Wls6
/1pbOv9aWzr/Wls6/1pbOv9ZWjj/WFk4/1pbOv9aWzr/Wls6/1pbOv9aWzr/Wls6/1pbOv9aWzr/
Wls6/1pbOv9aWzr/Wls6/1tbO/9bWzv/aWlM/62tn//Y2NjMqqqrKf///wCsrKw30dHRw9jY1v7Y
2NP+2NjU/tjY1P7Y2NT+2NjU/tjY1P7Y2NT+2NjU/tjY1P7Y2NT+2NjU/tjY1P7Y2NT+2NjU/tjY
1P7Y2NT+2NjU/tjY1P7Y2NT+2NjU/tjY1P7Y2NT+2NjT/tjY0/7Z2df719fXuLCvsDP///8AgAAA
AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAIAAAAE=
"""
# --------------------------
# Callback Functions for Parameters
# --------------------------
def set_reverse_path(checked):
global reverse_path
reverse_path = checked
print("Reverse path set to:", reverse_path)
regenerate_path()
def update_points_count_slider(value):
global user_points_limit, points_count_entry
val = int(round(value))
user_points_limit = val
points_count_entry.setText(str(val))
regenerate_path()
def on_points_count_entry_return():
global user_points_limit, points_count_entry
try:
val = int(points_count_entry.text())
val = max(5, min(50, val))
user_points_limit = val
regenerate_path()
except ValueError:
pass
def set_is_local(checked):
global is_local
is_local = checked
print("Is local set to:", is_local)
regenerate_path()
def update_dz_exaggeration_slider(value):
global dolly_zoom_exaggeration, dz_exag_entry
val = round(float(value) / 100, 2)
dolly_zoom_exaggeration = val
dz_exag_entry.setText(str(val))
if dolly_mode == 5:
regenerate_path()
def on_dz_exaggeration_entry_return():
global dolly_zoom_exaggeration, dz_exag_entry
try:
val = float(dz_exag_entry.text())
val = max(1.0, min(5.0, val))
dolly_zoom_exaggeration = val
if dolly_mode == 5:
regenerate_path()
except ValueError:
pass
def update_aperture_slider(value):
global aperture, aperture_entry
val = round(float(value) / 100, 2)
aperture = val
aperture_entry.setText(str(val))
regenerate_path()
def on_aperture_entry_return():
global aperture, aperture_entry
try:
val = float(aperture_entry.text())
val = max(1.4, min(32, val))
aperture = val
regenerate_path()
except ValueError:
pass
def update_focal_distance_slider(value):
global focal_distance, focal_distance_entry
val = round(float(value) / 100, 2)
focal_distance = val
focal_distance_entry.setText(str(val))
regenerate_path()
def on_focal_distance_entry_return():
global focal_distance, focal_distance_entry
try:
val = float(focal_distance_entry.text())
val = max(0.1, min(30, val))
focal_distance = val
regenerate_path()
except ValueError:
pass
def update_radius_slider(value):
global dolly_settings, radius_entry
val = round(float(value) / 100, 2)
dolly_settings["radius"] = val
radius_entry.setText(str(val))
regenerate_path()
def update_zoom_slider(value):
global dolly_zoom, zoom_entry
val = round(float(value), 2)
dolly_zoom = val
zoom_entry.setText(str(val))
if dolly_mode != 5:
send_dolly_path()
def update_speed_slider(value):
global dolly_speed, speed_entry
val = round(float(value) / 100, 2)
dolly_speed = val
speed_entry.setText(str(val))
send_dolly_path()
def update_height_slider(value):
global dolly_settings, height_entry
val = round(float(value) / 100, 2)
dolly_settings["height"] = val
height_entry.setText(str(val))
regenerate_path()
def on_translation_step_entry_return():
global translation_step_value
try:
val = float(translation_step_entry.text())
val = max(0.01, min(5.0, val))
translation_step_slider.setValue(int(val * 100))
translation_step_value = val
except ValueError:
pass
def update_translation_step_slider(value):
global translation_step_value, translation_step_entry
val = round(float(value) / 100, 2)
translation_step_value = val
translation_step_entry.setText(str(val))
def on_rotation_step_entry_return():
global rotation_step_value
try:
val = float(rotation_step_entry.text())
val = max(0.01, min(90.0, val))
rotation_step_slider.setValue(int(val * 100))
rotation_step_value = val
except ValueError:
pass
def update_rotation_step_slider(value):
global rotation_step_value, rotation_step_entry
val = round(float(value) / 100, 2)
rotation_step_value = val
rotation_step_entry.setText(str(val))
def update_lookat_x_slider(value):
global lookat_x_offset, lookat_x_entry
val = round(float(value) / 100, 2)
lookat_x_offset = val
lookat_x_entry.setText(str(val))
send_dolly_path()
def update_lookat_y_slider(value):
global lookat_y_offset, lookat_y_entry
val = round(float(value) / 100, 2)
lookat_y_offset = val
lookat_y_entry.setText(str(val))
send_dolly_path()
def update_duration_slider(value):
global dolly_settings, duration_entry
val = round(float(value) / 100, 2)
dolly_settings["duration"] = val
duration_entry.setText(str(val))
regenerate_path()
def on_radius_entry_return():
try:
val = float(radius_entry.text())
val = max(0.1, min(10.0, val))
update_radius_slider(val * 100)
except ValueError:
pass
def on_duration_entry_return():
try:
val = float(duration_entry.text())
val = max(0.1, min(30.0, val))
update_duration_slider(val * 100)
except ValueError:
pass
def update_radius_slider(value):
global dolly_settings, radius_entry
val = round(float(value) / 100, 2)
dolly_settings["radius"] = val
radius_entry.setText(str(val))
regenerate_path()
def on_zoom_entry_return():
global dolly_zoom
try:
val = float(zoom_entry.text())
val = max(20.0, min(300.0, val))
zoom_slider.setValue(int(val))
dolly_zoom = val
if dolly_mode != 5:
send_dolly_path()
except ValueError:
pass
def on_speed_entry_return():
global dolly_speed
try:
val = float(speed_entry.text())
val = max(0.1, min(10.0, val))
speed_slider.setValue(int(val * 100))
dolly_speed = val
send_dolly_path()
except ValueError:
pass
def on_height_entry_return():
try:
val = float(height_entry.text())
val = max(0.0, min(5.0, val))
height_slider.setValue(int(val * 100))
dolly_settings["height"] = val
regenerate_path()
except ValueError:
pass
def on_lookat_x_entry_return():
global lookat_x_offset
try:
val = float(lookat_x_entry.text())
val = max(-20.0, min(20.0, val))
lookat_x_slider.setValue(int(val * 100))
lookat_x_offset = val
send_dolly_path()
except ValueError:
pass
def on_lookat_y_entry_return():
global lookat_y_offset
try:
val = float(lookat_y_entry.text())
val = max(-20.0, min(20.0, val))
lookat_y_slider.setValue(int(val * 100))
lookat_y_offset = val
send_dolly_path()
except ValueError:
pass
# --------------------------
# File Monitoring to Extract Exported Data
# --------------------------
class ExportFileHandler(FileSystemEventHandler):
def on_created(self, event):
if event.src_path.endswith(".json"):
print(f"New exported path detected: {event.src_path}")
time.sleep(1)
extract_start_position(event.src_path)
def extract_start_position(file_path):
global start_position, exported_center, view_target, use_view_target, initial_dolly_distance, initial_dolly_zoom, dolly_zoom_btn, use_view_target_checkbox, target_move_mode
if target_move_mode:
print("Target move mode active; ignoring export file.")
return
if not os.path.exists(file_path):
print("Exported file not found. Using default start position (0,0,0).")
return
try:
with open(file_path, "r", encoding="utf-8") as file:
data = json.load(file)
if data and len(data) > 0 and "Position" in data[0]:
start_position = data[0]["Position"]
exported_center = copy.deepcopy(start_position)
print(f"Using exported center: {exported_center}")
if len(data) >= 2 and "Position" in data[1]:
view_target = data[1]["Position"]
use_view_target = True
if use_view_target_checkbox is not None:
use_view_target_checkbox.setChecked(True)
center_vec = np.array([exported_center["X"], exported_center["Y"], exported_center["Z"]])
target_vec = np.array([view_target["X"], view_target["Y"], view_target["Z"]])
initial_dolly_distance = np.linalg.norm(target_vec - center_vec)
initial_dolly_zoom = dolly_zoom
print(f"Initial dolly distance: {initial_dolly_distance}, initial zoom: {initial_dolly_zoom}")
print(f"View target set to: {view_target}")
else:
view_target = None
use_view_target = False
if use_view_target_checkbox is not None:
use_view_target_checkbox.setChecked(False)
print("No view target available.")
else:
print("Exported file has no valid waypoints. Using default start (0,0,0).")
new_path = os.path.join(USED_LOCATIONS_PATH, os.path.basename(file_path))
shutil.move(file_path, new_path)
print(f"Moved used export file to: {new_path}")
except Exception as e:
print(f"Error reading exported file: {e}")
if dolly_zoom_btn is not None:
if view_target is not None:
dolly_zoom_btn.setEnabled(True)
else:
dolly_zoom_btn.setEnabled(False)
def export_pin(pin_number):
"""Export current start position, view target (if set), camera offset, rotation offset, and various settings as a pin."""
pin_file = os.path.join(PINS_PATH, f"pin{pin_number}.json")
settings = {
"radius": dolly_settings["radius"],
"duration": dolly_settings["duration"],
"zoom": dolly_zoom,
"speed": dolly_speed,
"height": dolly_settings["height"],
"aperture": aperture,
"focal_distance": focal_distance,
"arc_angle": arc_angle,
"num_points": user_points_limit,
"translation_step": translation_step_value,
"rotation_step": rotation_step_value
}
# Convert the current rotation offset to Euler angles (XYZ, degrees)
rotation_offset_euler = camera_rotation_offset.as_euler('XYZ', degrees=True).tolist()
data = {
"origin": start_position,
"target": view_target, # May be None if no target is set.
"camera_offset": camera_offset, # Save the current translation offset.
"rotation_offset": rotation_offset_euler, # Save the rotation offset as Euler angles.
"settings": settings
}
try:
with open(pin_file, "w", encoding="utf-8") as f:
json.dump(data, f)
QMessageBox.information(None, "Pin Export", f"Pin {pin_number} updated with current origin, target, offsets, and settings.")
except Exception as e:
QMessageBox.critical(None, "Pin Export Error", f"Error exporting Pin {pin_number}: {e}")
def load_pin(pin_number):
"""
Load the stored pin and update start position, target, camera offset, rotation offset, and various settings.
Then regenerate the path so that these values take effect.
"""
global start_position, exported_center, view_target, use_view_target
global dolly_settings, dolly_zoom, dolly_speed, aperture, focal_distance, arc_angle, user_points_limit
global translation_step_value, rotation_step_value, camera_offset, camera_rotation_offset
pin_file = os.path.join(PINS_PATH, f"pin{pin_number}.json")
if not os.path.exists(pin_file):
QMessageBox.warning(None, "Pin Empty", f"Pin {pin_number} is empty.")
return
try:
with open(pin_file, "r", encoding="utf-8") as f:
data = json.load(f)
if "origin" in data:
start_position.clear()
start_position.update(data["origin"])
exported_center = copy.deepcopy(start_position)
if "target" in data:
view_target = data["target"]
use_view_target = (view_target is not None)
if "camera_offset" in data:
camera_offset.clear()
camera_offset.update(data["camera_offset"])
if "rotation_offset" in data:
# Recreate the camera_rotation_offset from saved Euler angles.
euler_angles = data["rotation_offset"]
camera_rotation_offset = R.from_euler('XYZ', euler_angles, degrees=True)
if "settings" in data:
settings = data["settings"]
dolly_settings["radius"] = settings.get("radius", dolly_settings["radius"])
dolly_settings["duration"] = settings.get("duration", dolly_settings["duration"])
dolly_zoom = settings.get("zoom", dolly_zoom)
dolly_speed = settings.get("speed", dolly_speed)
dolly_settings["height"] = settings.get("height", dolly_settings["height"])
aperture = settings.get("aperture", aperture)
focal_distance = settings.get("focal_distance", focal_distance)
arc_angle = settings.get("arc_angle", arc_angle)
user_points_limit = settings.get("num_points", user_points_limit)
translation_step_value = settings.get("translation_step", translation_step_value)
rotation_step_value = settings.get("rotation_step", rotation_step_value)
print(f"Loaded Pin {pin_number}:\n Origin: {start_position}\n Target: {view_target}\n Camera Offset: {camera_offset}\n Rotation Offset (Euler): {data.get('rotation_offset')}\n Settings: {data.get('settings', {})}")
regenerate_path()
except Exception as e:
QMessageBox.critical(None, "Pin Load Error", f"Error loading Pin {pin_number}: {e}")
def start_file_monitoring():
observer = Observer()
event_handler = ExportFileHandler()
observer.schedule(event_handler, path=EXPORT_PATH, recursive=False)
observer.start()
print(f"Monitoring {EXPORT_PATH} for new exported paths...")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
def start_file_monitoring_thread():
threading.Thread(target=start_file_monitoring, daemon=True).start()
# --------------------------
# Dolly Path Generation Functions
# --------------------------
def generate_circle_path():
center = exported_center if exported_center is not None else start_position
dolly_settings["points"] = user_points_limit
waypoints = []
for i in range(user_points_limit):
angle = (i / user_points_limit) * 2 * math.pi
x = round(center["X"] + dolly_settings["radius"] * math.cos(angle), 3)
z = round(center["Z"] + dolly_settings["radius"] * math.sin(angle), 3)
y = round(center["Y"] + dolly_settings["height"], 3)
yaw = round(math.degrees(math.atan2(center["Z"] - z, center["X"] - x)), 2)
wp = {
"Index": i,
"PathIndex": 0,
"FocalDistance": focal_distance,
"Aperture": aperture,
"Hue": 120.0,
"Saturation": 100.0,
"Lightness": 50.0,
"LookAtMeXOffset": 0.0,
"LookAtMeYOffset": 0.0,
"Zoom": dolly_zoom,
"Speed": dolly_speed,
"Duration": round((i / user_points_limit) * dolly_settings["duration"], 3),
"Position": {"X": x, "Y": y, "Z": z},
"Rotation": {"X": 0, "Y": yaw, "Z": 0},
"islocal": is_local
}
waypoints.append(wp)
return waypoints
def generate_arc_path():
center = exported_center if exported_center else start_position
# Suppose center was the old "circle center" used for 180° arcs.
# R is your original radius
R = dolly_settings["radius"]
# L is the half-circle length
L = R * math.pi
# Convert the user arc angle from degrees to radians
arc_rad = math.radians(arc_angle)
# If the user wants the same arc length as the half circle, compute a bigger radius
effective_radius = L / arc_rad
# Old midpoint for the 180° arc was at angle=0 in [-π/2..+π/2],
# which is center.x + R on the X axis
oldMidX = center["X"] + R
oldMidZ = center["Z"]
# The new arc’s unshifted midpoint is at (effective_radius, 0)
# so we figure out how much we must shift to make that coincide with (oldMidX, oldMidZ)
shiftX = oldMidX - effective_radius
shiftZ = oldMidZ - 0
# We'll sweep from -arc_rad/2 to +arc_rad/2
offset = -arc_rad / 2
waypoints = []
for i in range(user_points_limit):
t = i/(user_points_limit - 1) if user_points_limit>1 else 0
angle = offset + t * arc_rad
# Unshifted arc coords
rawX = effective_radius * math.cos(angle)
rawZ = effective_radius * math.sin(angle)
# Shift so midpoint is pinned
x = rawX + shiftX
z = rawZ + shiftZ
y = center["Y"] + dolly_settings["height"]
yaw = math.degrees(math.atan2(center["Z"] - z, center["X"] - x))
wp = {
"Index": i,
"Position": {"X": round(x,3), "Y": round(y,3), "Z": round(z,3)},
"Rotation": {"X": 0, "Y": round(yaw,2), "Z": 0},
# plus your other fields...
}
waypoints.append(wp)
return waypoints
def generate_line_path():
dolly_settings["points"] = user_points_limit
waypoints = []
startX = start_position["X"] - dolly_settings["radius"]
endX = start_position["X"] + dolly_settings["radius"]
for i in range(user_points_limit):
t = i / (user_points_limit - 1) if user_points_limit > 1 else 0
x = round(startX + t * (endX - startX), 3)
y = round(start_position["Y"] + dolly_settings["height"], 3)
z = start_position["Z"]
wp = {
"Index": i,
"PathIndex": 0,
"FocalDistance": focal_distance,
"Aperture": aperture,
"Hue": 120.0,
"Saturation": 100.0,
"Lightness": 50.0,
"LookAtMeXOffset": 0.0,
"LookAtMeYOffset": 0.0,
"Zoom": dolly_zoom,
"Speed": dolly_speed,
"Duration": round(t * dolly_settings["duration"], 3),
"Position": {"X": x, "Y": y, "Z": z},
"Rotation": {"X": 0, "Y": 0, "Z": 0},
"islocal": is_local
}
waypoints.append(wp)
return waypoints
def generate_elliptical_path():
dolly_settings["points"] = user_points_limit
waypoints = []
elliptical_ratio = 0.75
for i in range(user_points_limit):
angle = (i / user_points_limit) * 2 * math.pi
x = round(start_position["X"] + dolly_settings["radius"] * math.cos(angle), 3)
z = round(start_position["Z"] + (dolly_settings["radius"] * elliptical_ratio) * math.sin(angle), 3)
y = round(start_position["Y"] + dolly_settings["height"], 3)
wp = {
"Index": i,
"PathIndex": 0,
"FocalDistance": focal_distance,
"Aperture": aperture,
"Hue": 120.0,
"Saturation": 100.0,
"Lightness": 50.0,
"LookAtMeXOffset": 0.0,
"LookAtMeYOffset": 0.0,
"Zoom": dolly_zoom,
"Speed": dolly_speed,
"Duration": round((i / user_points_limit) * dolly_settings["duration"], 3),
"Position": {"X": x, "Y": y, "Z": z},
"Rotation": {"X": 0, "Y": 0, "Z": 0}
}
waypoints.append(wp)
return waypoints
def generate_loaded_path():
if not loaded_path_data_original:
print("No custom path loaded. Returning empty path.")
return []
# For file/slot modes, ignore the radius scaling and use a fixed scale factor.
scale_factor = 1
xs = [pt["Position"]["X"] for pt in loaded_path_data_original]
ys = [pt["Position"]["Y"] for pt in loaded_path_data_original]
zs = [pt["Position"]["Z"] for pt in loaded_path_data_original]
cx, cy, cz = sum(xs)/len(xs), sum(ys)/len(ys), sum(zs)/len(zs)
new_waypoints = []
for original in loaded_path_data_original:
wp = copy.deepcopy(original)
rx = wp["Position"]["X"] - cx
ry = wp["Position"]["Y"] - cy
rz = wp["Position"]["Z"] - cz
new_x = cx + rx * scale_factor
new_y = cy + ry * scale_factor + dolly_settings["height"]
new_z = cz + rz * scale_factor
wp["Position"] = {"X": round(new_x, 3), "Y": round(new_y, 3), "Z": round(new_z, 3)}
wp["Zoom"] = dolly_zoom
wp["Speed"] = dolly_speed
wp["Aperture"] = aperture
wp["FocalDistance"] = focal_distance
new_waypoints.append(wp)
return new_waypoints
def generate_dolly_zoom_path():
if view_target is None:
print("No target available for Dolly Zoom mode; returning empty path.")
return []
start_vec = np.array([start_position["X"], start_position["Y"], start_position["Z"]])
target_vec = np.array([view_target["X"], view_target["Y"], view_target["Z"]])
initial_distance = np.linalg.norm(target_vec - start_vec)
num_points = 5
max_t = 0.95
if reverse_dolly_zoom:
t_values = [max_t - (max_t * i/(num_points-1)) for i in range(num_points)]
else:
t_values = [(max_t * i/(num_points-1)) for i in range(num_points)]
waypoints = []
for i, t in enumerate(t_values):
pos = start_vec * (1 - t) + target_vec * t
duration = round(t * dolly_settings["duration"], 3)
current_distance = np.linalg.norm(target_vec - pos)
new_zoom = initial_dolly_zoom * (current_distance / initial_distance) * dolly_zoom_exaggeration if initial_distance > 0 else initial_dolly_zoom
new_zoom = min(max(new_zoom, 20), 300)
euler = compute_look_at_unity(pos, target_vec, vertical_mode=False)
wp = {
"Index": i,
"PathIndex": 0,
"FocalDistance": focal_distance,
"Aperture": aperture,
"Hue": 120.0,
"Saturation": 100.0,
"Lightness": 50.0,
"LookAtMeXOffset": 0.0,
"LookAtMeYOffset": 0.0,
"Zoom": round(new_zoom, 2),
"Speed": dolly_speed,
"Duration": duration,
"Position": {"X": round(pos[0], 3), "Y": round(pos[1], 3), "Z": round(pos[2], 3)},
"Rotation": {"X": round(euler[1], 2), "Y": round(euler[0], 2), "Z": round(euler[2], 2)}
}
waypoints.append(wp)
return waypoints
def regenerate_path():
global current_path_data
if dolly_mode == 1:
current_path_data = generate_circle_path()
elif dolly_mode == 2:
current_path_data = generate_arc_path() # New Arc mode!
elif dolly_mode == 3:
current_path_data = generate_line_path()
elif dolly_mode == 4:
current_path_data = generate_elliptical_path()
elif dolly_mode == 5:
current_path_data = generate_loaded_path()
elif dolly_mode == 6:
current_path_data = generate_dolly_zoom_path()
else:
current_path_data = []
# If file mode with a view target, apply camera_offset only to certain points
if dolly_mode == 4 and view_target is not None:
for i, pt in enumerate(current_path_data):
if i == 1: # skip the "target" itself
continue
for axis in ['X', 'Y', 'Z']:
pt["Position"][axis] = round(pt["Position"][axis] + camera_offset[axis], 3)
# Other modes
elif dolly_mode not in [5]:
for pt in current_path_data:
for axis in ['X', 'Y', 'Z']:
pt["Position"][axis] = round(pt["Position"][axis] + camera_offset[axis], 3)
# Apply rotation offset for non-Dolly-Zoom modes
if dolly_mode not in [5]:
if dolly_mode == 4 and view_target is not None:
camera_points = []
for i, pt in enumerate(current_path_data):
if i == 1:
continue
camera_points.append(np.array([pt["Position"]["X"], pt["Position"]["Y"], pt["Position"]["Z"]]))
else:
camera_points = [np.array([pt["Position"]["X"], pt["Position"]["Y"], pt["Position"]["Z"]]) for pt in current_path_data]
if camera_points:
pivot = np.mean(camera_points, axis=0)
for i, pt in enumerate(current_path_data):
if dolly_mode == 4 and view_target is not None and i == 1:
continue
pos = np.array([pt["Position"]["X"], pt["Position"]["Y"], pt["Position"]["Z"]])
rel = pos - pivot
new_rel = camera_rotation_offset.apply(rel)
new_pos = pivot + new_rel
pt["Position"]["X"] = round(new_pos[0], 3)
pt["Position"]["Y"] = round(new_pos[1], 3)
pt["Position"]["Z"] = round(new_pos[2], 3)
if current_path_data:
for i, pt in enumerate(current_path_data):
if dolly_mode == 4 and view_target is not None and i == 1:
continue
base_rot = R.from_euler('XYZ', [pt["Rotation"]["X"], pt["Rotation"]["Y"], pt["Rotation"]["Z"]], degrees=True)
new_rot = camera_rotation_offset * base_rot
new_euler = new_rot.as_euler('XYZ', degrees=True)
pt["Rotation"]["X"] = round(new_euler[0], 2)
pt["Rotation"]["Y"] = round(new_euler[1], 2)
pt["Rotation"]["Z"] = round(new_euler[2], 2)
send_dolly_path()
def send_dolly_path():
global initial_import
if initial_import:
print("Initial import suppressed.")
initial_import = False
return
if current_path_data is None:
return
# Make a copy of the current path data.
final_data = current_path_data.copy()
# Apply reversal if the flag is set.
if reverse_path:
# For file mode (dolly_mode==4) with a target, keep index 1 fixed.
if dolly_mode == 4 and view_target is not None and len(final_data) > 2:
# Keep first two points (start and target) intact.
start_target = final_data[:2]
# Reverse the remaining points.
rest = final_data[2:]
rest.reverse()
final_data = start_target + rest
else:
final_data.reverse()
# Optionally update the Index fields for debugging:
for i, pt in enumerate(final_data):
pt["Index"] = i
print("Reversed path order:", [pt["Index"] for pt in final_data])
# Apply common adjustments.