-
Notifications
You must be signed in to change notification settings - Fork 0
/
plane.py
40 lines (34 loc) · 1.2 KB
/
plane.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
from OpenGL.GL import *
import math
class Plane:
def __init__(self, x, y, z, width, height):
self.x = x
self.y = y
self.z = z
self.width = width
self.height = height
self.half_width = width / 2
self.half_height = height / 2
self.plane_vertices = [
(x - self.half_width, y, z - self.half_height),
(x + self.half_width, y, z - self.half_height),
(x + self.half_width, y, z + self.half_height),
(x - self.half_width, y, z + self.half_height),
]
def update(self):
self.plane_vertices = [
(self.x - self.half_width, self.y, self.z - self.half_height),
(self.x + self.half_width, self.y, self.z - self.half_height),
(self.x + self.half_width, self.y, self.z + self.half_height),
(self.x - self.half_width, self.y, self.z + self.half_height),
]
def draw(self):
# Draw the plane (opaque)
# glEnable(GL_BLEND)
glColor3f(0.0, 0.5, 1.0)
glBegin(GL_QUADS)
for vertex in self.plane_vertices:
glVertex3fv(vertex)
glEnd()
glColor3f(1.0, 1.0, 1.0)
# glDisable(GL_BLEND)