from vectors import Vector2d, Vector3d, Vector4d from matrix import Matrix3x3 class Engine: def __init__(self, width, height): self._width = width self._height = height @property def width(self): return self._width @width.setter def width(self, width): raise ValueError("Not allowed") class Mesh: def __init__(self): self.triangles = [] self.vertices = [] def load_obj_file(self, path): lines = [] with open(path, 'r') as reader: lines = reader.readlines() for line in lines: if line[0] == 'v': tmp = line.split(' ') x = float(tmp[1]) y = float(tmp[2]) z = float(tmp[3]) self.vertices.append(Vector3d(x, y, z)) if line[0] == 'f': tmp = line.split(' ') # Subtract one because the obj file isn't zero indexed. row0 = self.vertices[int(tmp[1]) - 1] row1 = self.vertices[int(tmp[2]) - 1] row2 = self.vertices[int(tmp[3]) - 1] tri = Matrix3x3(row0, row1, row2) self.triangles.append(tri)#Vector3d(x - 1, y - 1, z - 1))