cube = Model(vertexes, triangles, Vector3(0, 0, 0), sqrt(3)) #----- Light lights = [ Light('AMBIENT', 0.2, None), Light('POINT', 0.6, Vector3(-3, 2, -10)), Light('DIRECTIONAL', 0.2, Vector3(-1, 0, 1)) ] #----- Camera sqrt_2 = sqrt(2) clipping_planes = [ Plane(Vector3(0, 0, 1), -1), # Near Plane(Vector3(sqrt_2, 0, sqrt_2), 0), # Left Plane(Vector3(-sqrt_2, 0, sqrt_2), 0), # Right Plane(Vector3(0, -sqrt_2, sqrt_2), 0), # Top Plane(Vector3(0, sqrt_2, sqrt_2), 0) # Bottom ] camera = Camera(Vector3(-3, 1, 2), Matrix44().y_rotation(radians(-30)), clipping_planes) depth_buffer = [[0 for _ in range(screen_height)] for _ in range(screen_width)] instances = [Instance(cube, Vector3(-1.5, 0, 7), Matrix44(), 0.75), Instance(cube, Vector3(1.25, 2.5, 7.5), Matrix44.y_rotation(radians(195)), 1.0), Instance(cube, Vector3(1.75, 0, 5), Matrix44.y_rotation(radians(-30)), 1.0)] renderScene(camera, instances) image.save("raster18.png")
background_color = (255, 255, 255) image = Image.new("RGB", (screen_width, screen_height), background_color) pixels = image.load() cube = Model(vertexes, triangles, Vector3(0, 0, 0), sqrt(3)) sqrt_2 = sqrt(2) clipping_planes = [ Plane(Vector3(0, 0, 1), -1), # Near Plane(Vector3(sqrt_2, 0, sqrt_2), 0), # Left Plane(Vector3(-sqrt_2, 0, sqrt_2), 0), # Right Plane(Vector3(0, -sqrt_2, sqrt_2), 0), # Top Plane(Vector3(0, sqrt_2, sqrt_2), 0) # Bottom ] camera = Camera(Vector3(-3, 1, 2), Matrix44().y_rotation(radians(-30)), clipping_planes) depth_buffer = [[0 for _ in range(screen_height)] for _ in range(screen_width)] instances = [ Instance(cube, Vector3(-1.5, -1, 7), Matrix44(), 0.75), Instance(cube, Vector3(1.25, 2.5, 7.5), Matrix44.y_rotation(radians(195)), 1.0) ] renderScene(camera, instances) image.save("raster12.png")
Triangle(0, 2, 3, RED), Triangle(4, 0, 3, GREEN), Triangle(4, 3, 7, GREEN), Triangle(5, 4, 7, BLUE), Triangle(5, 7, 6, BLUE), Triangle(1, 5, 6, YELLOW), Triangle(1, 6, 2, YELLOW), Triangle(4, 5, 1, PURPLE), Triangle(4, 1, 0, PURPLE), Triangle(2, 6, 7, CYAN), Triangle(2, 7, 3, CYAN), ] background_color = (255, 255, 255) image = Image.new("RGB", (screen_width, screen_height), background_color) cube = Model(vertexes, triangles) camera = Camera(Vector3(-3, 1, 2), Matrix44.y_rotation(radians(-30))) instances = [Instance(cube, Vector3(-1.5, 0, 7), Matrix44(), 0.75), Instance(cube, Vector3(1.25, 2.5, 7.5), Matrix44.y_rotation(radians(195)), 1.0)] renderScene(camera, instances) image.save("raster09.png")