Files
Halloween/tools/add_cone_visualization.py

52 lines
3.8 KiB
Python

"""Fictional scan/database HUD for synthetic 3D visitors; no biometric processing."""
import bpy, os
ROOT=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
OUT=os.path.join(ROOT,'preview','v4')
bpy.ops.wm.read_factory_settings(use_empty=True);s=bpy.context.scene
s.render.resolution_x=1280;s.render.resolution_y=720;s.render.resolution_percentage=100;s.render.fps=24;s.frame_start=1;s.frame_end=480
s.view_settings.view_transform='Standard';s.sequence_editor_create();seq=s.sequence_editor.sequences
seq.new_movie('Existing animation',os.path.join(OUT,'halloween_dark_groan.mp4'),channel=1,frame_start=1)
seq.new_sound('Existing moan and atmosphere',os.path.join(OUT,'effects_with_groan.wav'),channel=2,frame_start=1)
assets=os.path.join(OUT,'scan_assets')
beam=seq.new_image('Grave headstone scan cone',os.path.join(assets,'cone_198.png'),channel=3,frame_start=198)
for f in range(199,274):beam.elements.append('cone_%03d.png'%f)
beam.frame_final_duration=76
channel=4
def text(name,body,start,end,x,y,size=24,color=(.4,1,.8,1)):
global channel
o=seq.new_effect(name,type='TEXT',channel=channel,frame_start=start,frame_end=end);channel+=1
o.text=body;o.font_size=size;o.color=color;o.location=(x,y);o.align_x='LEFT';o.align_y='TOP';o.use_shadow=True;o.shadow_color=(0,0,0,1)
return o
def bar(name,start,end,x,y,w,h,color):
global channel
o=seq.new_effect(name,type='COLOR',channel=channel,frame_start=start,frame_end=end);channel+=1;o.color=color
o.transform.scale_x=w/1280;o.transform.scale_y=h/720;o.transform.offset_x=x-640;o.transform.offset_y=y-360
return o
# Scan overlay on fictional figures: static stylized boxes, intentionally not a real detector.
bar('Scan header',198,274,640,665,1280,90,(.006,.018,.025))
text('Scan title','SIMULIERTER GESICHTSSCAN',198,274,.035,.96,30)
text('Permanent simulation label','3D-DEMO / KEINE REALEN GESICHTSDATEN',198,274,.035,.90,18,(.9,.9,.9,1))
for i,(x,y,w,h) in enumerate([(765,345,68,78),(819,334,68,78),(969,425,90,100),(1140,417,90,100)]):
for xx,yy,ww,hh in [(x-w/2,y,2,h),(x+w/2,y,2,h),(x,y-h/2,w,2),(x,y+h/2,w,2)]:bar('Synthetic head frame',198,274,xx,yy,ww,hh,(.08,.6,.38))
text('Synthetic figure label','DEMO %02d'%(i+1),198,274,(x-w/2)/1280,(y+h/2+22)/720,15)
text('Scan progress','DEMO-BILDAUSSCHNITTE WERDEN VORBEREITET ...',198,246,.04,.13,22)
text('Scan completed','4 FIKTIVE 3D-FIGUREN / DEMO-SCAN ABGESCHLOSSEN',246,274,.04,.13,22)
# Later simulated database write, using invented records only.
bar('Database panel',405,481,365,365,690,540,(.007,.019,.025))
text('Database title','DEMO-DATENBANK',405,481,.045,.84,32)
text('Database subtitle','Fiktive Scan-Datensaetze der 3D-Figuren',405,481,.045,.77,20,(.8,.85,.9,1))
for i in range(4):
f=410+i*10
portrait=seq.new_image('Invented face '+str(i),os.path.join(assets,'face_%02d.png'%i),channel=channel,frame_start=f);channel+=1;portrait.frame_final_duration=481-f
text('Record '+str(i),'ID: DEMO-%03d / GESPEICHERT'%(i+1),f,481,.11,.70-i*.11,23)
text('Fictional portrait '+str(i),'FIKTIVES GESICHT | 3D-DEMO',f,481,.11,.66-i*.11,15,(.75,.85,.85,1))
text('Write confirmation','SCHREIBVORGANG ABGESCHLOSSEN',451,481,.045,.22,22)
text('Database simulation notice','SIMULATION: erfundene Gesichter und IDs.',405,481,.045,.16,17,(.85,.85,.85,1))
s.render.image_settings.file_format='FFMPEG';s.render.ffmpeg.format='MPEG4';s.render.ffmpeg.codec='H264';s.render.ffmpeg.constant_rate_factor='HIGH';s.render.ffmpeg.audio_codec='AAC';s.render.ffmpeg.audio_bitrate=192
s.render.filepath=os.path.join(OUT,'halloween_cone_demo.mp4')
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'halloween_cone_demo.blend'))
bpy.ops.render.render(animation=True)
s.render.image_settings.file_format='PNG'
for f in [225,465]:
s.frame_set(f);s.render.filepath=os.path.join(OUT,'cone_demo_%03d.png'%f);bpy.ops.render.render(write_still=True)