mirror of
https://github.com/isledecomp/isle.git
synced 2026-02-15 17:17:38 +00:00
Add Kaitai Struct definition for texture data files (.tex) (#1741)
This commit is contained in:
parent
464e59df3e
commit
2dfc4b72ab
@ -21,6 +21,7 @@ Kaitai Struct allows you to define binary formats in a YAML-based `.ksy` file, w
|
||||
| [`animation.ksy`](/docs/animation.ksy) | `.ani` | Animation data (keyframes, actor references, camera animation) |
|
||||
| [`wdb.ksy`](/docs/wdb.ksy) | `.wdb` | World database (textures, parts, models, ROI hierarchies, LODs) |
|
||||
| [`dta.ksy`](/docs/dta.ksy) | `.dta` | Animation data (world animation info, model placement) |
|
||||
| [`tex.ksy`](/docs/tex.ksy) | `.tex` | Texture data (named textures with palette and pixel data) |
|
||||
|
||||
## Using the Tools
|
||||
|
||||
@ -50,6 +51,9 @@ ksv /path/to/lego/data/world.wdb wdb.ksy
|
||||
|
||||
# View an animation data file
|
||||
ksv samples/BLDRINF.DTA dta.ksy
|
||||
|
||||
# View a texture data file
|
||||
ksv samples/Dbfrfn.tex tex.ksy
|
||||
```
|
||||
|
||||
### Kaitai Struct Dump (ksdump)
|
||||
@ -74,6 +78,9 @@ ksdump --format yaml /path/to/lego/data/world.wdb wdb.ksy
|
||||
|
||||
# Dump an animation data file to JSON
|
||||
ksdump --format json samples/BLDRINF.DTA dta.ksy
|
||||
|
||||
# Dump a texture data file to JSON
|
||||
ksdump --format json samples/Dbfrfn.tex tex.ksy
|
||||
```
|
||||
|
||||
## Sample Files
|
||||
@ -84,5 +91,6 @@ The [`samples/`](/docs/samples/) directory contains example files for testing:
|
||||
- `History.gsi` - Sample score history data
|
||||
- `pns065rd.ani` - Sample animation file
|
||||
- `BLDRINF.DTA` - Sample animation data file
|
||||
- `Dbfrfn.tex` - Sample texture data file (dune buggy front fender)
|
||||
|
||||
Note: The world database (`world.wdb`) can be found in your LEGO Island installation at `lego/data/world.wdb`.
|
||||
|
||||
BIN
docs/samples/Dbfrfn.tex
Executable file
BIN
docs/samples/Dbfrfn.tex
Executable file
Binary file not shown.
91
docs/tex.ksy
Normal file
91
docs/tex.ksy
Normal file
@ -0,0 +1,91 @@
|
||||
meta:
|
||||
id: tex
|
||||
title: Texture Data File
|
||||
application: LEGO Island
|
||||
file-extension: tex
|
||||
license: CC0-1.0
|
||||
endian: le
|
||||
|
||||
doc: |
|
||||
Texture data format for LEGO Island (1997). Contains one or more named
|
||||
textures with 8-bit indexed color image data.
|
||||
|
||||
Texture data is embedded in SI (Interleaf) container files and parsed by
|
||||
LegoTexturePresenter::Read(). Each texture consists of a length-prefixed
|
||||
name followed by image data with a color palette and pixel indices.
|
||||
|
||||
The image format is shared with the world database (world.wdb) texture
|
||||
data, using the same LegoImage and LegoPaletteEntry serialization.
|
||||
|
||||
File structure:
|
||||
1. Texture count
|
||||
2. Named texture entries - name + palette + pixel data
|
||||
|
||||
seq:
|
||||
- id: num_textures
|
||||
type: u4
|
||||
doc: Number of textures in this file.
|
||||
- id: textures
|
||||
type: named_texture
|
||||
repeat: expr
|
||||
repeat-expr: num_textures
|
||||
doc: Array of named textures.
|
||||
|
||||
types:
|
||||
named_texture:
|
||||
doc: |
|
||||
A named texture with 8-bit indexed color image data.
|
||||
seq:
|
||||
- id: name_length
|
||||
type: u4
|
||||
doc: Length of the texture name buffer in bytes.
|
||||
- id: name
|
||||
type: str
|
||||
size: name_length
|
||||
encoding: ASCII
|
||||
terminator: 0
|
||||
doc: |
|
||||
Texture name (e.g., "dbfrfn.gif"). The name is a null-terminated
|
||||
C string within the allocated buffer. Bytes after the null
|
||||
terminator are unused padding and consumed but not included
|
||||
in the string value.
|
||||
- id: image
|
||||
type: image
|
||||
doc: The texture image data.
|
||||
|
||||
image:
|
||||
doc: |
|
||||
An 8-bit indexed color image with palette. Parsed by LegoImage::Read().
|
||||
seq:
|
||||
- id: width
|
||||
type: u4
|
||||
doc: Image width in pixels.
|
||||
- id: height
|
||||
type: u4
|
||||
doc: Image height in pixels.
|
||||
- id: palette_size
|
||||
type: u4
|
||||
doc: Number of entries in the color palette (max 256).
|
||||
- id: palette
|
||||
type: palette_entry
|
||||
repeat: expr
|
||||
repeat-expr: palette_size
|
||||
doc: Color palette entries.
|
||||
- id: pixels
|
||||
size: width * height
|
||||
doc: |
|
||||
Pixel data as palette indices. Each byte is an index into
|
||||
the palette array.
|
||||
|
||||
palette_entry:
|
||||
doc: RGB color palette entry. Parsed by LegoPaletteEntry::Read().
|
||||
seq:
|
||||
- id: red
|
||||
type: u1
|
||||
doc: Red component (0-255).
|
||||
- id: green
|
||||
type: u1
|
||||
doc: Green component (0-255).
|
||||
- id: blue
|
||||
type: u1
|
||||
doc: Blue component (0-255).
|
||||
Loading…
Reference in New Issue
Block a user