-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcamera.py
59 lines (43 loc) · 1.26 KB
/
camera.py
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
import math
import glm
width: int = 1280
height: int = 720
position = glm.vec3(-0.4, 0.9, 2.2)
up = glm.vec3(0.0, 1.0, 0.0)
fov = 45.0 # field of view
pitch: float = -22.0
yaw: float = -78.0
front = glm.normalize(glm.vec3(
math.cos(glm.radians(pitch)) * math.cos(glm.radians(yaw)),
math.sin(glm.radians(pitch)),
math.cos(glm.radians(pitch)) * math.sin(glm.radians(yaw))
))
def updateFront():
global front
front = glm.normalize(glm.vec3(
math.cos(glm.radians(pitch)) * math.cos(glm.radians(yaw)),
math.sin(glm.radians(pitch)),
math.cos(glm.radians(pitch)) * math.sin(glm.radians(yaw))
))
def get_view_matrix():
return glm.lookAt(position, position + front, up)
def get_projection_matrix():
return glm.perspective(glm.radians(fov), width / height, 0.1, 100.0)
def setF1Location():
global position, pitch, yaw
position = glm.vec3(-0.4, 0.9, 2.2)
pitch = -22.0
yaw = -78.0
updateFront()
def setF2Location():
global position, pitch, yaw
position = glm.vec3(0.42, -0.45, -1.05)
pitch = 22.0
yaw = 112.0
updateFront()
def setF3Location():
global position, pitch, yaw
position = glm.vec3(-3.12, 3.83, 3.93)
pitch = -38.0
yaw = -53.0
updateFront()