#!/usr/bin/env python3 """ test_view.py -- offline smoke test: replay a captured FLYK run through the virtual board, then render one frame with vrview and save it as a PNG. python test_view.py [cap5.raw.bin] [frames_into_run] [out.png] `frames_into_run` picks how many 0x1d/draw messages to replay before rendering (the shark swims, so later = different pose). """ import os, sys, struct sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) os.environ.setdefault('SDL_VIDEODRIVER', 'dummy') # offscreen pygame from vrboard import VirtualBoard, Assembler from decode_anim import find_framed_start def main(): path = sys.argv[1] if len(sys.argv) > 1 else 'cap5.raw.bin' upto = int(sys.argv[2]) if len(sys.argv) > 2 else 600 out = sys.argv[3] if len(sys.argv) > 3 else 'flyk_live_render.png' data = open(path, 'rb').read() board = VirtualBoard() asm = Assembler(); asm.feed(data[find_framed_start(data):]) for m in asm: try: board.handle(m) except Exception as e: print('board error:', e) if board.frames >= upto: break print(f'replayed to frame {board.frames}: nodes={len(board.nodes)} ' f'uploads={len(board.uploads)} conns={len(board.conns)} anim={len(board.anim)}') from vrview import Renderer r = Renderer() r.draw(board) r.cache.maybe_rebuild(board) print(f'instances renderable: {len(r.cache.instances)}') print('cam chain:', [hex(h) for h in r.cache.cam_chain]) r.pygame.image.save(r.screen, out) print('wrote', out) if __name__ == '__main__': main()