def render_dfaust(scene, prev_renderable, seq, target): new_renderable = Mesh.from_file(seq) scene.remove(prev_renderable) scene.add(new_renderable) scene.render() save_frame(target, scene.frame) return new_renderable
def test_obj(self): s = Scene(size=(1024, 1024), background=(0, 0, 0, 0)) s.add(Mesh.from_file(path.join(path.dirname(__file__), "plane.obj"))) s.rotate_x(np.pi / 2) s.camera_position = (-1, -1, -1) for i in range(180): s.render() imwrite("/tmp/frame_{:03d}.png".format(i), s.frame) s.rotate_y(np.pi / 90)
def test_ply(self): s = Scene(size=(1024, 1024), background=(0, 0, 0, 0)) s.add( Mesh.from_file(path.join(path.dirname(__file__), "primitives.ply"))) s.up_vector = (0, -1, 0) s.camera_position = (1, 0.5, 1) light_initial = s.light r_light = np.sqrt(light_initial[0]**2 + light_initial[-1]**2) for i in range(180): theta = i * np.pi / 90 r = np.sqrt(2) s.camera_position = (r * np.cos(theta), 0.5, r * np.sin(theta)) s.light = (r_light * np.cos(theta), light_initial[1], r_light * np.sin(theta)) s.render() imwrite("/tmp/frame_{:03d}.png".format(i), s.frame)
def load_ground_truth(mesh_file): m = Mesh.from_file(mesh_file, color=(0.8, 0.8, 0.8, 0.3)) # m.to_unit_cube() return m
import numpy as np import matplotlib.pyplot as plt from simple_3dviz.renderables import Spherecloud from simple_3dviz.behaviours.keyboard import SnapshotOnKey from simple_3dviz.window import show if __name__ == "__main__": t = np.linspace(0, 4 * np.pi, 20) x = np.sin(2 * t) y = np.cos(t) z = np.cos(2 * t) sizes = (2 + np.sin(t)) * 0.125 centers = np.stack([x, y, z]).reshape(3, -1).T cmap = plt.cm.copper colors = cmap(np.random.choice(np.arange(500), centers.shape[0])) s = Spherecloud(centers=centers, sizes=sizes, colors=colors) from simple_3dviz import Mesh m = Mesh.from_file("models/baby_yoda.stl", color=(0.1, 0.8, 0.1)) m.to_unit_cube() show([s, m], camera_position=(-2.8, -2.8, 0.1), size=(512, 512))