def render_random_spheres(scene): total_sphere = random.randint(1, 15) light = Light(Color(1.0, 1.0, 1.0, 1.0), 1.0) light.transform.position = Vector3(0.0, 2.0, -2.0) scene.set_light(light) for i in range(0, total_sphere): s = Sphere(random.randint(10, 200) / 100.0) s.transform.position = Vector3(random.randint(-3, 3), random.randint(-3, 3), random.randint(2, 10)) s.albedo = Color( float(random.randint(20, 255)) * 1.0 / 255.0, float(random.randint(20, 255)) * 1.0 / 255.0, float(random.randint(20, 255)) * 1.0 / 255.0, 1.0) print("Sphere got color " + str(s.albedo)) scene.add_objects(s) v1 = Vector3(8.0, 0.0, -1.0) v2 = Vector3(0.0, 8.0, -3.0) animation_velocity = 0.5 def update_method(t): p = Vector3(0.0, 2.0, -2.0) p = p.add(v1.multiply(np.cos(animation_velocity * t * np.pi))) p = p.add(v2.multiply(np.sin(animation_velocity * t * np.pi))) light.transform.position = p return update_method
total_sphere = random.randint(1, 15) scene_test = Scene() light = Light(Color(1.0, 1.0, 1.0, 1.0), 1.0) light.transform.position = Vector3(0.0, 2.0, -2.0) scene_test.set_light(light) for i in range(0, total_sphere): s = Sphere(random.randint(10, 200) / 100.0) s.transform.position = Vector3(random.randint(-3, 3), random.randint(-3, 3), random.randint(2, 10)) s.albedo = Color( float(random.randint(20, 255)) * 1.0 / 255.0, float(random.randint(20, 255)) * 1.0 / 255.0, float(random.randint(20, 255)) * 1.0 / 255.0, 1.0) print("Sphere got color " + str(s.albedo)) scene_test.add_objects(s) c = Camera() c.fov = 90 scene_test.set_ssaa(1) scene_test.set_camera(c) if os.path.exists("/sdcard/Raytracing/"): render_image = "/sdcard/Raytracing/test" else: render_image = 'test' render_extension = '.gif'