-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects_collection.py
80 lines (61 loc) · 2.9 KB
/
objects_collection.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import math
import numpy as np
from object_3d import *
class Cube(Object3D):
def __init__(self, renderer, shading=True, position=(0, 0, 0), ):
super().__init__(renderer, shading)
self.vertexes = np.array([[-1, -1, -1, 1], [-1, 1, -1, 1], [1, 1, -1, 1], [1, -1, -1, 1],
[-1, -1, 1, 1], [-1, 1, 1, 1], [1, 1, 1, 1], [1, -1, 1, 1]])
self.faces = np.array([[0, 1, 2, 3], [0, 1, 5, 4], [0, 4, 7, 3], [3, 2, 6, 7],
[1, 5, 6, 2], [4, 5, 6, 7]])
# self.faces = np.array([[0, 1, 2, 3], [0, 1, 5, 4], [3, 2, 6, 7], [4, 5, 6, 7]])
# self.faces = np.array([[0, 1, 2, 3]])
self.scale(2)
self.translate(position)
# self.rotate_y(math.pi / 4)
self.font = pg.font.SysFont('Arial', 30, bold=True)
self.color_faces = [(pg.Color('blue'), face) for face in self.faces]
self.movement_flag, self.draw_vertexes = False, False
#self.rotate_y(math.pi * -0.1)
self.label = ''
def __str__(self):
return "cube"
class Tetrahedron(Object3D):
def __init__(self, renderer, shading=True, position=(0, 0, 0)):
super().__init__(renderer, shading)
self.vertexes = np.array([[-1, -1, -1, 1], [1, -1, -1, 1], [0, -1, 1, 1], [0, 1, 0, 1]])
self.faces = np.array([[0, 2, 3], [0, 2, 1], [1, 2, 3], [0, 3, 1]])
#self.faces = np.array([[0, 3, 1]])
self.color_faces = [(pg.Color('pink'), face) for face in self.faces]
self.movement_flag, self.draw_vertexes = False, False
self.scale(2)
# self.rotate_y(math.pi * 0.6)
self.translate(position)
self.translate((1, 0, 0))
self.rotate_y(math.pi / 2)
def __str__(self):
return "tetrahedron"
class Axes(Object3D):
def __init__(self, render, shading):
super().__init__(render, shading)
self.vertexes = np.array([(0, 0, 0, 1), (1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)])
self.faces = np.array([(0, 1), (0, 2), (0, 3)])
self.colors = [pg.Color('red'), pg.Color('green'), pg.Color('blue')]
self.color_faces = [(color, face) for color, face in zip(self.colors, self.faces)]
self.draw_vertexes = False
self.movement_flag = False
#self.label = 'XYZ'
class Plain(Object3D):
def __init__(self, render, shading, position=(0, 0, 0), rotation=0):
super().__init__(render, shading)
self.translate(position)
self.vertexes = np.array([(-1, 0, -1, 1), (-1, 0, 1, 1), (1, 0, 1, 1), (1, 0, -1, 1)])
self.faces = np.array([[0, 1, 2, 3]])
self.colors = [pg.Color('red'), pg.Color('green'), pg.Color('blue')]
self.color_faces = [(color, face) for color, face in zip(self.colors, self.faces)]
self.draw_vertexes = False
self.movement_flag = False
self.scale(2)
self.rotate_x(rotation)
def __str__(self):
return "plain"