"""Photograph the exact COMPANION + VECTOR configuration in ALTO."""
import bpy,math
from pathlib import Path
from mathutils import Vector
ROOT=Path(__file__).resolve().parent.parent
bpy.ops.wm.open_mainfile(filepath=str(ROOT/'modeling/mezzo-studio.blend'))
s=bpy.context.scene
with bpy.data.libraries.load(str(ROOT/'modeling/cartridge-library.blend'),link=False) as (available,loaded):
    loaded.objects=available.objects
g=next(ob for ob in loaded.objects if ob and ob.name=='cartridge_companion')
for ob in [g]+list(g.children_recursive):s.collection.objects.link(ob)
g.location=(8.46,7.3,4.04196)
bpy.data.objects['cartridge_compute'].location.y=11.1
for slot in (1,2):
    for side,sign in (('front',-1),('rear',1)):bpy.data.objects[f'bay_0{slot}_door_'+side].rotation_euler.x=sign*math.pi/2
s.render.threads_mode='FIXED';s.render.threads=8
s.render.resolution_x=1600;s.render.resolution_y=1200;s.cycles.samples=48
floor=bpy.data.materials['Studio / floor finish'].node_tree.nodes.get('Principled BSDF')
floor.inputs['Base Color'].default_value=(.023,.031,.024,1)
c=s.camera;c.location=(39,-45,55);c.rotation_euler=(Vector((0,0,4))-c.location).to_track_quat('-Z','Y').to_euler();c.data.ortho_scale=59
s.render.filepath=str(ROOT/'public/images/mezzo-companion.png');bpy.ops.render.render(write_still=True)
