def setup_scenario_0():
	# walls
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * -0.2), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * 0.2), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0)

	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * -0.4), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 8, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * 0.4), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 8, depth=sphere_radius, mass=0.0)
def throw_bullet(size=1.0, mass=1.0, type='sphere', spread_angle=1.0, spread_pos=1.0):
	world = gs.Matrix4.TransformationMatrix(make_solid_pos(uniform(md_screen_w * -0.01 * size * spread_pos, md_screen_w * 0.01 * size * spread_pos), md_screen_h / 2 + (sphere_radius * size)), gs.Vector3())
	if type.find('sphere') > -1:
		new_bullet, rigid_body = scene.add_physic_sphere(scn, world, sphere_radius * size, mass=mass)
	elif type.find('cube') > -1:
		new_bullet, rigid_body = scene.add_physic_cube(scn, world, sphere_radius * size * 1.6, sphere_radius * size * 1.6, sphere_radius * size * 1.6, mass=mass)

	if type.find('elastic') > -1:
		rigid_body.SetRestitution(1.15)

	ejection_vector = world.GetY() + gs.Vector3(uniform(-1.0, 1.0), uniform(0.0, 1.0), 0.0) * spread_angle
	rigid_body.ApplyLinearImpulse(ejection_vector * (-50 / scale_factor))
	new_bullet.SetName('type;' + type + ';size;' + str(int(size)) + ';mass;' + str(int(mass)))
def setup_scenario_2():
	# walls
	# scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * -0.2), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
	# 					  width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0)
	# scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * 0.2), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
	# 					  width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0)

	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * -0.4), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 8, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_h * 0.4), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 8, depth=sphere_radius, mass=0.0)

	scene.add_physic_sphere(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(0,-md_screen_h * 0.25,0),gs.Vector3(0,0,0)),
	 					  radius=sphere_radius * 4.0, mass=0.0)

	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * -0.48), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 16.0, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * 0.48), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 16.0, depth=sphere_radius, mass=0.0)
stream_list = []


def make_solid_pos(x, y):
    return gs.Vector3(x * 1.15, y + height * 0.5, cos(x * y + x) * 0.15)


cube_masks = [[0, 0, 1, 0], [0, 1, 1, 0], [1, 1, 1, 1]]

for y in range(3):
    for x in range(-2, 2):
        if cube_masks[y][x + 2] == 1:
            world = gs.Matrix4.TransformationMatrix(
                make_solid_pos(x, y),
                gs.Vector3(0, pi * 0.25 * cos(x * y + x + y + 0.1) * 0.25, 0))
            new_cube = scene.add_physic_cube(scn, world, width, height, length,
                                             2)
            node_list.append(new_cube[0])

# fps = camera.fps_controller(0, 3.5, -12.5)

thrown_bullet = False
fixed_step = True
record_motion = False
record_done = False

dt_sum = 0.0

# Start simulation & record

while not input.key_press(gs.InputDevice.KeyEscape) and not record_done:
    if fixed_step:
stream_list = []


def make_solid_pos(x, y):
    return gs.Vector3(x * 1.15, y + height * 0.5, cos(x * y + x) * 0.15)


cube_masks = [[0, 0, 1, 0], [0, 1, 1, 0], [1, 1, 1, 1]]

for y in range(3):
    for x in range(-2, 2):
        if cube_masks[y][x + 2] == 1:
            world = gs.Matrix4.TransformationMatrix(
                make_solid_pos(x, y), gs.Vector3(0, pi * 0.25 * cos(x * y + x + y + 0.1) * 0.25, 0)
            )
            new_cube = scene.add_physic_cube(scn, world, width, height, length, 2)
            node_list.append(new_cube[0])

# fps = camera.fps_controller(0, 3.5, -12.5)

thrown_bullet = False
fixed_step = True
record_motion = False
record_done = False

dt_sum = 0.0

# Start simulation & record

while not input.key_press(gs.InputDevice.KeyEscape) and not record_done:
    if fixed_step:
def setup_scenario_4():

	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * -0.48), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 16.0, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * 0.48), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 16.0, depth=sphere_radius, mass=0.0)
def setup_scenario_3():

	scene.add_physic_sphere(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(0,-md_screen_h * 0.25,0),gs.Vector3(0,0,0)),
	 					  radius=sphere_radius * 4.0, mass=0.0)

	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * -0.48), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * 0.48), -md_screen_h * 0.5,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0)

	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * -0.48), 0.0,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 16.0, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * 0.48), 0.0,0),gs.Vector3(0,0,0)),
						  width=sphere_radius * 2.0, height=sphere_radius * 16.0, depth=sphere_radius, mass=0.0)

	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * -0.48), md_screen_h * 0.5,0),gs.Vector3(0,0,pi * 0.5)),
						  width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * 0.48), md_screen_h * 0.5,0),gs.Vector3(0,0,pi * 0.5)),
						  width=sphere_radius * 2.0, height=sphere_radius * 12.0, depth=sphere_radius, mass=0.0)

	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * -0.2), md_screen_h * 0.5,0),gs.Vector3(0,0,pi * 0.5)),
						  width=sphere_radius * 2.0, height=sphere_radius * 10.0, depth=sphere_radius, mass=0.0)
	scene.add_physic_cube(scn, mat=gs.Matrix4.TransformationMatrix(gs.Vector3(tile_quantizer(md_screen_w * 0.2), md_screen_h * 0.5,0),gs.Vector3(0,0,pi * 0.5)),
						  width=sphere_radius * 2.0, height=sphere_radius * 10.0, depth=sphere_radius, mass=0.0)