Skip to content

Feature/rcr car render#1

Open
jamesknopp wants to merge 12 commits intomainfrom
feature/rcr-car-render
Open

Feature/rcr car render#1
jamesknopp wants to merge 12 commits intomainfrom
feature/rcr-car-render

Conversation

@jamesknopp
Copy link
Copy Markdown
Owner

No description provided.

jamesknopp and others added 12 commits April 13, 2026 18:56
Implements two render paths:

RenderRCRSprite: simple single-texture path (tyres/chwheel).
  Sprite B=U, A=V sampled directly into texture map.
  Transparency only when both U and V are zero.

RenderRCRCarSprite: GP3 masked multi-texture car render.
  Uses rcr1b segmentation mask to route each pixel:
    Mask 0     -> background (GP3 transparent)
    Mask 1     -> contact shadow (leave as background)
    Mask 2,6   -> chassis.bmp direct UV
    Mask 3     -> ferrari.bmp section 1 (rows 128-255), U mirrored
    Mask 4     -> ferrari.bmp section 1 (rows 128-255), direct UV
    Mask 5,7   -> ferrari.bmp section 2 (rows 256-383), direct UV
    Mask 8-11  -> tyre texture direct UV

ferrari.bmp layout (256x384): section 0=left side (unused by rcr1),
section 1=top/nose, section 2=right side.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add rcrMask: TBitmap field to TJamFile (pf8bit, index values 0-11)
- Add LoadRCRMask(maskPath) to load companion mask JAM and extract
  its raw canvas as a pf8bit indexed bitmap
- LoadFromFile auto-detects rcr?a pattern and loads rcr?b from the
  same directory automatically on RCR JAM open

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add btnRenderCar button to panel_RCR in mainform.dfm
- Add RCRRender to mainform uses clause
- Implement btnRenderCarClick handler:
  - Validates RCR JAM is loaded with mask and sprite planes
  - Resolves ferrari.bmp, chassis.bmp, tyre texture from JAM directory
  - Tries whbridg0/whgood0/whmich0/whpire0 tyre textures in order
  - Calls RenderRCRCarSprite with rcrB (U), rcrA (V) and rcrMask
  - Displays rendered result in ImageEntry preview

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add TRCRPreviewForm (RCRPreview.pas/dfm):
  - Game selection (GP3 / GP3 2000) using strGP3Location/strGP32kLocation
  - RCR angle selection (rcr1a-rcr5a), auto-populated from Gp3Jams\Main\
  - Livery selection, scanned from Gp3Jams\Main\ (excludes tyres/atlas/chassis)
  - Loads selected rcr?a.jam (auto-loads rcr?b mask alongside it)
  - Extracts full-canvas UV planes via ExtractRCRPlaneRaw
  - Calls RenderRCRCarSprite and displays result in scrollable preview

- Add TJamFile.ExtractRCRPlaneRaw(odd): extracts full 256xH pf8bit canvas
  from FRawData using correct per-entry X0/Y0 offsets (stride=512)

- Add RCRPreview + RCRRender to jamviewer.dproj

- Simplify btnRenderCarClick: opens TRCRPreviewForm with pre-selected
  angle matching currently loaded JAM

GP2 support to be handled separately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Liveries live in Gp3Jams\liveries\, not Gp3Jams\Main\.
Add GetLiveryDir separate from GetMainJamDir so that:
  RCR JAMs (rcr?a/b.jam)  -> Gp3Jams\Main\
  Livery BMPs, chassis, tyres -> Gp3Jams\liveries\

HW liveries (Gp3JamsH\liveries\) noted but not used here (SW render only).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Aligns with the existing TJamType definition in JamGeneral.pas.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
LoadRCRMask calls MaskJam.LoadFromFile which internally calls CheckIfRCR.
Since rcr?b is not in rcrJAMList, CheckIfRCR sets the global boolRcrJam=False,
overwriting the True set by the parent rcr?a load.

Fix: save boolRcrJam before the inner LoadFromFile and restore it in the
finally block so the parent's RCR state is always preserved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace BMP directory scanning with hardcoded livery name lists:
    GP3:      arrows98 benett98 ferrar98 jordan98 mclare98 minardi98
              prost98 sauber98 stewar98 tyrrel98 willia98
    GP3 2000: 1mclar00 2mclar00 arrows00 bar00 benett00 ferrar00
              jaguar00 jordan00 minardi00 prost00 sauber00 willia00
- Add LoadJamCanvas() helper: loads a JAM file and returns its
  originalCanvas as a TBitmap (caller owns it)
- Load livery from Gp3Jams\liveries\<name>.jam via LoadJamCanvas
- Load chassis from Gp3Jams\Main\chassis3.jam via LoadJamCanvas
- Tyre textures remain BMP files in Gp3Jams\liveries\

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace fixed-size const arrays cast to TArray<string> with inline
dynamic array literals in the case statement — no typecast needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Scan for wh*.jam (whbridg0, whgood0, whmich0, whpire0, whstre0, whyoko0)
in GetMainJamDir and load via LoadJamCanvas, matching chassis3.jam approach.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- LoadJamCanvas: render directly to pf24bit via FRawData + per-entry
  local palette (FPalettes) + gpxPal, bypassing VCL pf8bit->pf8bit
  Canvas.Draw which silently corrupts palette indices on remapping JAMs
- LoadRCRMask: assemble mask canvas from FEntries[i].FRawTexture at
  correct (X,Y) offsets instead of assuming linear FRawData layout;
  fixes rcr1b.jam which has 32 sprite entries at various positions
- Add JamPalette to RCRPreview uses clause for TLocalPaletteArray access

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant