basic advanced example

This commit is contained in:
Vysyr committed 2026-10-31 23:11:57 +01:00
1 parent 6fe57915e8
commit bd8edf5afb
29 files changed
+1501 -38

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
"""Validate offline catalog timings against UE and play enum clips with automatic ends."""
import math
from ue_workshop import Scene, Sequence, Renderer, camera, lighting
from ue_workshop.animations import FighterAnimations, CreatureAnimations
from ue_workshop.characters import FIGHTER_MODEL, CREATURE_MODEL
from ue_workshop.skeletal import import_model
for model, name, catalog in ((FIGHTER_MODEL, "Fighter", FighterAnimations),
(CREATURE_MODEL, "Creature", CreatureAnimations)):
imported = import_model(model, name=name, reimport=False)
for clip in catalog:
assert math.isclose(clip.seconds, imported.animations[clip.key].get_play_length(),
rel_tol=0, abs_tol=0.000001), clip.key
scene = Scene("CatalogSmoke")
fighter = scene.skeletal_model(FIGHTER_MODEL, name="Fighter", rotation=(0, 0, 180))
scene.primitive("Cube", name="Floor", location=(0, 0, -10), scale=(20, 20, 0.2))
lighting.studio(scene)
cam = camera.create(scene, location=(450, -550, 300), fov=45)
shot = Sequence(scene, fps=24, frames=120)
shot.camera(cam)
draw = FighterAnimations.DRAW_A_GREAT_SWORD_1
attack = FighterAnimations.GREAT_SWORD_ATTACK
first = shot.animation(fighter, draw, start=0)
second_start = draw.frames(shot.fps) - 6
second = shot.animation(fighter, attack, start=second_start)
fast = shot.animation(fighter, attack, start=60, speed=2)
assert first.get_end_frame() == draw.frames(shot.fps)
assert second.get_end_frame() == second_start + attack.frames(shot.fps)
assert fast.get_end_frame() == 60 + attack.frames(shot.fps, speed=2)
assert second.get_editor_property("params").animation.get_name() == attack.key
shot.save(open_editor=False)
renderer = Renderer(width=640, height=360, samples=1, warmup=0, mp4=False)