-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcam_control.py
More file actions
33 lines (31 loc) · 1.27 KB
/
cam_control.py
File metadata and controls
33 lines (31 loc) · 1.27 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
# UTILITY FUNCTIONS FOR USE WITH PANDA3D
def move_cam(direction):
pos = base.cam.get_pos()
match direction:
case "left":
base.cam.setPos(pos.x - .2, pos.y, pos.z)
case "right":
base.cam.setPos(pos.x + .2, pos.y, pos.z)
case "fwd":
base.cam.setPos(pos.x, pos.y + .2, pos.z)
case "back":
base.cam.setPos(pos.x, pos.y - .2, pos.z)
case _:
print("Move direction not recognised!")
def enable_camera_controls():
base.accept("arrow_left", move_cam, ["left"])
base.accept("arrow_left-repeat", move_cam, ["left"])
base.accept("a", move_cam, ["left"])
base.accept("a-repeat", move_cam, ["left"])
base.accept("arrow_right", move_cam, ["right"])
base.accept("arrow_right-repeat", move_cam, ["right"])
base.accept("d", move_cam, ["right"])
base.accept("d-repeat", move_cam, ["right"])
base.accept("arrow_up", move_cam, ["fwd"])
base.accept("arrow_up-repeat", move_cam, ["fwd"])
base.accept("w", move_cam, ["fwd"])
base.accept("w-repeat", move_cam, ["fwd"])
base.accept("arrow_down", move_cam, ["back"])
base.accept("arrow_down-repeat", move_cam, ["back"])
base.accept("s", move_cam, ["back"])
base.accept("s-repeat", move_cam, ["back"])