Entry 389
Stream and desktop cameras are placed and projected in VU0's arithmetic: every view matrix is the game's bit for bit
Documented in The ALTIMIT desktop, In-engine streams.
This entry answers what was left open by The Audio screen's movies play as the desktop holds them: Movie 13's gate-in swirl draws, and Skeith's drain shows Kite and its backdrop.
Files14 in 7 directories
camera.rsview.rsanm.rsframes.rscrates/piney-desktop/tests/camera.rscamera_fixture.txtcrates/piney-stream/src/scene.rsdraw.rslib.rscrates/piney-stream/tests/stream.rstools/test_stream_rs.pydocs/engine/desktop.mdstream.mdUNKNOWNS.mdEntry 388 left one gap. The port drew stream cameras through
piney_desktop::camera::Camera::world_view, a glam inverse of
T(pos) Rz Ry Rx Rx(pi) with glam's sine. libvu0's _sceVu0ecossin
makes sine as sqrt(1 - cos^2), about 5e-5 off near 0. So stream 18's
steps 33 and 34 put world_screen 3.3e-4 of a column off the game's, and
the fixture's bound had been loosened to 4e-4. Scene::world_view_bits
had the game's camera arithmetic, but only the sort key and the test used
it.
What the game does
Every view the desktop and the streams draw through comes from
ccView::SetView (0x001052c0). It has three callers: PlaySceneMain, ccAnm::Draw
and the field's cameraSet.
- The camera.
DecodeF_Camera(0x0014ece0) turns the record's degrees into radians as(pi deg) / 180and callsccCam::SetMatrix_PosRotXYZ(0x001386b0). That is the unit matrix turned a half turn about x, then about x, y and z withsceVu0RotMatrixX/Y/Z, moved bysceVu0TransMatrix(xyz only), thensceVu0InversMatrix(0x001107b0).PlaySceneMainplaces the stream's camera again every frame withSetMatrix_PosRotXYZDebug(0x001385a0). That call is the same, with the stream's matrix (+0xc0, the unit matrix) multiplied in after the half turn. A record without a fov (flag 0x100) keeps the camera's own. - The projection.
SetViewdoes it all on the EE and VU0:scrz = 512 / (2 tanf((0.0174533 fov) / 2)), with newlib'stanf.ccSetViewScreenClipMatrix(0x00101f60) builds a scale-and-centre matrix. It holdsax,ay * screenAspect, the centre, andaz = (far near (zmax - zmin)) / (far - near).cz = (-zmax near + zmin far) / (far - near)uses amula.sand amadd.s, whose product is rounded before the add.- It
sceVu0MulMatrixes that with the distance matrix(scrz, scrz, z -> w, w -> z). world_screenis that view screen times the camera's matrix.
- The field, towns and battle go through
cameraSet:SetMatrix_PosTarget, then the sameSetView. The port already had both in VU0's arithmetic (piney_world::camera::pos_target,VIEW_SCREEN), andtools/test_world_rs.pyand the other camera harnesses check them bit for bit. Nothing else builds a view through glam.
Fix
piney_desktop::camerais now the game's arithmetic, in float bits:Cameraholds pos, rot (radians), fov andmatrix(ccCam.matrix).Camera::pos_rot_xyzisSetMatrix_PosRotXYZ,Camera::debug(m)isSetMatrix_PosRotXYZDebug, andCamera::decode(flag, values)isDecodeF_Camera.view_screen,screen_zandscreen_aspectare the EE's;world_screenisvu_mul(view_screen, matrix).- The glam
world_viewis gone.
Viewis built byView::new(projection, camera)andset_camera. It keeps theworld_screenthatSetViewmakes. The draw readsworld_screen_bits()and glam'sworld_screen()takes it from there.- Streams.
Scene::world_view_bitsandcamera_bitsare gone.Scene::cameraisDecodeF_Camera's camera, andScene::view_cameraisPlaySceneMain's debug placement. The draw, the sort key, the shadow view and the effects' camera (fx_camera'sworld_viewandworld_screen) all use it. - The desktop's
ccAnm.frames::camera_recordsgives the flag and the values as bits, andAnmdecodes them onto its camera. A flag-bit-0 record now changes nothing, as in the game, and a record without a fov keeps the camera's.
Checked
scenes_play_as_the_game_plays_them: every frame'sworld_screennow equals the game's bit for bit. That is all 1837 frames of streams 0, 106, 2, 15, 6 and 18. The fixture's%.9greads back exact. The old bounds were 4e-4 for glam and 1e-5 forworld_view_bits.tools/test_stream_rs.py cameras(new) runsSetFrame,SetMatrix_PosRotXYZandSetViewnatively in eemu and writescrates/piney-desktop/tests/camera_fixture.txt. It coversANM_xddcamerand 300 seeded cameras: near-zero turns, whole turns, records without a fov, and the default, letterbox and mail frames.cameras_place_and_project_as_the_game_smatches the camera matrix andworld_screenof all 301 bit for bit.default_view_screen_is_the_ee_s: the ported view screen at fov 45 equalspiney_world::camera::VIEW_SCREEN, the field's constant (scrz 0x441a827a, aspect 0x3f955555, az 0x4f00003f, cz 0xc4ffe07f).- The records. A one-off survey covered every F_Camera record in
Infection's streams and
DATA.BIN: 44089 records in 1089 files. All of them have flag 0. No record leaves out a value, so the game's stack leftovers for a missing position or turn never arise. - Shots. In
/mnt/data/claude/scratch/cam389, each before/after pair was compared by eye and by pixel diff.- Stream 18 frame 33 (
s18_f33_pair.png,s18_f33_diff.png): scattered single-pixel edge and texel changes from the sub-pixel camera move. The effects' streaks are the same in both. - The desktop after 200 frames (
desk_pair.png,desk_diff.png): at most 5 levels of gradient rounding. - The title's stream 0 frame 200: 25 pixels by 1.
- No golden image or pixel hash in the repo moved.
- Stream 18 frame 33 (
- piney-game's suite (four threads), the tests of piney-desktop,
piney-stream, piney-demo and piney-toppage, clippy on the touched crates,
fmt,
cairns checkandtools/docs.py checkpass.
nothing new from this entry. The model draws still
multiply world_screen by each object's lwMatrix in glam, where VU1
does it in its microcode; this entry covers only the view.
docs/engine/field-walk.md's note on ghoCam's markers is about object
matrices too. The console's own Movie 13 and 16 from the desktop (entry
- still need a PS2 or PCSX2 capture.