"""Podstawy: wlasny model z Blendera i kamera robiaca pelne 360 stopni. Uruchom w UE: File > Execute Python Script. Zapisz model w Blenderze przed uruchomieniem. """ import math from ue_workshop import Scene, Sequence, Renderer, camera, lighting, materials from ue_workshop.paths import PROJECT REIMPORT = False # True po zmianie modelu w Blenderze; False uzywa assetu z UE # 1. SCENA. Zmien model, kolor podlogi i swiatla. scene = Scene("Basics") character = scene.model( PROJECT / "source_assets/character/character_custom.blend", name="CustomCharacter", height=200, reimport=REIMPORT, ) floor = materials.color("Floor", (0.07, 0.08, 0.11)) scene.primitive("Cube", name="Floor", location=(0, 0, -10), scale=(20, 20, 0.2), material=floor) lighting.studio(scene) # 2. KAMERA. Jednostki: centymetry; FOV w stopniach. radius = 550 height = 260 target = (0, 0, 100) cam = camera.create(scene, location=(radius, 0, height), target=target, fov=45) # 3. ANIMACJA. 192 klatki przy 24 FPS = 8 sekund. shot = Sequence(scene, fps=24, frames=192) shot.camera(cam) pitch = -math.degrees(math.atan2(height - target[2], radius)) for frame in range(shot.frames): angle = 360 * frame / (shot.frames - 1) x = radius * math.cos(math.radians(angle)) y = radius * math.sin(math.radians(angle)) # Rotacja: roll, pitch, yaw. Ciagly yaw zapobiega obrotowi wstecz przy 180 stopniach. shot.transform_key(cam, frame, location=(x, y, height), rotation=(0, pitch, angle + 180)) shot.save() # 4. RENDER. Najpierw obejrzyj scene w Sequencerze. renderer = Renderer(width=1280, height=720, samples=4, warmup=16, mp4=True) # renderer.render(shot) # Zamiast filmu: renderer.render(shot, single_frame=96)