-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.py
More file actions
92 lines (84 loc) · 3.54 KB
/
Copy pathconsole.py
File metadata and controls
92 lines (84 loc) · 3.54 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
import threading as thrd
import config as cfg
from camera import camera
from numpy import deg2rad, rad2deg
def console_thread():
while True:
command = input(" > ")
splited = command.split()
main_arg = splited[0]
if main_arg == "tp":
try:
if splited[1].startswith("~"):
x = float(splited[1][1:]) + camera.x
else:
x = float(splited[1])
if splited[2].startswith("~"):
y = float(splited[2][1:]) + camera.y
else:
y = float(splited[2])
if splited[3].startswith("~"):
z = float(splited[3][1:]) + camera.z
else:
z = float(splited[3])
camera.x, camera.y, camera.z = x, y, z
except Exception:
print("Invalid arguments or command")
elif main_arg == "speed":
if splited[1] == "set":
if splited[2] == "default":
cfg.speed = 0.010
else:
try:
cfg.speed = float(splited[2])
except Exception:
print("Invalid arguments or command")
elif splited[1] == "add":
try:
cfg.speed = float(splited[2]) + cfg.speed
except Exception:
print("Invalid arguments or command")
elif splited[1] == "get":
print(f"Current speed is >> {cfg.speed:.3f}")
elif main_arg == "fov":
if splited[1] == "set":
if splited[2] == "default":
camera.fov = 60
camera.f = camera.get_focus(cfg.screen, camera.fov)/2
else:
try:
fov = float(splited[2])
camera.fov = fov
camera.f = camera.get_focus(cfg.screen, camera.fov)/2
except Exception:
print("Invalid arguments or command")
elif splited[1] == "add":
try:
fov = float(splited[2]) + camera.fov
camera.fov = fov
camera.f = camera.get_focus(cfg.screen, camera.fov)/2
except Exception:
print("Invalid arguments or command")
elif splited[1] == "get":
print(f"Current FoV is >> {camera.fov:.3f}")
elif main_arg == "look":
if splited[1] == "set":
if splited[2] == "default":
camera.dx, camera.dy = 0, 0
else:
try:
camera.dx, camera.dy = deg2rad(float(splited[2])), deg2rad(float(splited[3]))
except Exception:
print("Invalid arguments or command")
elif splited[1] == "add":
try:
camera.dx, camera.dy = deg2rad(camera.dx + float(splited[2])), deg2rad(camera.dy + float(splited[3]))
except Exception:
print("Invalid arguments or command")
elif splited[1] == "get":
print(f"Current look angle is >> {rad2deg(camera.dx):.3f} | {rad2deg(camera.dy):.3f}")
elif main_arg == "kill":
camera.kill()
def start_console():
thread = thrd.Thread(target=console_thread, daemon=True)
thread.start()