def main(): # Setup the scene scene = Scene() scene.add(Cube()) scene.look_at((2, 1, 1.5), (0, 0, 0)) scene.perspective(50, 0.1, 10) # Render and display the scene scene.render().show(show_hidden=True)
def test_pyramid(renderer_id): scene = Scene() scene.add(Pyramid()) scene.look_at((2, 6, 1.5), (0, 0, 0)) scene.perspective(70, 0.1, 10) rs = scene.render(renderer_id, merge_lines=False) assert rs.find_indices() == {1, 2, 5, 6, 7}
def main(silhouette: bool = False): scene = Scene() obj = OBJShape("deer.obj") obj.rotate_x(-math.pi / 2) obj.rotate_z(-math.pi / 2) if silhouette: obj.add(SilhouetteSkin(keep_segments=False)) scene.add(obj) scene.look_at((2, 2, 2), (0, 0, 0.5)) scene.perspective(25, 0.1, 10) scene.render().show()
def main(): # Setup the scene scene = Scene() n = Node() n.add(Cube(scale=(10, 20, 6))) for i in [2.5, -2.5]: for j in [-7.5, -2.5, 2.5, 7.5]: n.add(Cylinder(scale=(1.5, 1.5, 1), translate=(i, j, 3.5))) scene.add(n) scene.look_at((30, 30, 20), (0, 0, 0)) scene.perspective(50, 0.1, 10) # Render and display the scene scene.render().show()
def main(silhouette: bool = False): scene = Scene() n = Node() for i in range(-10, 11, 2): for j in range(-10, 11, 2): h = 1 + random.random() * 2 c = Cube(scale=(1, 1, h), translate=(i, j, h / 2)) n.add(c) if silhouette: n.add(SilhouetteSkin(keep_segments=False)) scene.add(n) scene.look_at((25, 22.5, 15), (0, 0, 0)) scene.perspective(50, 0.1, 10) scene.render().show()
def main(): scene = Scene() np.random.seed(0) for i in range(-12, 13, 2): for j in range(-12, 13, 2): h = 1 + random.random() * 5 c = StrippedCube(scale=(1, 1, h), translate=(i, j, h / 2)) scene.add(c) scene.look_at((1.1, 0.8, 8.2), (0, 0.2, 0)) scene.perspective(90, 0.1, 10) rs = scene.render("v2") rs.show()
def main(silhouette: bool = False): scene = Scene() obj = OBJShape("cow.obj") obj.rotate_x(-math.pi / 2) obj.rotate_z(-math.pi / 2) if silhouette: obj.add(SilhouetteSkin(keep_segments=False)) scene.add(obj) scene.look_at((0.5, 2, 0.2), (0, 0, 0)) scene.perspective(40, 0.1, 10) rs = scene.render("v2") rs.show() rs.save("cow_new.svg")
def test_city(renderer_id): """ This test case appeared as problematic at some point """ for i, j in [(0, 0), (-4, -2)]: scene = Scene() c = StrippedCube(scale=(1, 1, 1), translate=(i, j, 0.5)) scene.add(c) scene.look_at((1.1, 0.8, 8.2), (0, 0.2, 0)) scene.perspective(90, 0.1, 10) rs = scene.render(renderer_id, merge_lines=False) expected_indices = { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 } assert rs.find_indices() == expected_indices
def main(silhouette: bool = True): scene = Scene() n = Node() for i in range(0, 3, 2): for j in range(0, 1, 2): h = 1 c = Cube(scale=(1, 1, h), translate=(i, j, h / 2)) n.add(c) if silhouette: n.add(SilhouetteSkin(keep_segments=False)) scene.add(n) scene.look_at((25, 22.5, 15), (0, 0, 0)) scene.perspective(50, 0.1, 10) rs = scene.render("v2", merge_lines=False) print(rs.find_indices()) rs.show(show_faces=23, show_grid=True, show_axes=True)
def test_cubes_silhouette(renderer_id): # TODO: this test must be generalised to the silhouette of any available scene scene = Scene() for i in range(0, 3, 2): for j in range(2, 3, 2): c = Cube(scale=(1, 1, 1), translate=(i, j, 0.5)) scene.add(c) scene.add(SilhouetteSkin(keep_segments=False)) scene.look_at((25, 22.5, 15), (0, 0, 0)) scene.perspective(50, 0.1, 10) rs = scene.render(renderer_id, merge_lines=False) # by definition of a silhouette scene, every single segment must go through assert rs.find_indices() == set(range(len(rs._projected_segments)))
def test_no_segment(renderer_id): scene = Scene() scene.add( TriangleShape((1, 0, 0), (-1, 0, 0), (0, 0, 2), add_segments=False)) scene.look_at((2, 2, 1), (0, 0, 1)) scene.render(renderer_id)
def test_no_face(renderer_id): scene = Scene() scene.add(SegmentShape((0, -2, 1), (0, 1, 1))) scene.look_at((2, 2, 1), (0, 0, 1)) scene.render(renderer_id)
def test_empty_scene(renderer_id): scene = Scene() scene.look_at((2, 2, 1), (0, 0, 1)) scene.render(renderer_id)
def main(): # Setup the scene scene = Scene() scene.add(Cube(translate=(2, 0, 0))) scene.add(Pyramid()) scene.add(Cylinder(scale=(0.5, 0.5, 1), translate=(-2, 0, 0))) scene.look_at((2, 6, 1.5), (0, 0, 0)) scene.perspective(70, 0.1, 10) # Render and display the scene scene.render().show(show_hidden=True)
def main(): scene = Scene() scene.add(SegmentShape((0, -2, 1), (0, 1, 1))) scene.add(SegmentShape((1, -0.1, 0.5), (-3, -0.1, 0.5))) # behind scene.add(SegmentShape((-3, 0.1, 0.8), (1, 0.1, 0.8))) scene.add(TriangleShape((1, 0, 0), (-1, 0, 0), (0, 0, 2))) scene.look_at((2, 2, 1), (0, 0, 1)) scene.perspective(90, 0.1, 10) scene.render().show(show_axes=True, show_grid=True)
def main(): scene = Scene() scene.add( Cylinder(vertical_segs=True, silhouette=False, translate=(0, -3, 0))) scene.add(Cylinder(vertical_segs=False, silhouette=False)) scene.add( Cylinder(vertical_segs=False, silhouette=True, translate=(0, 3, 0))) scene.look_at((12, 0, 4), (0, 0, 0)) scene.perspective(50, 0.1, 20) scene.render().show(show_hidden=True)