Nine tracks get the console's own map, and the projection is corrected
RPConfig.xml has always named a picture for nine of the eighteen tracks. The pictures exist after all, so the page reads the mapping straight out of the config and uses them: score zones, drop zone, the chambers drawn properly and labelled. No reconstruction beats the real thing. The other nine keep the course traced from their gates, and each card now says which of the two it is showing. The pictures also check the reconstruction. Brewer's Bane is the one track shaped distinctively enough to be obviously wrong, and it matches the console picture turn for turn - long leg up one side to Score Zone 1, the corner, the run out to Score Zone 2, junction chambers spaced along it. It matched MIRRORED. Seen from above with +Z up the page the engine's +X runs to the left, and every plan here had been drawn the other way round. Fixed, so the nine tracks without a picture are drawn the same way round as the nine with one.
This commit is contained in:
+45
-26
File diff suppressed because one or more lines are too long
+64
-10
@@ -7,7 +7,7 @@ stride, so the scenery placements ARE the map, seen from above.
|
||||
Usage: build_tracks.py <rpl4tool-listing.txt> <out.html>
|
||||
"""
|
||||
import base64, html, io, os, re, struct, sys
|
||||
from PIL import Image, ImageDraw
|
||||
from PIL import Image, ImageDraw, ImageOps
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import navmap
|
||||
@@ -47,10 +47,16 @@ def resource_table():
|
||||
TABLE = resource_table()
|
||||
|
||||
# ------------------------------------------------------------ the console
|
||||
CONSOLE = {}
|
||||
CONSOLE, CONSOLE_ART = {}, {}
|
||||
xml = open(ROOT + '/tools/console-config/RPConfig.xml', encoding='utf-8-sig').read()
|
||||
for m in re.finditer(r'<map\s+key="([^"]+)"\s+name="([^"]+)"', xml):
|
||||
for m in re.finditer(r'<map\s+key="([^"]+)"\s+name="([^"]+)"'
|
||||
r'(?:\s+image="([^"]*)")?', xml):
|
||||
CONSOLE[m.group(1)] = m.group(2)
|
||||
if m.group(3):
|
||||
# The config names the picture; the picture itself now sits in
|
||||
# assets/. Take the mapping from the config rather than matching
|
||||
# filenames to track names by eye.
|
||||
CONSOLE_ART[m.group(1)] = os.path.basename(m.group(3).replace('\\', '/'))
|
||||
|
||||
# What the game actually offers, read from the front end's own catalogs so
|
||||
# this page cannot drift from the menu.
|
||||
@@ -86,6 +92,36 @@ def era(key):
|
||||
GAUGE_IDS = {rid for rid, r in TABLE.items() if r['desc'].endswith(': GaugeImage')}
|
||||
|
||||
|
||||
ART_DIR = os.path.join(ROOT, 'assets', 'red planet maps')
|
||||
|
||||
|
||||
def console_plan(filename, box=900):
|
||||
"""The console's own picture of the track, as an alpha mask.
|
||||
|
||||
These are the pictures the setup console showed, and they are the real
|
||||
maps - score zones, drop zone, the chambers drawn properly and labelled.
|
||||
Nine of the eighteen tracks have one. Where there is one it beats any
|
||||
reconstruction, so it wins. Greyscale line art on white, so inverting
|
||||
luminance to alpha lets the page tint it like every other plan and keeps
|
||||
it readable in both themes."""
|
||||
path = os.path.join(ART_DIR, filename)
|
||||
if not os.path.exists(path):
|
||||
return None
|
||||
im = ImageOps.invert(Image.open(path).convert('L'))
|
||||
box_ = im.getbbox()
|
||||
if box_:
|
||||
im = im.crop(box_)
|
||||
if max(im.size) > box:
|
||||
k = box / max(im.size)
|
||||
im = im.resize((max(1, int(im.width * k)), max(1, int(im.height * k))),
|
||||
Image.LANCZOS)
|
||||
out = Image.merge('RGBA', (Image.new('L', im.size, 255),) * 3 + (im,))
|
||||
buf = io.BytesIO()
|
||||
out.save(buf, 'PNG', optimize=True)
|
||||
return ('data:image/png;base64,' + base64.b64encode(buf.getvalue()).decode(),
|
||||
im.width, im.height)
|
||||
|
||||
|
||||
def plan_view(segs, box=520, flat=False):
|
||||
"""The course, straight down, as an alpha mask. `flat` for the route
|
||||
chains, which are (x, z) pairs rather than (x, y, z) world points."""
|
||||
@@ -99,8 +135,15 @@ def plan_view(segs, box=520, flat=False):
|
||||
ih = max(8, int(h * scale) + 20)
|
||||
img = Image.new('L', (iw, ih), 0)
|
||||
dr = ImageDraw.Draw(img)
|
||||
# X runs left, not right. Seen from above with +Z up the page, the
|
||||
# engine's +X goes to the LEFT - drawn the other way every plan came out
|
||||
# mirrored. The console's own picture of Brewer's Bane settles it: its
|
||||
# long leg runs up the right side to Score Zone 1, turns at the corner
|
||||
# and runs left to Score Zone 2, which is this projection and not its
|
||||
# mirror. The nine tracks the console never had a picture of are drawn
|
||||
# the same way round as the nine it did.
|
||||
for seg in segs:
|
||||
xy = [(10 + (p[0] - min(xs)) * scale,
|
||||
xy = [(10 + (max(xs) - p[0]) * scale,
|
||||
ih - 10 - ((p[1] if flat else p[2]) - min(zs)) * scale)
|
||||
for p in seg]
|
||||
if len(xy) > 1:
|
||||
@@ -144,13 +187,17 @@ for key, t in tracks.items():
|
||||
if pts:
|
||||
xs = [p[0] for p in pts]; ys = [p[1] for p in pts]; zs = [p[2] for p in pts]
|
||||
t['extent'] = (max(xs) - min(xs), max(ys) - min(ys), max(zs) - min(zs))
|
||||
if t['kind'] == 'route' and chains:
|
||||
t['art'], t['aw'], t['ah'] = plan_view(chains, flat=True)
|
||||
else:
|
||||
t['art'], t['aw'], t['ah'] = plan_view(segs)
|
||||
shown = console_plan(CONSOLE_ART[key]) if key in CONSOLE_ART else None
|
||||
t['source'] = 'console'
|
||||
if shown is None:
|
||||
t['source'] = 'route' if (t['kind'] == 'route' and chains) else 'blocks'
|
||||
shown = (plan_view(chains, flat=True) if t['source'] == 'route'
|
||||
else plan_view(segs))
|
||||
t['art'], t['aw'], t['ah'] = shown
|
||||
else:
|
||||
t['extent'] = (0, 0, 0)
|
||||
t['art'] = None
|
||||
t['source'] = 'none'
|
||||
|
||||
# Tracks with identical footprints are almost certainly one built from the
|
||||
# other; say so rather than leaving the reader to notice.
|
||||
@@ -185,9 +232,16 @@ for key in ORDER:
|
||||
short = ('<p class="twin">%d of %d placements are drawn; the rest carry no '
|
||||
'map art or stand alone off the course</p>'
|
||||
% (t['drawn'], t['instances'])) if t['skipped'] else ''
|
||||
SOURCE = {
|
||||
'console': 'The console’s own map',
|
||||
'route': 'Course traced from the gates',
|
||||
'blocks': 'Wall blocks — no single course to trace',
|
||||
}
|
||||
art = ('<figcaption class="plan__src">%s</figcaption>' % SOURCE[t['source']]
|
||||
) if t['art'] else ''
|
||||
art = ('<span class="plan__img" role="img" aria-label="%s plan view" '
|
||||
'style="--art:url(%s);--ar:%d/%d"></span>'
|
||||
% (html.escape(t['name']), t['art'], t['aw'], t['ah'])) if t['art'] else ''
|
||||
'style="--art:url(%s);--ar:%d/%d"></span>%s'
|
||||
% (html.escape(t['name']), t['art'], t['aw'], t['ah'], art)) if t['art'] else ''
|
||||
cards.append("""
|
||||
<article class="trk" data-tags="{tags}" data-search="{search}">
|
||||
<figure class="plan">{art}</figure>
|
||||
|
||||
+13
-2
@@ -104,9 +104,20 @@ h1 em { font-style: normal; color: var(--sys); }
|
||||
.trk { background: var(--panel); padding: 1.1rem 1.25rem 1.25rem; }
|
||||
.trk[hidden] { display: none; }
|
||||
|
||||
.plan { margin: 0 0 1rem; display: flex; justify-content: center; }
|
||||
.plan {
|
||||
margin: 0 0 1rem; display: flex; flex-direction: column;
|
||||
align-items: center; gap: .5rem;
|
||||
}
|
||||
.plan__src {
|
||||
font: 500 var(--step--1)/1 var(--mono); letter-spacing: .1em;
|
||||
text-transform: uppercase; color: var(--ink-low); text-align: center;
|
||||
}
|
||||
.plan__img {
|
||||
display: block; width: 100%; max-width: 15rem; aspect-ratio: var(--ar);
|
||||
/* The mask is drawn with contain, so clamping the box letterboxes the
|
||||
art rather than stretching it - a portrait console map stays legible
|
||||
beside a squat arena. */
|
||||
display: block; width: 100%; max-width: 15rem; max-height: 22rem;
|
||||
aspect-ratio: var(--ar);
|
||||
background-color: var(--ink-mid);
|
||||
-webkit-mask-image: var(--art); mask-image: var(--art);
|
||||
-webkit-mask-size: contain; mask-size: contain;
|
||||
|
||||
+14
-6
@@ -8,12 +8,12 @@
|
||||
<div class="wrap">
|
||||
<p class="eyebrow">Red Planet 4.12 · plans drawn from RPL4.RES</p>
|
||||
<h1>Every track,<br><em>seen from above</em></h1>
|
||||
<p class="lede">There are no track maps in the game's files — the console had
|
||||
pictures of them and those pictures did not survive. But the track itself knows
|
||||
where it goes. Almost every one is built from a single piece repeated: a wall
|
||||
thrown across the route with a gate in the middle. <strong>These plans are the
|
||||
course those gates describe</strong> — every gate is a point the race passes
|
||||
through, walked in the order the course visits them.</p>
|
||||
<p class="lede">There are no track maps in the game's files. Nine of these are the
|
||||
next best thing: <strong>the setup console's own pictures</strong>, score zones and
|
||||
drop zone labelled, recovered and shown here as they were drawn. The other nine
|
||||
never had one — so their plan comes from the track itself. Almost every track
|
||||
is a single piece repeated, a wall thrown across the route with a gate in the
|
||||
middle, and <strong>every gate is a point the race passes through</strong>.</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -70,6 +70,14 @@
|
||||
obstacles gives it four or more. Seventeen tracks score 1 or 2 and are drawn as a
|
||||
course. The large arena scores 8 on an exact 100 unit grid, so it keeps its wall blocks
|
||||
instead — and the small arena, which scores 2, really is the maze it looks like.</p>
|
||||
<p class="foot">The console's nine pictures also check the other nine. Brewer's Bane is
|
||||
the one track with a shape distinctive enough to be wrong in an obvious way, and the
|
||||
reconstruction matches the picture turn for turn — long leg up one side to Score
|
||||
Zone 1, the corner, the run out to Score Zone 2, junction chambers spaced along it. It
|
||||
matched mirrored, which is how the projection came to be corrected: seen from above
|
||||
with +Z up the page the engine's +X runs to the <em>left</em>, and every plan here had
|
||||
been drawn the other way round. The tracks with no picture are now drawn the same way
|
||||
round as the tracks with one.</p>
|
||||
<p class="foot">There is still no driving surface anywhere in the file: the track is
|
||||
walls and gates, never tarmac. Extent and relief are the span of the placed geometry in
|
||||
world units, so a long thin plan is a point-to-point canyon run — most of the
|
||||
|
||||
Reference in New Issue
Block a user