-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai_renderer.py
More file actions
62 lines (44 loc) · 1.32 KB
/
Copy pathai_renderer.py
File metadata and controls
62 lines (44 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from image_backend import ImageBackend
class AIRenderer:
"""
Converts structured scene graphs into:
- image prompts
- animation frame descriptions
- future diffusion model inputs
"""
def __init__(self, llm=None):
self.llm = llm
self.backend = ImageBackend(mode="ollama")
# -----------------------------
def render_frame(self, scene, frame_index):
objects = scene.get("objects", [])
description = "\n".join([
f"{o['id']} pos={o['position']} vel={o['velocity']}"
for o in objects
])
prompt = f"""
Generate visual frame description for rendering pipeline.
Scene:
{description}
Return structured visual prompt.
"""
result = self.backend.generate(prompt, output_path=f"frames/frame_{frame_index:04d}")
return result
# =====================================================
# SCENE → ANIMATION FRAME DESCRIPTION
# =====================================================
def render_animation_frame(self, scene, next_scene=None):
prompt = f"""
Describe a single animation frame transition.
Current scene:
{scene}
Next scene:
{next_scene}
Focus on:
- motion changes
- object displacement
- physics behavior
"""
if self.llm:
return self.llm.call(prompt)
return prompt