def step(self, step_t): t = self.c.get_current_time() print 'Simulation time:', t T = time.time() self.c.step(step_t) print 'Time:', time.time() - T image_buffer = tc_core.RGBImageFloat(self.video_manager.width, self.video_manager.height, Vector(0, 0, 0.0)) particles = self.c.get_render_particles() particles.write(self.directory + '/particles%05d.bin' % self.frame) res = map(float, self.resolution) radius = res[0] * 2.5 theta = 0 camera = Camera('pinhole', origin=(0, res[1], res[2] * 5), look_at=(0, 0, 0), up=(0, 1, 0), fov=70, width=10, height=10) self.particle_renderer.set_camera(camera) self.particle_renderer.render(image_buffer, particles) img = image_buffer_to_ndarray(image_buffer) img = LDRDisplay(exposure=0.1).process(img) show_image('Vis', img) self.video_manager.write_frame(img) self.frame += 1
def step(self, step_t): t = self.c.get_current_time() print 'Simulation time:', t T = time.time() self.c.step(step_t) print 'Time:', time.time() - T image_buffer = tc_core.RGBImageFloat(self.video_manager.width, self.video_manager.height, Vector(0, 0, 0.0)) particles = self.c.get_render_particles() particles.write( self.get_output_path('particles%05d.bin' % self.step_counter)) camera = Camera('pinhole', origin=(0, 0, 50), look_at=(0, 0, 0), up=(0, 1, 0), fov=70, width=self.video_manager.width, height=self.video_manager.height) self.particle_renderer.set_camera(camera) self.particle_renderer.render(image_buffer, particles) img = image_buffer_to_ndarray(image_buffer) # img = LDRDisplay(exposure=1, adaptive_exposure=False).process(img) cv2.imshow('Vis', img) cv2.waitKey(1) self.video_manager.write_frame(img) self.step_counter += 1
def view(self, frame, camera): particles = tc_core.RenderParticles() ret = particles.read(self.input_directory + 'particles%05d.bin' % frame) if not ret: print 'read file failed' return False image_buffer = tc_core.RGBImageFloat(self.video_manager.width, self.video_manager.height, Vector(0, 0, 0.0)) self.particle_renderer.set_camera(camera) self.particle_renderer.render(image_buffer, particles) img = image_buffer_to_ndarray(image_buffer) #img = LDRDisplay(exposure=1, adaptive_exposure=False).process(img) show_image('Vis', img) self.video_manager.write_frame(img) return True
resolution = [64] * 3 resolution[1] *= 2 particle_renderer = ParticleRenderer('shadow_map', shadow_map_resolution=0.5, alpha=0.6, shadowing=0.07, ambient_light=0.3, light_direction=(1, 3, 1)) smoke = Smoke3(resolution=tuple(resolution), simulation_depth=resolution[2], delta_x=1.0 / resolution[0], gravity=(0, 0, 0), advection_order=1, cfl=0.5, smoke_alpha=80.0, smoke_beta=800, temperature_decay=0.05, pressure_tolerance=1e-6, density_scaling=2, initial_speed=(0, 0, 0), tracker_generation=20, perturbation=0, pressure_solver='mgpcg', num_threads=2, open_boundary=True) for i in range(600): smoke.step(0.03) particles = smoke.c.get_render_particles() width, height = 512, 1024 image_buffer = tc_core.RGBImageFloat(width, height, Vector(0, 0, 0.0)) radius = resolution[0] * 4 camera = Camera('pinhole', origin=(0, radius * 0.3, radius), look_at=(0, 0, 0), up=(0, 1, 0), fov=70, width=width, height=height) particle_renderer.set_camera(camera) particle_renderer.render(image_buffer, particles) img = image_buffer_to_ndarray(image_buffer) cv2.imshow('Vis', img) cv2.waitKey(1)