"""Check environment, camera cuts, visibility, rotate, materials, tiling, then and audio.""" import math import wave import unreal from ue_workshop import Scene, Sequence, Renderer, camera, lighting, materials from ue_workshop.animations import FighterAnimations as F from ue_workshop.characters import FIGHTER_MODEL from ue_workshop.paths import PROJECT scene = Scene("BasicsSmoke") lighting.environment(scene, fog=0.05) tiled = materials.texture_set("BasicsFloor", tiling=8, base_color="source_assets/character/creature/Maw J Laygo.fbm/MAW_diffuse.png") red = materials.color("BasicsRed", (0.8, 0.02, 0.01)) scene.primitive("Cube", name="Floor", location=(0, 0, -10), scale=(20, 20, 0.2), material=tiled) ramp = scene.primitive("Cube", name="Ramp", location=(0, 250, 50), scale=(2, 2, 0.2), rotation=(0, 30, 0)) assert abs(ramp.get_actor_rotation().pitch - 30) < 0.01 fighter = scene.skeletal_model(FIGHTER_MODEL, name="Fighter", height=200, location=(0, -150, 0)) materials.assign(fighter, red) skeletal = fighter.get_attached_actors()[0].skeletal_mesh_component assert all(skeletal.get_material(index) == red for index in range(skeletal.get_num_materials())) ghost = scene.character(material=red, name="Ghost", location=(-200, 100, 0)) assert math.dist(ghost.get_attached_actors()[0].get_actor_location().to_tuple()[:2], (-200, 100)) < 60 ball = scene.primitive("Sphere", name="Ball", location=(150, 0, 100), material=red) wide = camera.create(scene, location=(600, -700, 300), target=(0, 0, 100)) close = camera.create(scene, location=(300, -400, 150), target=(0, -150, 120), fov=30) shot = Sequence(scene, fps=24, frames=48) assert shot.seconds(1.5) == 36 shot.camera(wide) shot.camera(close, start=24, end=36) assert [cut[:2] for cut in shot._camera_cuts] == [(0, 24), (24, 36), (36, 48)] tracks = shot.asset.find_tracks_by_type(unreal.MovieSceneCameraCutTrack) assert len(tracks[0].get_sections()) == 3 shot.visible(ball, 12) shot.visible(ball, 24, False) shot.visible(ghost, 12, False) shot.animation(fighter, F.GREAT_SWORD_IDLE, start=0, end=24) shot.then(fighter, F.GREAT_SWORD_IDLE, overlap=6, end=48) assert shot.rotation(fighter, 0) == (0, 0, 0) assert shot.rotate(fighter, 0, 24, (0, 0, 90)) == (0, 0, 90) assert abs(shot.rotation(fighter, 24)[2] - 90) < 0.001 assert 0 < shot.rotation(fighter, 12)[2] < 90 assert abs(shot.rotation(fighter, 47)[2] - 90) < 0.001 assert shot.rotate(fighter, 24, 47, (0, 0, 360))[2] == 450 shot.save(open_editor=False) music = PROJECT / "Saved/Workshop/basics_smoke.wav" music.parent.mkdir(parents=True, exist_ok=True) with wave.open(str(music), "wb") as target: target.setnchannels(1) target.setsampwidth(2) target.setframerate(8000) target.writeframes(b"\x00\x10" * 8000 * 5) renderer = Renderer(width=640, height=360, samples=1, warmup=8, audio=str(music)) print("Basics smoke ready")