Private
Public Access
16 lines
1002 B
Python
16 lines
1002 B
Python
"""Project fictional grave emitter into the existing animated camera."""
|
|
import bpy, os, json, math
|
|
from mathutils import Vector
|
|
from bpy_extras.object_utils import world_to_camera_view
|
|
root=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
bpy.ops.wm.open_mainfile(filepath=os.path.join(root,'preview/v4/halloween_dark_groan.blend'))
|
|
s=bpy.context.scene;origin=Vector((0,1.48,1.02));end=Vector((3.25,-.65,1.2));direction=(end-origin).normalized()
|
|
u=direction.cross(Vector((0,0,1))).normalized();v=direction.cross(u).normalized();records=[]
|
|
def project(p):
|
|
c=world_to_camera_view(s,s.camera,p);return [c.x*1280,(1-c.y)*720]
|
|
for f in range(198,274):
|
|
s.frame_set(f);ring=[project(end+.72*(u*math.cos(i*math.tau/40)+v*math.sin(i*math.tau/40))) for i in range(40)]
|
|
records.append({'frame':f,'origin':project(origin),'ring':ring})
|
|
path=os.path.join(root,'preview/v4/scan_assets');os.makedirs(path,exist_ok=True)
|
|
with open(os.path.join(path,'projection.json'),'w') as out:json.dump(records,out)
|