"""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 = True # True po zmianie modelu w Blenderze; False uzywa assetu z UE SKY = True # True: niebo i slonce; False: ciemne studio z trzema swiatlami # 1. SCENA. Zmien model, podloge i swiatla. scene = Scene("Basics") character = scene.model( PROJECT / "source_assets/character/character_custom.blend", name="CustomCharacter", height=200, reimport=REIMPORT, ) # tiling=40: tekstura powtorzona 40 razy na kazdej krawedzi podlogi (200 x 200 m). floor = materials.texture_set("TiledFloor", base_color="source_assets/textures/floor_tiles.png", tiling=40) scene.primitive("Cube", name="Floor", location=(0, 0, -10), scale=(200, 200, 0.2), material=floor) if SKY: # Zachod slonca: dodaj sun_angle=5. Mocniejsza mgla: fog=0.05. lighting.environment(scene, sun_intensity=1500, fog=0.01) else: lighting.studio(scene) # 2. KAMERA. Jednostki: centymetry; FOV w stopniach. radius = 550 height = 140 # nisko, zeby w kadrze byl horyzont target = (0, 0, 110) 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. Muzyke uslyszysz dopiero w MP4. renderer = Renderer(width=1280, height=720, samples=4, warmup=16, mp4=True, audio="source_assets/audio/basics_music.wav") # renderer.render(shot) # Zamiast filmu: renderer.render(shot, single_frame=96)