Files
TeslaRel410/emulator/render-bridge/cam_debug.py
T
CydandClaude Fable 5 0f5b2e28da Renderer: vendor live-bridge scripts; GPU backend unblocked (60fps)
- emulator/render-bridge/: the pod->Dave's-renderer live bridge (rescued
  from session scratchpad): live_bridge.py (first-person cam from the 0x1f
  pose, arrow-key eye-height trim), fp/chase offline renders, fifobridge,
  diagnostics, gauge_arena[_sound].conf, and launch_pod.ps1 (one-command
  pod+bridge restart: pentapus VPX_EXPLODE + AWE32 sound + GL bridge).
- _backend.py: renderer selection -- vrview_gl.GLRenderer (moderngl) by
  default, VRVIEW_SOFT=1 for the software reference; backend-agnostic
  frame save via last_frame.
- GPU backend runs on side-by-side CPython 3.13 (moderngl/glcontext cp313
  wheels; no MSVC needed): 63fps headless / 60.7 windowed vs 21fps software
  on the same scene, and the GL path also draws the vertex-alpha cloud dome.
- vrview.py: VRVIEW_GAMMA env selects DAC gamma (1.25 live-renderer legacy
  vs 1.7 per the original GAMMA.C) for A/B against the real pod.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 13:34:02 -05:00

49 lines
1.7 KiB
Python

import os, sys, struct
sys.path.insert(0, r'C:\VWE\TeslaRel410\dpl3-revive\patha')
os.environ.setdefault('SDL_VIDEODRIVER', 'dummy')
import numpy as np
from vrboard import VirtualBoard, Msg, A
from vrview import Renderer
data = open(sys.argv[1], 'rb').read()
board = VirtualBoard()
off = 0
while off + 8 <= len(data):
if data[off:off + 4] != b'VPXM':
off += 1; continue
ln = struct.unpack_from('<I', data, off + 4)[0]
body = data[off + 8:off + 8 + ln]; off += 8 + ln
if len(body) >= 4:
a = struct.unpack_from('<I', body, 0)[0]
if a < 0x100:
try: board.handle(Msg(False, 0xff, a, body[4:]))
except Exception: pass
r = Renderer(w=832, h=512)
c = r.cache; c.maybe_rebuild(board)
print('munga', board.munga, 'view', hex(c.view) if c.view else None,
'cam_chain', [hex(h) for h in c.cam_chain])
np.set_printoptions(suppress=True)
try:
cam = r.cam_matrix(board)
print('DAVE cam eye', cam[3, :3].round(1),
'back(+z)row', cam[2, :3].round(3), '(camera looks -back)')
except Exception as e:
print('DAVE cam err', e)
# geometry world centroid + bounds
pts = []
for inst in c.instances:
M = r.chain_matrix(board, inst['chain'])
if np.all(np.isfinite(M[3, :3])): pts.append(M[3, :3])
pts = np.array(pts)
print('GEOM centroid', pts.mean(0).round(1),
'min', pts.min(0).round(1), 'max', pts.max(0).round(1))
# the animated vehicle poses (0x1f) -- the player camera should be one of these
print('anim_abs vehicles:', len(board.anim_abs))
for h, f in list(board.anim_abs.items()):
R = np.array(f[:9]).reshape(3, 3); t = np.array(f[9:12])
print(' veh', hex(h), 'pos', t.round(1),
'Zrow', R[2].round(3), 'is_cam_chain', h in c.cam_chain)