translated the remaining german notes, python comments, help and messages to english (in-game strings, parsed report lines and cli values stay german)
This commit is contained in:
1 parent
86fe26d786
commit
526f6072f6
36 files changed
+1553
-1544
No files matched your search
+18
-18
@@ -1,17 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Level-WAD -> OBJ (+MTL, Texturseiten-PNGs, Vorschaubilder).
|
||||
"""Level WAD -> OBJ (+MTL, texture page PNGs, preview images).
|
||||
|
||||
geom_export.py level.wad outdir [--collision] [--objects] [--no-png] [--size 1200x900]
|
||||
|
||||
Erzeugt in outdir:
|
||||
level.obj / level.mtl Weltgeometrie (TRAK-Kacheln, platziert nach MAP), mit UVs und
|
||||
Vertexfarben ("v x y z r g b"), ein OBJ-Objekt pro Kachel
|
||||
page_NN.png Texturseiten (256x256, aus TEXT)
|
||||
collision.obj (--collision) Kollisionspolygone, Gruppen nach Material
|
||||
objects.obj (--objects) statische STPC-Objektmodelle nebeneinander
|
||||
preview_top.png, preview_persp.png texturierte Software-Renderings zur Kontrolle
|
||||
Writes to outdir:
|
||||
level.obj / level.mtl world geometry (TRAK tiles, placed per MAP), with UVs and
|
||||
vertex colours ("v x y z r g b"), one OBJ object per tile
|
||||
page_NN.png texture pages (256x256, from TEXT)
|
||||
collision.obj (--collision) collision polygons, grouped by material
|
||||
objects.obj (--objects) static STPC object models side by side
|
||||
preview_top.png, preview_persp.png textured software renderings for checking
|
||||
|
||||
Koordinaten: Exportraum = MAP-Floats (y oben, rechtshaendig, z < 0). Spielraum = (x, y, -z).
|
||||
Coordinates: export space = MAP floats (y up, right-handed, z < 0). Game space = (x, y, -z).
|
||||
Format: notes/geometry.md
|
||||
"""
|
||||
import argparse
|
||||
@@ -27,7 +27,7 @@ import geomlib as G # noqa: E402
|
||||
|
||||
|
||||
def world_tris(trak, mp, texs, use_alt=False):
|
||||
"""Liefert Liste von Dreiecken: (P[3x3], UV[3x2], C[3x3] 0..1, page, texidx, tileidx)."""
|
||||
"""Returns a list of triangles: (P[3x3], UV[3x2], C[3x3] 0..1, page, texidx, tileidx)."""
|
||||
out = []
|
||||
for i in range(mp['N']):
|
||||
x, y, z, rot, mi, fl = mp['A'][i]
|
||||
@@ -57,13 +57,13 @@ def world_tris(trak, mp, texs, use_alt=False):
|
||||
|
||||
|
||||
def flat_color(t):
|
||||
# Flache Farbe (Texturflag Bit0): u0,u1,v0 = R,G,B (Renderer FUN_00556510)
|
||||
# flat colour (texture flag bit 0): u0,u1,v0 = R,G,B (Renderer FUN_00556510)
|
||||
return (t['u0'] / 255, t['u1'] / 255, t['v0'] / 255)
|
||||
|
||||
|
||||
def write_obj(path, tris, texs, mtlname):
|
||||
with open(path, 'w') as fo:
|
||||
fo.write('# Ein Koenigreich fuer ein Lama - Weltgeometrie (geom_export.py)\n')
|
||||
fo.write('# Ein Koenigreich fuer ein Lama - world geometry (geom_export.py)\n')
|
||||
fo.write(f'mtllib {mtlname}\n')
|
||||
vi = 1
|
||||
cur_tile = None
|
||||
@@ -96,7 +96,7 @@ def write_mtl(path, tris, texs, npages):
|
||||
fo.write(f'newmtl flat_{tex}\nKd %.3f %.3f %.3f\n\n' % c)
|
||||
|
||||
|
||||
# ------------------------------------------------------------ Software-Renderer
|
||||
# ------------------------------------------------------------ software renderer
|
||||
|
||||
def render(tris, pages, cam, size, path, texs):
|
||||
Wd, Hd = size
|
||||
@@ -134,7 +134,7 @@ def render(tris, pages, cam, size, path, texs):
|
||||
iz = w0 / cz[0] + w1 / cz[1] + w2 / cz[2]
|
||||
depth = 1 / np.where(inside, iz, 1e-9)
|
||||
sub = zb[y0:y1 + 1, x0:x1 + 1]
|
||||
# Farbe
|
||||
# colour
|
||||
nrm = np.cross(np.array(P[1]) - P[0], np.array(P[2]) - P[0])
|
||||
nl = np.linalg.norm(nrm)
|
||||
shade = 0.55 + 0.45 * abs(nrm @ L) / nl if nl > 0 else 1
|
||||
@@ -166,7 +166,7 @@ def main():
|
||||
ap.add_argument('wad'); ap.add_argument('outdir')
|
||||
ap.add_argument('--collision', action='store_true')
|
||||
ap.add_argument('--objects', action='store_true')
|
||||
ap.add_argument('--no-png', action='store_true', help='keine Seiten-PNGs/Vorschau')
|
||||
ap.add_argument('--no-png', action='store_true', help='no page PNGs/previews')
|
||||
ap.add_argument('--size', default='1200x900')
|
||||
a = ap.parse_args()
|
||||
os.makedirs(a.outdir, exist_ok=True)
|
||||
@@ -175,8 +175,8 @@ def main():
|
||||
tris = world_tris(trak, mp, texs)
|
||||
write_obj(os.path.join(a.outdir, 'level.obj'), tris, texs, 'level.mtl')
|
||||
write_mtl(os.path.join(a.outdir, 'level.mtl'), tris, texs, len(pages))
|
||||
print(f'{a.wad}: WFPC={wf:#x} TRAK-Modelle={len(trak)} Kacheln={mp["N"]} Raster={mp["W"]}x{mp["H"]} '
|
||||
f'Dreiecke={len(tris)} Texturen={len(texs)} Seiten={len(pages)}')
|
||||
print(f'{a.wad}: WFPC={wf:#x} TRAK models={len(trak)} tiles={mp["N"]} grid={mp["W"]}x{mp["H"]} '
|
||||
f'triangles={len(tris)} textures={len(texs)} pages={len(pages)}')
|
||||
|
||||
if a.collision:
|
||||
with open(os.path.join(a.outdir, 'collision.obj'), 'w') as fo:
|
||||
@@ -233,7 +233,7 @@ def main():
|
||||
P = np.array([p for t in tris for p in t[0]])
|
||||
lo, hi = P.min(0), P.max(0); c = (lo + hi) / 2
|
||||
ext = max(hi[0] - lo[0], hi[2] - lo[2])
|
||||
# Draufsicht (fast senkrecht, Norden = -z oben)
|
||||
# top view (almost vertical, north = -z at the top)
|
||||
render(tris, imgs, ((c[0], hi[1] + ext * 1.2, c[2] + 0.01), (c[0], lo[1], c[2]), 50), size,
|
||||
os.path.join(a.outdir, 'preview_top.png'), texs)
|
||||
render(tris, imgs, ((c[0] + ext * 0.35, hi[1] + ext * 0.45, hi[2] + ext * 0.45), tuple(c), 60), size,
|
||||
|
||||
Reference in new issue
Block a user