mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 06:12:41 +01:00
docs: the EU07M model format spec in English
The spec of docs/eu07m-format.md was written in Polish, after docs/world-format-eu07.md. It is translated whole, with the state of the format brought up to date and a section on the channels added. No change to the format itself.
This commit is contained in:
+277
-255
@@ -1,320 +1,342 @@
|
||||
# Format modeli EU07M (`.eu07m`)
|
||||
# The EU07M model format (`.eu07m`)
|
||||
|
||||
Następca E3D: w pełni binarny format modeli. Plik czyta się prawie bez przetwarzania, prosto do buforów OpenGL 4.6 i
|
||||
Vulkana 1.4. Niesie węzły TRS, skinning, typowane komponenty i metadane węzłów oraz grup wierzchołków. Rozszerza się bez
|
||||
podnoszenia wersji. Rekordy, rozmiary i offsety są w `model/eu07m/eu07m_format.h`, a `static_assert` pilnują, żeby kod i ten
|
||||
opis się nie rozjechały.
|
||||
The successor of E3D: a fully binary model format. A file is read with almost no processing, straight into the buffers of OpenGL
|
||||
4.6 and Vulkan 1.4. It carries TRS nodes, skinning, typed components and metadata of nodes and vertex groups, and it extends without
|
||||
raising its version. The records, their sizes and offsets are in `model/eu07m/eu07m_format.h`, where `static_assert`s keep the code
|
||||
and this description from drifting apart.
|
||||
|
||||
Stan: wersja 1.0. Format, czytnik, pisarz i konwersja z E3D/T3D (etap 1), wczytywanie w grze za przełącznikiem (etap 2),
|
||||
strumienie kompaktowe w rendererze Vulkan (etap 3, sekcja „W grze”).
|
||||
State: version 1.0. The format, its reader, writer and the conversion from E3D/T3D (stage 1); the loading in the game behind a
|
||||
switch (stage 2); the compact streams in the Vulkan renderer (stage 3); the instancing of models with lights (stage 5); skinning
|
||||
(stage 4); animation clips and channels (stage 8). See "In the game".
|
||||
|
||||
## Zasady
|
||||
## Principles
|
||||
|
||||
- **Little-endian.** Rekordy leżą w pliku tak, jak w pamięci, i tak trafiają do GPU.
|
||||
- **Spis sekcji (TOC).** Każdą sekcję znajduje się przez spis, a nie przez przejście po kolejnych kawałkach. Czytnik może
|
||||
wziąć tylko te sekcje, których potrzebuje.
|
||||
- **Tablice z `stride`.** Sekcja z rekordami zaczyna się od `count` i `stride`. Nowa wersja dopisuje pola na końcu
|
||||
rekordu: stary czytnik bierze znany prefiks, a nowy daje brakującym polom wartości domyślne.
|
||||
- **Sekcje wymagane i opcjonalne.** Nieznaną sekcję opcjonalną czytnik pomija, a narzędzia przenoszą ją bez zmian.
|
||||
Nieznana sekcja wymagana sprawia, że plik jest odrzucany z czytelnym komunikatem.
|
||||
- **Wersja.** Wersja główna zmienia się tylko przy zmianie niezgodnej; czytnik odrzuca plik o wyższej wersji głównej.
|
||||
Wersja poboczna oznacza nowe pola i sekcje, które starszy czytnik pomija.
|
||||
- **Plik to dane niezaufane.** Czytnik sprawdza każdy offset, rozmiar, indeks, rodzica, joint i odwołanie, zanim
|
||||
cokolwiek zostanie użyte (`eu07m::validate`).
|
||||
- **Semantyka w danych, nie w nazwach.** Role, strony pojazdu, warianty i sloty świateł są polami komponentów. Nazwy
|
||||
zostają, żeby dzisiejsze `.mmd` i eventy działały bez zmian.
|
||||
- **Little-endian.** The records lie in the file as they lie in memory, and go to the GPU that way.
|
||||
- **A table of sections (TOC).** Every section is found through the table, not by walking chunk after chunk. A reader may take
|
||||
only the sections it needs.
|
||||
- **Tables with a `stride`.** A section of records starts with `count` and `stride`. A new version adds fields at the end of a
|
||||
record: an old reader takes the prefix it knows, a new one gives the missing fields their defaults.
|
||||
- **Required and optional sections.** A reader skips an optional section it doesn't know, and the tools carry it over unchanged.
|
||||
An unknown required section makes the file refused, with a readable message.
|
||||
- **Version.** The major version changes only with an incompatible change; a reader refuses a file of a higher major version.
|
||||
The minor version marks new fields and sections, which an older reader skips.
|
||||
- **A file is untrusted data.** The reader checks every offset, size, index, parent, joint and reference before anything is used
|
||||
(`eu07m::validate`).
|
||||
- **Meaning in the data, not in the names.** Roles, the ends of a vehicle, variants and light slots are fields of components. The
|
||||
names stay, so the `.mmd` files and the events of today work unchanged.
|
||||
|
||||
## Nagłówek (64 B)
|
||||
## Header (64 B)
|
||||
|
||||
| Offset | Typ | Pole |
|
||||
| Offset | Type | Field |
|
||||
|---|---|---|
|
||||
| 0 | char × 4 | magic `EU7M`, nazwa formatu w czterech bajtach |
|
||||
| 4 | u16 × 2 | wersja główna (1), poboczna (0) |
|
||||
| 8 | u32 | flagi: bit 0 = kolejność indeksów zoptymalizowana |
|
||||
| 12 | u32 | liczba sekcji |
|
||||
| 16 | u64 | offset spisu sekcji |
|
||||
| 24 | u64 | rozmiar pliku |
|
||||
| 32 | u64 | FNV-1a 64 bajtów od offsetu 64 do końca pliku |
|
||||
| 40 | u64 | hash pliku źródłowego (eksporter i konwerter wiedzą, kiedy budować od nowa) |
|
||||
| 48 | 16 B | zarezerwowane, zera |
|
||||
| 0 | char × 4 | magic `EU7M`, the name of the format in four bytes |
|
||||
| 4 | u16 × 2 | major version (1), minor version (0) |
|
||||
| 8 | u32 | flags: bit 0 = the index order was optimised |
|
||||
| 12 | u32 | section count |
|
||||
| 16 | u64 | offset of the table of sections |
|
||||
| 24 | u64 | file size |
|
||||
| 32 | u64 | FNV-1a 64 of the bytes from offset 64 to the end of the file |
|
||||
| 40 | u64 | hash of the source file (the exporter and the converter know when to build again) |
|
||||
| 48 | 16 B | reserved, zeroes |
|
||||
|
||||
## Wpis spisu sekcji (32 B)
|
||||
## Entry of the table of sections (32 B)
|
||||
|
||||
| Typ | Pole |
|
||||
| Type | Field |
|
||||
|---|---|
|
||||
| u32 | FourCC |
|
||||
| u32 | flagi: bit 0 = wymagana, bit 1 = zstd, bit 2 = kodek meshoptimizer (tylko strumienie wierzchołków i indeksów) |
|
||||
| u64 | offset w pliku |
|
||||
| u64 | rozmiar w pliku |
|
||||
| u64 | rozmiar po rozpakowaniu |
|
||||
| u32 | flags: bit 0 = required, bit 1 = zstd, bit 2 = meshoptimizer codec (vertex and index streams only) |
|
||||
| u64 | offset in the file |
|
||||
| u64 | size in the file |
|
||||
| u64 | size unpacked |
|
||||
|
||||
Sekcje są wyrównane do 16 B, a strumienie wierzchołków i indeksów do 64 B. Sekcja może być skompresowana zstd. Każda
|
||||
sekcja występuje najwyżej raz.
|
||||
Sections are aligned to 16 B, the vertex and index streams to 64 B. A section may be compressed with zstd. Each section appears at
|
||||
most once.
|
||||
|
||||
Strumienie wierzchołków (`VPOS`, `VATT`, `VSKN`, `VSKW`, `VUSR`, `VBND`) mogą być zapisane kodekiem wierzchołków
|
||||
meshoptimizera (wersja 1), a strumienie indeksów (`IDX2`, `IDX4`) jego kodekiem sekwencji indeksów (`ref/meshoptimizer`,
|
||||
licencja MIT). Kodek jest bezstratny co do bajtu, a rozpakowuje się kilka razy szybciej niż zstd na tych danych. Gdy sekcja ma
|
||||
obie flagi, zstd pakuje wynik kodeka; czytnik najpierw rozpakowuje zstd (najwyżej do granicy rozmiaru kodeka), potem dekoduje.
|
||||
Rozmiar po rozpakowaniu we wpisie spisu to zawsze rozmiar surowego strumienia. Flaga kodeka na innej sekcji odrzuca plik.
|
||||
The vertex streams (`VPOS`, `VATT`, `VSKN`, `VSKW`, `VUSR`, `VBND`) may be stored in the vertex codec of meshoptimizer (version 1),
|
||||
the index streams (`IDX2`, `IDX4`) in its index sequence codec (`ref/meshoptimizer`, MIT licence). The codec is lossless to the
|
||||
byte and unpacks several times faster than zstd on this data. When a section has both flags, zstd packs the output of the codec;
|
||||
the reader first unpacks zstd (at most to the bound of the codec size), then decodes. The unpacked size in the table entry is
|
||||
always the size of the raw stream. The codec flag on any other section refuses the file.
|
||||
|
||||
## Sekcje
|
||||
## Sections
|
||||
|
||||
`[T]` oznacza tablicę: `u32 count`, `u32 stride`, potem `count` rekordów co `stride` bajtów. `[S]` oznacza surowy
|
||||
strumień bez nagłówka: liczba elementów to rozmiar sekcji podzielony przez rozmiar elementu.
|
||||
`[T]` marks a table: `u32 count`, `u32 stride`, then `count` records of `stride` bytes. `[S]` marks a raw stream without a header:
|
||||
the element count is the section size divided by the element size.
|
||||
|
||||
| FourCC | Wym. | Postać | Zawartość |
|
||||
| FourCC | Required | Form | Content |
|
||||
|---|---|---|---|
|
||||
| `STRS` | tak | — | `u32 count`, `u32 blob_size`, `count + 1` offsetów `u32`, blob UTF-8. String `i` to bajty `[offset[i], offset[i+1])`. |
|
||||
| `NIDX` | nie | [T] 16 B | indeks nazw: `u64` FNV-1a 64 nazwy w ASCII małymi literami, `u32` węzeł, `u32` 0; posortowane po hashu, potem po węźle |
|
||||
| `NODE` | tak | [T] 80 B | węzły |
|
||||
| `XFRM` | nie | [T] 80 B | `u32` węzeł, 12 B zera, macierz 4×4 `f32` kolumnami: przekształcenie węzła, którego TRS nie opisze (ścinanie) |
|
||||
| `MESH` | tak | [T] 16 B | `u32` pierwszy prymityw, `u32` liczba, `i32` skóra (−1), `u32` flagi (0x1: siatka używa `VUSR`) |
|
||||
| `PRIM` | tak | [T] 48 B | prymitywy (rekordy rysowania) |
|
||||
| `VPOS` | tak | [S] 12 B | pozycja `f32 × 3` |
|
||||
| `VATT` | tak | [S] 16 B | QTangent `snorm16 × 4`, UV0 `f32 × 2` |
|
||||
| `VSKN` | nie | [S] 8 B | jointy `u8 × 4`, wagi `unorm8 × 4` (suma 255) |
|
||||
| `VSKW` | nie | [S] 16 B | jointy `u16 × 4`, wagi `unorm16 × 4` (suma 65535); zamiast `VSKN`, gdy skóra ma ponad 256 jointów |
|
||||
| `VUSR` | nie | [S] 16 B | dane użytkownika `f32 × 4` (dzisiejsze `userdata`) |
|
||||
| `VBND` | tak, gdy jest | [S] 4 B | przypisanie wierzchołka scalonego prymitywu: `u8` joint skóry prymitywu, `u8` slot światła, `u8` rola w slocie (0 brak, 1 zapalony, 2 zgaszony), `u8` 0. Pisarz oznacza go jako wymagany, bo bez niego scalone prymitywy rysują się źle |
|
||||
| `IDX2` | nie | [S] 2 B | indeksy `u16`, lokalne względem `base_vertex` prymitywu |
|
||||
| `IDX4` | nie | [S] 4 B | indeksy `u32`, jw. |
|
||||
| `MATL` | tak | [T] 80 B | sloty materiałów |
|
||||
| `SKIN` | nie | [T] 16 B | `u32` pierwszy joint w `SKJT`, `u32` liczba, `i32` węzeł korzenia, `u32` 0 |
|
||||
| `SKJT` | nie | [T] 64 B | `u32` węzeł, 12 B zera, odwrotna macierz bindu 3×4 `f32` (cztery kolumny po trzy) |
|
||||
| `VGRP` | nie | [T] 32 B | grupy wierzchołków |
|
||||
| `VGIT` | nie | [S] 4 B | elementy grup: wierzchołki albo pary (pierwszy, liczba) |
|
||||
| `VGWT` | nie | [S] 1 B | wagi `unorm8` elementów grup, które je mają |
|
||||
| `CMPT` | nie | [T] 20 B | komponenty |
|
||||
| `CDAT` | nie | — | dane komponentów |
|
||||
| `BNDS` | nie | [T] 40 B | granice: `f32 × 3` min, `f32 × 3` max, sfera `f32 × 4`; jeden rekord na węzeł (geometria węzła w jego przestrzeni), ostatni dla całego modelu |
|
||||
| `EDIT` | nie | [T] 16 B | `u32` ścieżka pliku źródłowego (string), `u32` narzędzie (string), 8 B zera |
|
||||
| `ACLP` | nie | [T] 32 B | klip animacji: `u32` nazwa, `u32` flagi (0x1 zapętlony, 0x2 gra sam od startu scenariusza), `u32` pierwsza ścieżka w `ATRK`, `u32` liczba, `f32` długość w sekundach, 12 B zera |
|
||||
| `ATRK` | nie | [T] 24 B | ścieżka klipu: `u32` węzeł, `u8` część (0 przesunięcie, 1 obrót, 2 skala), `u8` interpolacja (0 skok, 1 liniowa, 2 sześcienna), `u16` 0, `u32` liczba kluczy, `u32` pierwszy czas w `ATIM`, `u32` pierwsza wartość w `AVEC` albo `AROT`, `u32` 0 |
|
||||
| `ATIM` | nie | [S] 4 B | czasy kluczy `f32` w sekundach, od 0, niemalejące w ścieżce |
|
||||
| `AVEC` | nie | [S] 12 B | wartości przesunięć i skal `f32 × 3`; przy interpolacji sześciennej trzy na klucz: styczna wejściowa, wartość, styczna wyjściowa (jak glTF) |
|
||||
| `AROT` | nie | [S] 8 B | obroty „smallest three”: trzy mniejsze składowe kwaternionu `snorm16 × 3` (pomnożone przez √2), `u16` indeks największej (0 x … 3 w), która jest dodatnia i wyliczana z pozostałych |
|
||||
| `STRS` | yes | — | `u32 count`, `u32 blob_size`, `count + 1` offsets `u32`, a UTF-8 blob. String `i` is the bytes `[offset[i], offset[i+1])`. |
|
||||
| `NIDX` | no | [T] 16 B | the name index: `u64` FNV-1a 64 of the name in ASCII lowercase, `u32` node, `u32` 0; sorted by the hash, then by the node |
|
||||
| `NODE` | yes | [T] 80 B | the nodes |
|
||||
| `XFRM` | no | [T] 80 B | `u32` node, 12 B of zeroes, a 4×4 `f32` matrix by columns: the transform of a node which TRS can't describe (shear) |
|
||||
| `MESH` | yes | [T] 16 B | `u32` first primitive, `u32` count, `i32` skin (−1), `u32` flags (0x1: the mesh uses `VUSR`) |
|
||||
| `PRIM` | yes | [T] 48 B | the primitives (draw records) |
|
||||
| `VPOS` | yes | [S] 12 B | position `f32 × 3` |
|
||||
| `VATT` | yes | [S] 16 B | QTangent `snorm16 × 4`, UV0 `f32 × 2` |
|
||||
| `VSKN` | no | [S] 8 B | joints `u8 × 4`, weights `unorm8 × 4` (summing to 255) |
|
||||
| `VSKW` | no | [S] 16 B | joints `u16 × 4`, weights `unorm16 × 4` (summing to 65535); in place of `VSKN` when a skin has more than 256 joints |
|
||||
| `VUSR` | no | [S] 16 B | user data `f32 × 4` (the `userdata` of today) |
|
||||
| `VBND` | yes, when present | [S] 4 B | the binding of a vertex of a merged primitive: `u8` joint of the skin of the primitive, `u8` light slot, `u8` role in the slot (0 none, 1 lit, 2 dark), `u8` 0. The writer marks it required, as merged primitives are drawn wrong without it |
|
||||
| `IDX2` | no | [S] 2 B | `u16` indices, local to the `base_vertex` of the primitive |
|
||||
| `IDX4` | no | [S] 4 B | `u32` indices, as above |
|
||||
| `MATL` | yes | [T] 80 B | the material slots |
|
||||
| `SKIN` | no | [T] 16 B | `u32` first joint in `SKJT`, `u32` count, `i32` root node, `u32` 0 |
|
||||
| `SKJT` | no | [T] 64 B | `u32` node, 12 B of zeroes, the 3×4 inverse bind matrix `f32` (four columns of three) |
|
||||
| `VGRP` | no | [T] 32 B | the vertex groups |
|
||||
| `VGIT` | no | [S] 4 B | the items of the groups: vertices, or pairs (first, count) |
|
||||
| `VGWT` | no | [S] 1 B | the `unorm8` weights of the items of the groups which have them |
|
||||
| `CMPT` | no | [T] 20 B | the components |
|
||||
| `CDAT` | no | — | the data of the components |
|
||||
| `BNDS` | no | [T] 40 B | bounds: `f32 × 3` min, `f32 × 3` max, a sphere `f32 × 4`; one record for each node (the geometry of the node in its space), the last one for the whole model |
|
||||
| `EDIT` | no | [T] 16 B | `u32` path of the source file (string), `u32` tool (string), 8 B of zeroes |
|
||||
| `ACLP` | no | [T] 32 B | an animation clip: `u32` name, `u32` flags (0x1 looped, 0x2 plays on its own from the start of the scenario), `u32` first track in `ATRK`, `u32` count, `f32` duration in seconds, 12 B of zeroes |
|
||||
| `ATRK` | no | [T] 24 B | a track of a clip: `u32` node, `u8` part (0 translation, 1 rotation, 2 scale), `u8` interpolation (0 step, 1 linear, 2 cubic), `u16` 0, `u32` key count, `u32` first time in `ATIM`, `u32` first value in `AVEC` or `AROT`, `u32` 0 |
|
||||
| `ATIM` | no | [S] 4 B | the times of the keys, `f32` seconds, from 0, not decreasing within a track |
|
||||
| `AVEC` | no | [S] 12 B | the values of translations and scales, `f32 × 3`; with cubic interpolation three for each key: in-tangent, value, out-tangent (as in glTF) |
|
||||
| `AROT` | no | [S] 8 B | rotations, "smallest three": the three smaller components of the quaternion `snorm16 × 3` (multiplied by √2), `u16` index of the largest (0 x … 3 w), which is positive and rebuilt from the others |
|
||||
|
||||
Wszystkie strumienie wierzchołków (`VPOS`, `VATT`, `VSKN`/`VSKW`, `VUSR`, `VBND`) mają tyle samo elementów: jeden na wierzchołek
|
||||
pliku. Strumień skóry obejmuje więc też wierzchołki siatek sztywnych (z zerami; zstd je zjada). Do GPU trafiają tylko
|
||||
zakresy siatek skinowanych.
|
||||
All the vertex streams (`VPOS`, `VATT`, `VSKN`/`VSKW`, `VUSR`, `VBND`) have the same element count: one for each vertex of the file.
|
||||
The skin stream so covers the vertices of rigid meshes too (with zeroes; zstd eats them). Only the ranges of skinned meshes go to
|
||||
the GPU.
|
||||
|
||||
### Węzeł (80 B)
|
||||
### Node (80 B)
|
||||
|
||||
| Offset | Typ | Pole |
|
||||
| Offset | Type | Field |
|
||||
|---|---|---|
|
||||
| 0 | u32 | nazwa (string) |
|
||||
| 4 | i32 | rodzic, −1 dla korzenia |
|
||||
| 8 | u32 | koniec poddrzewa: indeks za ostatnim węzłem poddrzewa |
|
||||
| 12 | u32 | flagi: bit 0 animowany, bit 1 ukryty, bit 2 przekształcenie w `XFRM`, bit 3 bez własnego przekształcenia (submodel E3D bez macierzy; TRS to tożsamość) |
|
||||
| 16 | f32 × 3 | translacja |
|
||||
| 28 | f32 × 4 | obrót, kwaternion x y z w |
|
||||
| 44 | f32 × 3 | skala |
|
||||
| 56 | i32 | siatka, −1 bez siatki |
|
||||
| 60 | u32 × 2 | komponenty węzła: pierwszy, liczba |
|
||||
| 68 | f32 × 2 | kwadrat odległości od kamery: od, do (0 = bez ograniczenia) |
|
||||
| 76 | u32 | `iFlags` submodelu E3D, z którego węzeł powstał; 0 w modelu nowym |
|
||||
| 0 | u32 | name (string) |
|
||||
| 4 | i32 | parent, −1 for the root |
|
||||
| 8 | u32 | end of the subtree: the index past the last node of the subtree |
|
||||
| 12 | u32 | flags: bit 0 animated, bit 1 hidden, bit 2 transform in `XFRM`, bit 3 no transform of its own (an E3D submodel without a matrix; the TRS is the identity) |
|
||||
| 16 | f32 × 3 | translation |
|
||||
| 28 | f32 × 4 | rotation, quaternion x y z w |
|
||||
| 44 | f32 × 3 | scale |
|
||||
| 56 | i32 | mesh, −1 without one |
|
||||
| 60 | u32 × 2 | the components of the node: first, count |
|
||||
| 68 | f32 × 2 | squared distance from the camera: from, to (0 = no limit) |
|
||||
| 76 | u32 | the `iFlags` of the E3D submodel the node was made from; 0 in a model made anew |
|
||||
|
||||
Węzły leżą w porządku DFS: rodzic przed dziećmi, a poddrzewo zajmuje ciągły zakres `[węzeł, koniec poddrzewa)`. Dzieci
|
||||
jednego rodzica są w kolejności rysowania. Macierze świata liczy się więc jedną pętlą od początku tablicy. Przekształcenie
|
||||
węzła to T · R · S, chyba że ma flagę `XFRM`.
|
||||
The nodes lie in depth-first order: a parent before its children, and a subtree takes the continuous range `[node, end of the
|
||||
subtree)`. The children of one parent are in drawing order. The world matrices are so worked out by one loop from the start of the
|
||||
table. The transform of a node is T · R · S, unless it has the `XFRM` flag.
|
||||
|
||||
### Prymityw (48 B)
|
||||
### Primitive (48 B)
|
||||
|
||||
| Offset | Typ | Pole |
|
||||
| Offset | Type | Field |
|
||||
|---|---|---|
|
||||
| 0 | u32 | pierwszy indeks w `IDX2`/`IDX4`; bez indeksów: pierwszy wierzchołek liczony od `base_vertex` |
|
||||
| 4 | u32 | liczba indeksów; bez indeksów: liczba rysowanych wierzchołków |
|
||||
| 8 | u32 | `base_vertex` w strumieniach |
|
||||
| 12 | u32 | liczba wierzchołków prymitywu |
|
||||
| 16 | u32 | materiał (slot `MATL`) |
|
||||
| 20 | u32 | węzeł |
|
||||
| 24 | i32 | skóra, −1 dla sztywnego |
|
||||
| 28 | u32 | flagi: bity 0-3 topologia (wartości GL: 0 punkty, 1 linie, 2 pętla, 3 łamana, 4 trójkąty, 5 pas, 6 wachlarz); 0x10 indeksowany; 0x20 indeksy w `IDX4`; 0x40 przebieg nieprzezroczysty; 0x80 przebieg przezroczysty; 0x100 bez cienia; 0x200 sztywne jointy z `VBND`; 0x400 sloty świateł z `VBND`; bity 16-23 LOD |
|
||||
| 32 | f32 × 4 | sfera w przestrzeni węzła |
|
||||
| 0 | u32 | first index in `IDX2`/`IDX4`; without indices: the first vertex counted from `base_vertex` |
|
||||
| 4 | u32 | index count; without indices: the count of vertices drawn |
|
||||
| 8 | u32 | `base_vertex` in the streams |
|
||||
| 12 | u32 | vertex count of the primitive |
|
||||
| 16 | u32 | material (`MATL` slot) |
|
||||
| 20 | u32 | node |
|
||||
| 24 | i32 | skin, −1 for a rigid one |
|
||||
| 28 | u32 | flags: bits 0-3 topology (GL values: 0 points, 1 lines, 2 loop, 3 strip, 4 triangles, 5 strip, 6 fan); 0x10 indexed; 0x20 indices in `IDX4`; 0x40 opaque pass; 0x80 translucent pass; 0x100 no shadow; 0x200 rigid joints from `VBND`; 0x400 light slots from `VBND`; bits 16-23 LOD |
|
||||
| 32 | f32 × 4 | sphere in the space of the node |
|
||||
|
||||
### Prymitywy scalone
|
||||
### Merged primitives
|
||||
|
||||
Dziś każda ruchoma część i każda lampa (`Light_On##` / `Light_Off##`) to osobny submodel, a więc osobny draw call w
|
||||
każdym przebiegu. Model scenerii ze światłem albo animacją nie jest przy tym instancjonowany. EU07M pozwala złożyć części
|
||||
kilku węzłów o tym samym materiale w jeden prymityw:
|
||||
Today every moving part and every lamp (`Light_On##` / `Light_Off##`) is a submodel of its own, so a draw call of its own in every
|
||||
pass. A scenery model with a light or an animation isn't instanced either. EU07M allows the parts of several nodes with the same
|
||||
material to be put in one primitive:
|
||||
|
||||
- **Sztywne jointy (0x200).** Każdy wierzchołek wskazuje w `VBND` joint skóry prymitywu (`skin` ≥ 0), z wagą 1.
|
||||
Wierzchołki leżą w pozie bindu, tak jak w skinningu, a macierz to `świat(joint) · odwrotny bind(joint)`. Vertex shader
|
||||
bierze ją z bufora póz instancji sam, bez przebiegu compute. Prymityw nie potrzebuje `VSKN`. Skóra ma najwyżej 256
|
||||
jointów; większą grupę narzędzie dzieli na kilka prymitywów.
|
||||
- **Sloty świateł (0x400).** Wierzchołek wskazuje slot (`u8`, pole `slot` komponentu `LSLT`) i rolę: zapalony (świeci i
|
||||
jest widoczny, gdy slot się świeci) albo zgaszony (widoczny, gdy slot jest zgaszony). Stan slotu leży w buforze stanów
|
||||
instancji, więc model ze światłami da się instancjonować. Slotu, którego model nie ma, shader nie zapala.
|
||||
- **Węzły zostają.** Scalenie przenosi tylko geometrię; węzły i ich nazwy zostają w `NODE`, więc `GetFromName`, `.mmd` i
|
||||
eventy działają dalej. Ukrycie węzła (`visible`) to zerowa macierz jego jointu w buforze póz.
|
||||
- Sfera prymitywu obejmuje pozę bindu. Runtime dla prymitywu z ruchomymi jointami bierze granice instancji.
|
||||
- **Rigid joints (0x200).** Each vertex names in `VBND` a joint of the skin of the primitive (`skin` ≥ 0), with weight 1. The
|
||||
vertices lie in the bind pose, as with skinning, and the matrix is `world(joint) · inverse bind(joint)`. The vertex shader
|
||||
takes it from the pose buffer of the instance itself, without a compute pass. The primitive needs no `VSKN`. A skin has at most
|
||||
256 joints; the tool splits a larger group into several primitives.
|
||||
- **Light slots (0x400).** A vertex names a slot (`u8`, the `slot` field of an `LSLT` component) and a role: lit (glowing and
|
||||
visible while the slot is lit) or dark (visible while the slot is dark). The state of the slot lies in the state buffer of the
|
||||
instance, so a model with lights can be instanced. A slot the model hasn't the shader doesn't light.
|
||||
- **The nodes stay.** Merging moves only the geometry; the nodes and their names stay in `NODE`, so `GetFromName`, the `.mmd` and
|
||||
the events keep working. Hiding a node (`visible`) is a zero matrix of its joint in the pose buffer.
|
||||
- The sphere of the primitive covers the bind pose. For a primitive with moving joints the runtime takes the bounds of the
|
||||
instance.
|
||||
|
||||
Łączy narzędzie (`optimize`), nie konwerter: łączy węzły nieanimowane i bez komponentów, a węzły, do których coś odwołuje
|
||||
się po nazwie, zostawia jako jointy. Części przezroczyste, ze skórkami wymiennymi innymi niż reszta oraz z innym zakresem
|
||||
widoczności nie są łączone.
|
||||
The tool merges (`optimize`), not the converter: it merges nodes which aren't animated and have no components, and keeps as joints
|
||||
the nodes something refers to by name. Translucent parts, parts with replaceable skins other than the rest and parts with another
|
||||
visibility range aren't merged.
|
||||
|
||||
### Wierzchołek
|
||||
### Vertex
|
||||
|
||||
- Pozycja `f32 × 3` względem originu modelu.
|
||||
- QTangent: kwaternion obrotu układu (T, B, N), w którym B = N × T. Kwaternion ma w ≥ 1/32767. Gdy bitangent jest
|
||||
odwrócony (lustrzane UV, `tangent.w < 0` w `basic_vertex`), cały kwaternion jest zanegowany, więc w < 0. Dekodowanie:
|
||||
N = trzecia kolumna, T = pierwsza, B = N × T · znak(w).
|
||||
- UV0 `f32 × 2`; half traci precyzję przy teksturach powtarzanych setki razy.
|
||||
- Position `f32 × 3` relative to the origin of the model.
|
||||
- QTangent: the quaternion of the rotation of the frame (T, B, N), where B = N × T. The quaternion has w ≥ 1/32767. When the
|
||||
bitangent is flipped (mirrored UV, `tangent.w < 0` in `basic_vertex`), the whole quaternion is negated, so w < 0. Decoding:
|
||||
N = third column, T = first, B = N × T · sign(w).
|
||||
- UV0 `f32 × 2`; half floats lose precision on textures repeated hundreds of times.
|
||||
|
||||
Rozmiar: 28 B (sztywny), 32 B (w prymitywie scalonym, z `VBND`), 36 B (skinowany), wobec 48 B `basic_vertex`. Przebieg
|
||||
cieni czyta tylko `VPOS` (i `VBND` w prymitywach scalonych).
|
||||
Size: 28 B (rigid), 32 B (in a merged primitive, with `VBND`), 36 B (skinned), against the 48 B of `basic_vertex`. The shadow pass
|
||||
reads only `VPOS` (and `VBND` in merged primitives).
|
||||
|
||||
### Materiał (80 B)
|
||||
### Material (80 B)
|
||||
|
||||
| Offset | Typ | Pole |
|
||||
| Offset | Type | Field |
|
||||
|---|---|---|
|
||||
| 0 | u32 | nazwa `.mat` albo tekstury (string); brak = tylko kolory |
|
||||
| 4 | i32 | skórka wymienna −1..−4, 0 = stała |
|
||||
| 8 | u32 | flagi |
|
||||
| 12 | f32 | próg selfillum (`fLight` z E3D) |
|
||||
| 0 | u32 | name of the `.mat` or of the texture (string); none = colours only |
|
||||
| 4 | i32 | replaceable skin −1..−4, 0 = fixed |
|
||||
| 8 | u32 | flags |
|
||||
| 12 | f32 | selfillum threshold (`fLight` of E3D) |
|
||||
| 16 | f32 × 4 × 4 | ambient, diffuse, specular, emission |
|
||||
|
||||
### Grupa wierzchołków (32 B)
|
||||
### Vertex group (32 B)
|
||||
|
||||
`u32` nazwa, `u32` siatka, `u32` pierwszy element w `VGIT`, `u32` liczba elementów, `u32` flagi (0x1 elementy to
|
||||
pary (pierwszy, liczba), 0x2 wagi w `VGWT`), `u32 × 2` komponenty grupy (pierwszy, liczba), `u32` 0. Indeksy wierzchołków
|
||||
są w strumieniach pliku (bezwzględne).
|
||||
`u32` name, `u32` mesh, `u32` first item in `VGIT`, `u32` item count, `u32` flags (0x1 the items are pairs (first, count), 0x2
|
||||
weights in `VGWT`), `u32 × 2` the components of the group (first, count), `u32` 0. The vertex indices are those of the streams of
|
||||
the file (absolute).
|
||||
|
||||
## Komponenty
|
||||
## Components
|
||||
|
||||
Rekord w `CMPT` (20 B):
|
||||
A record in `CMPT` (20 B):
|
||||
|
||||
| Offset | Typ | Pole |
|
||||
| Offset | Type | Field |
|
||||
|---|---|---|
|
||||
| 0 | u32 | typ (FourCC) |
|
||||
| 4 | u16 | wersja danych |
|
||||
| 6 | u8 | rodzaj celu: 0 model, 1 węzeł, 2 siatka, 3 grupa wierzchołków |
|
||||
| 7 | u8 | flagi |
|
||||
| 8 | u32 | indeks celu |
|
||||
| 12 | u32 | offset danych w `CDAT` (wyrównany do 4) |
|
||||
| 16 | u32 | rozmiar danych |
|
||||
| 0 | u32 | type (FourCC) |
|
||||
| 4 | u16 | version of the data |
|
||||
| 6 | u8 | kind of the target: 0 model, 1 node, 2 mesh, 3 vertex group |
|
||||
| 7 | u8 | flags |
|
||||
| 8 | u32 | index of the target |
|
||||
| 12 | u32 | offset of the data in `CDAT` (aligned to 4) |
|
||||
| 16 | u32 | size of the data |
|
||||
|
||||
Komponenty jednego węzła leżą obok siebie, a węzeł wskazuje swój zakres; tak samo grupa wierzchołków. Nieznany typ gra
|
||||
pomija, a narzędzia przenoszą go bez zmian. Nowa wersja typu dopisuje pola na samym końcu danych, za listami, więc
|
||||
starszy czytnik czyta swoją część od początku i pomija resztę.
|
||||
Odwołania wewnątrz danych to indeksy: string, węzeł albo komponent; `0xFFFFFFFF` = brak.
|
||||
The components of one node lie next to each other, and the node names its range; so does a vertex group. The game skips an unknown
|
||||
type, and the tools carry it over unchanged. A new version of a type adds fields at the very end of the data, past the lists, so an
|
||||
older reader reads its part from the start and skips the rest. References within the data are indices: a string, a node or a
|
||||
component; `0xFFFFFFFF` = none.
|
||||
|
||||
| Typ | Dane (wersja 1) |
|
||||
| Type | Data (version 1) |
|
||||
|---|---|
|
||||
| `PROP` | `u32 count`, potem rekordy 24 B: `u32` klucz (string), `u8` typ (0 bool, 1 int, 2 float, 3-5 vec2-4, 6 string, 7 węzeł, 8 komponent), 3 B zera, 16 B wartości |
|
||||
| `SOCK` | gniazdo, 36 B: `u32` rola (string), `u8` strona (0 brak, 1 przód, 2 tył), `u8` 0, `u16` indeks, pozycja `f32 × 3`, obrót `f32 × 4` (w przestrzeni węzła) |
|
||||
| `JOIN` | joint, 36 B: `u8` rodzaj (0 stały, 1 zawias, 2 kulisty, 3 przesuw, 4 śruba), `u8` czy ograniczony, `u16` 0, `u32` rola, oś `f32 × 3`, min, max, spoczynek, skok śruby (m na obrót) |
|
||||
| `SPRG` | sprężyna, 52 B: `u8` tryb (0 follow, 1 stretch, 2 aim, 3 wahadło), `u8` ruch boczny, `u16` 0, kotwica A (węzeł, gniazdo), kotwica B (węzeł, gniazdo), oś `f32 × 3`, długość swobodna, skok min, max, długość wahadła, tłumienie wahadła |
|
||||
| `CHAN` | łańcuch (wąż, kabel, miech), 32 B: `u8` rodzaj (0 wąż hamulcowy, 1 zasilający, 2 kabel, 3 miech, 4 inny), `u8` 0, `u16` liczba jointów, `i32` skóra, min. promień gięcia, sztywność, masa głowicy, długość sztywnej głowicy, gniazda końców A i B; potem węzły jointów `u32 × n` i długości segmentów `f32 × (n − 1)` |
|
||||
| `VARI` | grupa wariantów: `u32` nazwa, `u16` liczba stanów, `u16` stan domyślny; stany po 12 B (`u32` nazwa, `u32` pierwszy, `u32` liczba węzłów), potem lista węzłów `u32` |
|
||||
| `CHNL` | kanał sterowania: `u32` nazwa, `f32` min, max, wartość początkowa, `u16` liczba powiązań, `u16` 0; powiązania po 16 B: `u8` rodzaj (0 joint, 1 klip, 2 warianty, 3 slot światła), 3 B zera, `u32` komponent celu, `f32` skala, `f32` przesunięcie (wartość celu = kanał · skala + przesunięcie) |
|
||||
| `LSLT` | slot światła: `u16` slot, `u16` 0, `f32` stan początkowy (kodowanie z eventu `lights`), kolor `f32 × 3` (ujemny: kolor źródeł), `u16` liczba węzłów zapalonych, zgaszonych, źródeł `LGHT`, `u16` 0; potem te trzy listy `u32` |
|
||||
| `LGHT` | źródło światła, 52 B: `u8` rodzaj (0 punkt, 1 reflektor), `u8` flagi (0x1 shadeself, 0x2 bez cieni, 0x4 soft falloff, 0x8 tylko oświetlenie, 0x10 aureola), `u16` 0, kolor `f32 × 4`, natężenie, promień, aureola od, do, `i32` typ zaniku, promień zaniku, cos stożka, cos plamy |
|
||||
| `EMIT` | emiter, 16 B: `u8` rodzaj (0 dym, 1 para, 2 iskry), 3 B zera, kierunek `f32 × 3` |
|
||||
| `MREF` | model wpięty w węzeł, 12 B: ścieżka (string), gniazdo (komponent), skórka (string) |
|
||||
| `COLL` | bryła, 48 B: `u8` kształt (0 prostopadłościan, 1 kula, 2 kapsuła), 3 B zera, `u32` rola, środek `f32 × 3`, obrót `f32 × 4`, półwymiary `f32 × 3` |
|
||||
| `LANM` | animacja E3D (`TAnimType`): `u32` |
|
||||
| `LTXT` | wyświetlacz tekstu E3D (`TP_TEXT`); dzieci węzła to znaki nazwane swoim znakiem. Bez danych. |
|
||||
| `STAR` | gwiazdy E3D (`TP_STARS`): `u32 count`, potem kolory RGB `u32` (jak w E3D), po jednym na wierzchołek siatki węzła |
|
||||
| `LMAT` | materiał węzła bez geometrii (punkt świetlny, rotator), który E3D trzyma w każdym submodelu: `u32` slot `MATL`. Z niego światło bierze próg zapalenia (`fLight`), kolory i materiał |
|
||||
| `PROP` | `u32 count`, then records of 24 B: `u32` key (string), `u8` type (0 bool, 1 int, 2 float, 3-5 vec2-4, 6 string, 7 node, 8 component), 3 B of zeroes, 16 B of value |
|
||||
| `SOCK` | a socket, 36 B: `u32` role (string), `u8` end (0 none, 1 front, 2 rear), `u8` 0, `u16` index, position `f32 × 3`, rotation `f32 × 4` (in the space of the node) |
|
||||
| `JOIN` | a joint, 36 B: `u8` kind (0 fixed, 1 hinge, 2 ball, 3 slider, 4 screw), `u8` limited, `u16` 0, `u32` role, axis `f32 × 3`, min, max, rest, pitch of a screw (m for each turn) |
|
||||
| `SPRG` | a spring, 52 B: `u8` mode (0 follow, 1 stretch, 2 aim, 3 pendulum), `u8` side play, `u16` 0, anchor A (node, socket), anchor B (node, socket), axis `f32 × 3`, free length, travel min, max, pendulum length, pendulum damping |
|
||||
| `CHAN` | a chain (hose, cable, bellows), 32 B: `u8` kind (0 brake hose, 1 main reservoir hose, 2 cable, 3 bellows, 4 other), `u8` 0, `u16` joint count, `i32` skin, minimum bend radius, stiffness, head mass, length of the rigid head, the sockets of the ends A and B; then the joint nodes `u32 × n` and the segment lengths `f32 × (n − 1)` |
|
||||
| `VARI` | a variant group: `u32` name, `u16` state count, `u16` default state; states of 12 B (`u32` name, `u32` first, `u32` node count), then the node list `u32` |
|
||||
| `CHNL` | a control channel: `u32` name, `f32` min, max, initial value, `u16` binding count, `u16` 0; bindings of 16 B: `u8` kind (0 joint, 1 clip, 2 variants, 3 light slot), 3 B of zeroes, `u32` target (a `JOIN` component; for a clip its index in `ACLP`; a `VARI` or an `LSLT` component), `f32` scale, `f32` offset (value of the target = channel · scale + offset) |
|
||||
| `LSLT` | a light slot: `u16` slot, `u16` 0, `f32` initial state (coded as in the `lights` event), colour `f32 × 3` (negative: the colour of the sources), `u16` counts of the lit nodes, the dark nodes, the `LGHT` sources, `u16` 0; then those three lists `u32` |
|
||||
| `LGHT` | a light source, 52 B: `u8` kind (0 point, 1 spot), `u8` flags (0x1 shadeself, 0x2 no shadows, 0x4 soft falloff, 0x8 light only, 0x10 halo), `u16` 0, colour `f32 × 4`, intensity, radius, halo from, to, `i32` falloff kind, falloff radius, cos of the cone, cos of the hotspot |
|
||||
| `EMIT` | an emitter, 16 B: `u8` kind (0 smoke, 1 steam, 2 sparks), 3 B of zeroes, direction `f32 × 3` |
|
||||
| `MREF` | a model attached to the node, 12 B: path (string), socket (component), skin (string) |
|
||||
| `COLL` | a solid, 48 B: `u8` shape (0 box, 1 sphere, 2 capsule), 3 B of zeroes, `u32` role, centre `f32 × 3`, rotation `f32 × 4`, half extents `f32 × 3` |
|
||||
| `LANM` | an E3D animation (`TAnimType`): `u32` |
|
||||
| `LTXT` | an E3D text display (`TP_TEXT`); the children of the node are the characters, named by their character. No data. |
|
||||
| `STAR` | E3D stars (`TP_STARS`): `u32 count`, then RGB colours `u32` (as in E3D), one for each vertex of the mesh of the node |
|
||||
| `LMAT` | the material of a node without geometry (a light point, a rotator), which E3D keeps in every submodel: `u32` `MATL` slot. The light takes its threshold (`fLight`), colours and material from it |
|
||||
|
||||
## Konwersja z E3D i T3D
|
||||
## Conversion from E3D and T3D
|
||||
|
||||
`eu07 -eu07m convert <wejście.e3d|.t3d> <wyjście.eu07m> [dynamic]` wczytuje model istniejącym loaderem (jak `-e3d`) i zapisuje
|
||||
go w EU07M:
|
||||
`eu07 -eu07m convert <input.e3d|.t3d> <output.eu07m> [dynamic]` loads the model with the existing loader (as `-e3d` does) and writes
|
||||
it as EU07M:
|
||||
|
||||
- Submodel staje się węzłem. Kolejność dzieci i nazwy zostają, więc `GetFromName`, `.mmd` i eventy działają po staremu.
|
||||
- Macierz submodelu jest rozkładana na TRS. Gdy TRS jej nie odtwarza (ścinanie), pełna macierz idzie do `XFRM`.
|
||||
- `iFlags`, zakres widoczności i kolory zostają w węźle i w slocie materiału.
|
||||
- `TP_FREESPOTLIGHT` → `LGHT`; `Light_On##` / `Light_Off##` → `LSLT`; `smokesource_*` → `EMIT`; animacja `anim:` → `LANM`;
|
||||
- A submodel becomes a node. The order of the children and the names stay, so `GetFromName`, the `.mmd` and the events work as
|
||||
before.
|
||||
- The matrix of a submodel is decomposed into TRS. When TRS doesn't give it back (shear), the whole matrix goes to `XFRM`.
|
||||
- The `iFlags`, the visibility range and the colours stay in the node and in the material slot.
|
||||
- `TP_FREESPOTLIGHT` → `LGHT`; `Light_On##` / `Light_Off##` → `LSLT`; `smokesource_*` → `EMIT`; an `anim:` animation → `LANM`;
|
||||
`TP_TEXT` → `LTXT`; `TP_STARS` → `STAR`.
|
||||
- Indeksy są zapisywane jako `u16`, gdy prymityw ma mniej niż 65 536 wierzchołków.
|
||||
- The indices are written as `u16` when a primitive has fewer than 65 536 vertices.
|
||||
|
||||
Pozostałe polecenia: `eu07 -eu07m dump <plik.eu07m>` (zawartość jako tekst) i `eu07 -eu07m validate <plik.eu07m>` (sprawdzenie
|
||||
pliku wraz z hashem zawartości).
|
||||
The other commands: `eu07 -eu07m dump <file.eu07m>` (the content as text, clips included) and `eu07 -eu07m validate <file.eu07m>`
|
||||
(a check of the file with the hash of its content).
|
||||
|
||||
## W grze
|
||||
## In the game
|
||||
|
||||
Z `modelformat eu07m` w `eu07.ini` model z plikiem `.eu07m` obok `.e3d` / `.t3d` jest wczytywany z niego (`TModel3d::LoadFromEU07M`).
|
||||
Domyślne `modelformat legacy` zostawia pliki `.eu07m` w spokoju.
|
||||
With `modelformat eu07m` in `eu07.ini`, a model with an `.eu07m` file beside its `.e3d` / `.t3d` (or alone) is loaded from it
|
||||
(`TModel3d::LoadFromEU07M`). The default `modelformat legacy` leaves `.eu07m` files alone.
|
||||
|
||||
- **Renderer Vulkan** trzyma strumienie modelu EU07M tak, jak leżą w pliku: pozycje (12 B), atrybuty z `VATT` (16 B), dane
|
||||
użytkownika i indeksy, każde w osobnym buforze banku (`vertex_kind::scene_compact`). Shadery czytają pozycję i UV jak dotąd,
|
||||
a normalną i tangens wyliczają z kwaternionu (`compact_frame()` w `shaders/vk14/common.glsl`, wariant `COMPACT_VERTEX`
|
||||
programu). Ray tracing buduje BLAS z pozycji o kroku 12 B i czyta normalne oraz UV z atrybutów (`RT_FLAG_COMPACT`).
|
||||
- **Renderer OpenGL 4.6** dostaje te same modele jako `gfx::basic_vertex` (48 B), jak modele E3D.
|
||||
- Kod gry, który czyta wierzchołki modelu (pantograf, granice, picking, edytor), dostaje je jako `gfx::basic_vertex`, zrobione ze
|
||||
strumieni przy pierwszym odczycie.
|
||||
- Gwiazdy (`STAR`) trzymają kolor w normalnej, więc idą jako `gfx::basic_vertex` również w Vulkanie.
|
||||
- **The Vulkan renderer** keeps the streams of an EU07M model as they lie in the file: positions (12 B), attributes from `VATT`
|
||||
(16 B), user data and indices, each in a buffer of its own in the bank (`vertex_kind::scene_compact`). The shaders read the
|
||||
position and the UV as before, and work out the normal and the tangent from the quaternion (`compact_frame()` in
|
||||
`shaders/vk14/common.glsl`, the `COMPACT_VERTEX` variant of a program). Ray tracing builds the BLAS from the positions with a
|
||||
stride of 12 B and reads the normals and UVs from the attributes (`RT_FLAG_COMPACT`).
|
||||
- **The OpenGL 4.6 renderer** gets the same models as `gfx::basic_vertex` (48 B), as E3D models.
|
||||
- The code of the game which reads the vertices of a model (pantograph, bounds, picking, the editor) gets them as
|
||||
`gfx::basic_vertex`, made from the streams the first time they are read.
|
||||
- The stars (`STAR`) keep their colour in the normal, so they go as `gfx::basic_vertex` in Vulkan too.
|
||||
- A node with `range_max_sq` 0 has no distance limit; before, such a node (of a model made anew, not converted from E3D) wasn't
|
||||
drawn at all.
|
||||
|
||||
### Klipy animacji
|
||||
### Animation clips
|
||||
|
||||
Klip (`ACLP`) to zestaw ścieżek (`ATRK`), z których każda ustawia jedną część TRS węzła: przesunięcie, obrót albo skalę.
|
||||
Części węzła bez ścieżki zostają takie, jak w jego TRS.
|
||||
A clip (`ACLP`) is a set of tracks (`ATRK`), each of which sets one part of the TRS of a node: translation, rotation or scale. The
|
||||
parts of a node without a track stay as in its TRS.
|
||||
|
||||
- **Interpolacja.** Skok trzyma wartość klucza do następnego. Liniowa to lerp wektorów i slerp obrotów (krótszą drogą).
|
||||
Sześcienna to spline Hermite'a z glTF, ze stycznymi w jednostkach na sekundę; tylko dla wektorów, obrót sześcienny
|
||||
walidator odrzuca. Przed pierwszym i po ostatnim kluczu ścieżka trzyma jego wartość.
|
||||
- **Czas.** Klip idzie po czasie symulacji od chwili startu, z tempem `speed`. Zapętlony zaczyna od nowa po swojej
|
||||
długości, inny zatrzymuje się na końcu. Klip z flagą 0x2 startuje sam, gdy egzemplarz jest rysowany pierwszy raz.
|
||||
- **W grze.** `TAnimModel::play_clip(nazwa, tempo)` startuje klip (komenda self-testu `clip <węzeł> <nazwa> [tempo]`),
|
||||
a `stop_clips()` zatrzymuje wszystkie. Przy każdym rysowaniu egzemplarza `RaPrepare()` próbkuje grające klipy i
|
||||
ustawia transformy węzłów (`TSubModel::SetClipTransform()`, animacja `at_Clip`), tak jak inne animacje egzemplarza.
|
||||
Węzły, które klipy przesuwają, są przy wczytaniu oznaczane jako animowane, więc model z klipami nie jest
|
||||
instancjonowany. Klip ruszający jointami skóry zgina skinowane części (sekcja „Skinning”).
|
||||
- **Event scenerii.** `event <nazwa> animation <opóźnienie> <model> clip <klip> <tempo> endevent` startuje klip od
|
||||
początku w podanym tempie (klip już grający zaczyna od nowa), a tempo 0 zatrzymuje klipy modelu; węzły zostają tam,
|
||||
gdzie klip je zostawił. Klip, którego model nie ma, daje w logu `Bad event: ... can't find clip`. To nowa forma
|
||||
eventu `animation`, której obecne wydanie nie czyta; dotychczasowe formy (`rotate`, `translate`, `digital`, `.vmd`)
|
||||
czytają się jak dotąd.
|
||||
- **Jeszcze nie:** powiązanie kanałów `CHNL` z czasem klipu. Obecne wydanie nie czyta sekcji klipów, a plik bez nich
|
||||
wczytuje się jak dotąd.
|
||||
- **Interpolation.** Step holds the value of a key till the next one. Linear is the lerp of vectors and the slerp of rotations (the
|
||||
shorter way). Cubic is the Hermite spline of glTF, with tangents in units per second; vectors only, the validator refuses a
|
||||
cubic rotation. Before the first and past the last key a track holds its value.
|
||||
- **Time.** A clip goes by the simulation time from when it started, at its pace. A looped clip starts over past its duration,
|
||||
another stops at its end. A clip with flag 0x2 starts on its own the first time the instance is drawn.
|
||||
- **In the game.** `TAnimModel::play_clip(name, pace)` starts a clip (the self-test command `clip <node> <name> [pace]`), and
|
||||
`stop_clips()` stops them all. Each time the instance is drawn, `RaPrepare()` samples the clips playing and sets the transforms
|
||||
of the nodes (`TSubModel::SetClipTransform()`, the animation `at_Clip`), as the other animations of an instance. The nodes the
|
||||
clips move are flagged animated at load, so a model with clips isn't instanced. A clip moving the joints of a skin bends the
|
||||
skinned parts (see "Skinning").
|
||||
- **Scenery event.** `event <name> animation <delay> <model> clip <clip> <pace> endevent` starts the clip from its beginning at the
|
||||
pace (a clip playing starts over), and a pace of 0 stops the clips of the model; the nodes stay where the clips left them. A clip
|
||||
the model hasn't gives `Bad event: ... can't find clip` in the log. This is a new form of the `animation` event, which the
|
||||
current release doesn't read; the forms before it (`rotate`, `translate`, `digital`, `.vmd`) read as they did.
|
||||
|
||||
The current release doesn't read the clip sections, and a file without them loads as before.
|
||||
|
||||
### Channels
|
||||
|
||||
A channel (`CHNL`) is a named value of the model, kept within its range, which moves what it's bound to. Whatever sets it (an event,
|
||||
the code of a vehicle, later Lua or a gauge in the cab) doesn't matter.
|
||||
|
||||
- **Bindings the game follows.** A joint (`JOIN` of a node): the value of the target turns a hinge (radians) or a screw, or moves a
|
||||
slider (metres) along the axis of the joint, from the transform of the node, within the limits of the joint when it has them; a
|
||||
fixed or a ball joint leaves the node at rest. A clip (its index in `ACLP`): the value of the target is the share of the duration
|
||||
of the clip, 0 to 1, so the channel scrubs the clip without playing it. Bindings to variants and light slots are read but not
|
||||
followed yet.
|
||||
- **In the game.** `TAnimModel::set_channel(name, value)` sets a channel (the self-test command `channel <node> <name> <value>`).
|
||||
Each time the instance is drawn, `RaPrepare()` sets the nodes from the channels, after the clips playing, so a channel overrides a
|
||||
clip on the same node. A channel not set yet has its initial value. The nodes of the joints are flagged animated at load.
|
||||
- **Scenery event.** `event <name> animation <delay> <model> channel <channel> <value> endevent` sets the channel. A channel the
|
||||
model hasn't gives `Bad event: ... can't find channel` in the log. A new form of the `animation` event, which the current release
|
||||
doesn't read.
|
||||
|
||||
### Skinning
|
||||
|
||||
Prymityw ze skórą (`skin` ≥ 0, wagi w `VSKN` albo `VSKW`) jest rysowany przez jointy swojej skóry, w obu rendererach.
|
||||
A primitive with a skin (`skin` ≥ 0, weights in `VSKN` or `VSKW`) is drawn by the joints of its skin, in both renderers.
|
||||
|
||||
- **Układ.** Wierzchołki leżą w pozie bindu, w przestrzeni modelu, a transform węzła siatki jest pomijany, jak w glTF.
|
||||
Macierz jointu to `świat(joint) · odwrotny bind(joint)`, gdzie świat to transform węzła jointu od korzenia modelu, z
|
||||
animacjami egzemplarza. Odwrotny bind w `SKJT` odwraca więc świat jointu w pozie bindu.
|
||||
- **Pozy.** Jointy to zwykłe węzły modelu, więc ustawia się je jak dotąd: eventy `animation`, animacje z `.mmd` i kod
|
||||
pojazdów (`GetFromName`, `SetRotate`, `SetTranslate`). Osobne API nie jest potrzebne.
|
||||
- **Paleta.** Przejście renderera, które pierwsze w klatce rysuje skinowany submodel egzemplarza, liczy na CPU paletę
|
||||
jointów (`gfx::skin_cache`, `rendering/common/skincache.cpp`, matematyka w `model/skinning.cpp`).
|
||||
- **Wierzchołki.** Jeśli paleta zmieniła się od poprzedniej klatki, wierzchołki są przesuwane przed przejściami
|
||||
następnej klatki, bo w trakcie przejść nic, co rysują, się nie zmienia (`gfx::walk_sync`). Pozycje idą przez mieszaną
|
||||
macierz, a normalne i tangensy przez jej obrót.
|
||||
- Renderer Vulkan robi to compute shaderem (`shaders/vk14/skin.comp`, `rendering/vulkan14/vulkan14skinning.cpp`):
|
||||
poza bindu z wagami trafia na GPU raz na skinowaną część, paleta idzie w buforze klatki, a kernel zapisuje
|
||||
wierzchołki prosto w bufor banku, w miejsce geometrii egzemplarza. Gdy bank robi swoje bufory od nowa (nowa
|
||||
geometria egzemplarza albo oddana), wszystkie egzemplarze skinowane na GPU są przesuwane od nowa.
|
||||
- Renderer OpenGL 4.6, a także Vulkan z `gfx.skinning.gpu 0` (domyślnie 1) albo bez kernela, przesuwa wierzchołki na
|
||||
CPU i podmienia geometrię egzemplarza. Oba sposoby dają ten sam obraz.
|
||||
- Wierzchołki nadążają więc za jointami z opóźnieniem jednej klatki, a w pierwszej klatce egzemplarz jest w pozie bindu.
|
||||
- Dopóki jointy są w pozie bindu, rysowana jest geometria modelu, wspólna dla wszystkich egzemplarzy. Egzemplarz
|
||||
niewidziany przez 600 klatek oddaje swoją geometrię.
|
||||
- **Ograniczenia tej wersji:** granice submodelu z pozy bindu,
|
||||
wektory ruchu i ray tracing bez ruchu jointów.
|
||||
- Węzeł z `range_max_sq` 0 nie ma limitu odległości; wcześniej taki węzeł (model zrobiony od nowa, nie przekonwertowany
|
||||
z E3D) nie był w ogóle rysowany.
|
||||
- **Space.** The vertices lie in the bind pose, in the space of the model, and the transform of the node of the mesh is left out,
|
||||
as in glTF. The matrix of a joint is `world(joint) · inverse bind(joint)`, world being the transform of the node of the joint
|
||||
from the root of the model, with the animations of the instance. The inverse bind in `SKJT` so undoes the world of the joint in
|
||||
the bind pose.
|
||||
- **Poses.** The joints are ordinary nodes of the model, so they are posed as before: `animation` events, the animations of the
|
||||
`.mmd` and the code of the vehicles (`GetFromName`, `SetRotate`, `SetTranslate`), clips and channels. No API of its own is needed.
|
||||
- **Palette.** The pass of the renderer which first draws a skinned submodel of an instance in a frame works out the palette of the
|
||||
joints on the CPU (`gfx::skin_cache`, `rendering/common/skincache.cpp`, the maths in `model/skinning.cpp`).
|
||||
- **Vertices.** When the palette changed since the last frame, the vertices are moved before the passes of the next frame, as
|
||||
nothing the passes draw changes while they draw (`gfx::walk_sync`). The positions go by the blended matrix, the normals and the
|
||||
tangents by its rotation.
|
||||
- The Vulkan renderer does it in a compute shader (`shaders/vk14/skin.comp`, `rendering/vulkan14/vulkan14skinning.cpp`): the
|
||||
bind pose with the weights goes to the GPU once for each skinned part, the palette in the ring of the frame, and the kernel
|
||||
writes the vertices straight into the buffer of the bank, over the geometry of the instance. When the bank makes its buffers
|
||||
anew (geometry of an instance made or let go), all the instances skinned on the GPU are moved again.
|
||||
- The OpenGL 4.6 renderer, and Vulkan with `gfx.skinning.gpu 0` (default 1) or without the kernel, moves the vertices on the CPU
|
||||
and replaces the geometry of the instance. Both give the same picture.
|
||||
- The vertices so follow the joints a frame late, and in its first frame an instance is in the bind pose.
|
||||
- While the joints are in the bind pose, the geometry of the model is drawn, shared by all its instances. An instance not drawn
|
||||
for 600 frames lets go of its geometry.
|
||||
- **Limits of this version:** the bounds of a submodel come from the bind pose; motion vectors and ray tracing don't see the moves
|
||||
of the joints.
|
||||
|
||||
### Instancjonowanie modeli ze światłami
|
||||
### Instancing of models with lights
|
||||
|
||||
Z `gfx.instancedlights 1` w `eu07.ini` modele ze światłami (`lights`, `Light_On##` / `Light_Off##`), np. głowice semaforów,
|
||||
są rysowane instancjonowane w obu rendererach, z cullingiem GPU i bez niego. Domyślne `0` rysuje je jak dotąd, każdy
|
||||
egzemplarz osobno. Dotyczy to modeli EU07M i E3D tak samo.
|
||||
With `gfx.instancedlights 1` in `eu07.ini`, models with lights (`lights`, `Light_On##` / `Light_Off##`), such as signal heads, are
|
||||
drawn instanced in both renderers, with the GPU culling and without it. The default `0` draws them as before, each instance on its
|
||||
own. It applies to EU07M and E3D models alike.
|
||||
|
||||
- Stan świateł egzemplarza to słowo w elemencie `[0][3]` macierzy instancji: bity 0–7 pokazują zapalone części slotów, bity
|
||||
8–15 zgaszone, w mantysie liczby o wykładniku 128 (`0x40000000`). Bez tego znacznika shader rysuje wszystko.
|
||||
- Część światła (`model_ubs.light_part`: 0 brak, 1 + slot zapalona, 9 + slot zgaszona) ukryta w danym egzemplarzu dostaje
|
||||
w shaderze macierz zerową (`instance_hides_part()` w `common.glsl`).
|
||||
- Egzemplarz pokazuje całą część zapaloną albo całą zgaszoną. Przy miganiu i przy przełączaniu (`ls_On` / `ls_Off` /
|
||||
`ls_Blink`) zamiana następuje w połowie przejścia (krycie 0,5), a nie płynnym przenikaniem jak bez instancjonowania.
|
||||
Stany stałe wyglądają tak samo jak bez instancjonowania.
|
||||
- Pomiar (Vulkan, 200 głowic `s4ipcpb_dd`): z `gfx.gpucull 0` klatka 9,2 ms → 1,5–2,5 ms i 2400 → 16 drawcalli,
|
||||
z `gfx.gpucull 1` 9,1 ms → 3,0 ms i 2410 → 26 drawcalli.
|
||||
- The light state of an instance is a word in the element `[0][3]` of its instance matrix: bits 0–7 show the lit parts of the
|
||||
slots, bits 8–15 the dark ones, in the mantissa of a float of exponent 128 (`0x40000000`). Without that marker the shader draws
|
||||
everything.
|
||||
- A part of a light (`model_ubs.light_part`: 0 none, 1 + slot lit, 9 + slot dark) the instance doesn't show gets a zero matrix in
|
||||
the shader (`instance_hides_part()` in `common.glsl`).
|
||||
- An instance shows the whole lit part or the whole dark one. Blinking and switching (`ls_On` / `ls_Off` / `ls_Blink`) change over
|
||||
at half the fade (opacity 0.5), not with the cross-fade of the draws instance by instance. Steady states look the same as without
|
||||
the instancing.
|
||||
- Measured (Vulkan, 200 heads `s4ipcpb_dd`): with `gfx.gpucull 0` the frame 9.2 ms → 1.5–2.5 ms and 2400 → 16 draw calls, with
|
||||
`gfx.gpucull 1` 9.1 ms → 3.0 ms and 2410 → 26 draw calls.
|
||||
|
||||
## Zgodność wstecz
|
||||
## Backward compatibility
|
||||
|
||||
E3D i T3D są czytane jak dotąd. Plik `.eu07m` jest wczytywany tylko wtedy, gdy istnieje, za przełącznikiem `modelformat eu07m`
|
||||
w `eu07.ini`. Obecne wydanie nie czyta `.eu07m`.
|
||||
E3D and T3D are read as before. An `.eu07m` file is loaded only when it exists, behind the switch `modelformat eu07m` in
|
||||
`eu07.ini`. The current release doesn't read `.eu07m`.
|
||||
|
||||
Reference in New Issue
Block a user