def __init__ (self, name: str, pos_x: float, pos_y: float, pos_z: float, i_r:float, i_g: float, i_b: float ): self.name = name self.pos = MV.vec3(pos_x, pos_y, pos_z) self.intensity = MV.vec3(i_r, i_g, i_b)
''' parser = argparse.ArgumentParser() parser.add_argument('infile', type=str, help="input file") args = parser.parse_args() if not args.infile: print("Need an infile...") exit() lights, spheres, backgroundColor, ambient, near, left, right, bottom, top, res, output_filename = parse_data(args.infile) h = res[0] w = res[1] img = np.full((h, w, 3), backgroundColor) atVector = MV.vec3((right+left)/2, (top+bottom)/2 , -near) camPoint = MV.vec3(0., 0., 0.) MAX_DEPTH = 6 scene = Scene(ambient, backgroundColor, camPoint, atVector, spheres, lights) r = float(w) / h # Screen coordinates: x0, y0, x1, y1. S = (-1., -1. / r, 1., 1. / r ) for i, x in enumerate(np.linspace(S[0], S[2], w)): for j, y in enumerate(np.linspace(S[1], S[3], h)): col = np.zeros(3) scene.atVector[:2] = (x, y) D = scene.atVector - scene.camPoint depth = 0 ray = Ray(scene.camPoint, D)