diff --git a/functions.py b/functions.py index 710188e..c78c8a0 100644 --- a/functions.py +++ b/functions.py @@ -363,7 +363,7 @@ colour: list[Colour] texture: list[Texture] - faces: list[Face] = [] + faces: list[Face] # ordered top - north - east - south - west - bottom cubePoints = [Point3D([.5, .5, .5]), Point3D([.5, .5, -.5]), Point3D([.5, -.5, .5]), Point3D([.5, -.5, -.5]), Point3D([-.5, .5, .5]), Point3D([-.5, .5, -.5]), Point3D([-.5, -.5, .5]), Point3D([-.5, -.5, -.5])] @@ -381,9 +381,10 @@ [cubePoints[6], cubePoints[2], cubePoints[0], cubePoints[4]]] # bottom] def __init__(self, position: Point3D, texture : list[Colour], has_faces, has_edges): + self.faces = [] + self.position = Point3D([0, 0, 0]) # todo # implement texture - self.position = position self.colours = texture @@ -392,8 +393,10 @@ # initialises faces when the cube is placed. Faces are in global coordinates for i in range(6): - self.faces.append(Face([point.translate(self.position) for point in self.cubeFaces[i]], + new_points = 0 + self.faces.append(Face([point.translate(self.position) for point in copy.deepcopy(self.cubeFaces[i])], self.colours[i], self.has_edges, self.has_faces)) + print(self.position.xyz()) def get_faces(self): return copy.deepcopy(self.faces) diff --git a/main.py b/main.py index eaf7955..fba8d44 100644 --- a/main.py +++ b/main.py @@ -132,7 +132,6 @@ # __draw cubes__ # calculate 3d and project 3d point locations - col = 0 for cube in cubes: for face in cube.get_faces(): allFaces.append(face) @@ -159,7 +158,7 @@ # if len(newPoints) > 2: # face.points = newPoints # allFaces.append(face) - + # whyyyy # add faces for placeable cube if placing: # generate the position for the new cube ('ray cast' out of camera and do weird things) @@ -171,7 +170,6 @@ newCube = Cube(newCubePos, placingColours[currentTexture], True, keys[pygame.K_LCTRL]) # take faces out of cube object and never speak of it again for face in newCube.get_faces(): - print(face.points[0].xyz) allFaces.append(face) # # fix points behind camera and remove faces with two or fewer remaining points @@ -184,13 +182,17 @@ # ______draw all faces______ # apply camMatrix to allFaces for face in allFaces: + # newpoints: list[Point3D] = [] for point in face.points: point.apply_matrix(camMatrix) - + # newpoints.append(Point3D([0, 0, 0])) + # point = Point3D(rotate(translate([point.xyz()], playerPos.xyz()), rotX, rotY, rotZ)[0]) + # face.points = newpoints # fix points behind the camera face.fix_points_behind_camera() - if len(face.points) < 3: - allFaces.remove(face) + # if len(face.points) < 3: + # allFaces.remove(face) + # sort the list of allFaces # iterates through all faces - iterates through each point axis - iterates through points within faces # (strange order) @@ -214,7 +216,7 @@ try: if True: # face_angle([face.points[0], face.points[1], face.points[2]], FPDis, camDistance) > 90: - if face.hasFaces: + if face.hasFaces and len(face.points) > 2: pygame.draw.polygon(mainSurface, tuple(face.colour.get_rgb()), [point.get() for point in _2dPoints], 0) if face.hasEdges: for i2 in range(len(_2dPoints)):