#!/usr/bin/env python3 """Show OUR BTL4OPT arena (decoded by the friend's board from a captured wire stream) in a real on-screen window, orbiting a synthetic camera around it. Decode once, then orbit forever; close the window to stop.""" import os, sys, struct, math sys.path.insert(0, r'C:\VWE\TeslaRel410\dpl3-revive\patha') # real window (no SDL dummy) import numpy as np from vrboard import VirtualBoard, Assembler from decode_anim import find_framed_start from vrview import Renderer cap = sys.argv[1] if len(sys.argv) > 1 else r'C:\VWE\TeslaRel410\dpl3-revive\patha\bt8.raw.bin' upto = int(sys.argv[2]) if len(sys.argv) > 2 else 800 W, H = 720, 450 data = open(cap, 'rb').read() board = VirtualBoard() asm = Assembler(); asm.feed(data[find_framed_start(data):]) for m in asm: try: board.handle(m) except Exception: pass if board.frames >= upto: break print(f'decoded: nodes={len(board.nodes)} frames={board.frames}') W, H = 560, 350 r = Renderer(w=W, h=H, title='VWE pod - Division render (dpl3-revive) - our BTL4OPT arena') r.cache.maybe_rebuild(board) c = r.cache # aim at the mechs (anim_abs vehicle positions); ignore ones still at origin mechs = np.array([np.array(f[9:12]) for f in board.anim_abs.values()]) real = mechs[np.abs(mechs).sum(1) > 1.0] center = real.mean(0) if len(real) else np.zeros(3) radius = 480.0 # close orbit around the mech/dome cluster print(f'mechs={mechs.round(0).tolist()} target={center.round(1)} radius={radius}') # lift the far clip so the whole arena renders (yon = view float idx 13, off 52) if c.view is not None and c.view in board.nodes: vb = bytearray(board.nodes[c.view].get('body') or b'') if len(vb) >= 56: struct.pack_into('