def projection_vectorielle(pt): vector = v.diference3D(pt, position) if PROJECTIONSHERIQUE: vector.normalize() vector.dot(FOV) z = v.scalar(vector, direction) else: # z = abs(v.scalar(vector, direction)) z = v.scalar(vector, direction) vector.dot(FOV / z) x = v.scalar(vector, Dx) y = v.scalar(vector, Dz) # x = x*(screen/2) + screenX/2 # y = y*(screen/2) + screenY/2 x = x * (screen / 2) + screenX / 2 y = y * (screen / 2) + screenY / 2 # if x<0 or y<0 or x>screen or y>screen: # print(x, y) if z < 0: x -= screenX / 2 y -= screenY / 2 return x * screenX, y * screenY return x, y
def generate_faces_colored(mesh, material): dots, faces = mesh faces_ = [] for face in faces: vect1 = v.diference3D(dots[face[0]], dots[face[1]]) vect2 = v.diference3D(dots[face[0]], dots[face[2]]) vect = v.cross3D(vect1, vect2) vect.normalize() c = apply_light(material.get_color(), (1 + v.scalar(vect, light)) / 2, material.get_light_power()) faces_.append(bs.Face(*get_vectors_face(face, dots), c, material)) return faces_