Skip to content

Instantly share code, notes, and snippets.

@anonhostpi
Created September 7, 2024 16:06
Show Gist options
  • Save anonhostpi/26e8c760e10fdc257d509e7ccae85be9 to your computer and use it in GitHub Desktop.
Save anonhostpi/26e8c760e10fdc257d509e7ccae85be9 to your computer and use it in GitHub Desktop.
A Kaitai Struct for DBPF Geom Entries
meta:
id: geom
file-extension: geom
endian: le
imports:
- path/to/mtnf.ksy
seq:
- id: header
type: header
- id: shader
type: shader
- id: merge_group
type: u4
- id: sort_order
type: u4
- id: vertex_collection
type: vertex_collection
- id: body_count
type: u4
- id: bodies
type: body
repeat: expr
repeat-expr: body_count
- id: skin_controller_index
type: u4
- id: bone_count
type: u4
- id: bones
type: u4
repeat: expr
repeat-expr: bone_count
doc: 32-bit hash of the bone name
# insert TGI block list here
types:
header:
seq:
- id: magic
contents: 'GEOM'
- id: version
type: u4
valid:
any-of: [0x00000005, 0x0000000C]
doc: "see [Sims4Tools \\> GEOM.cs#L129](https://github.com/s4ptacle/Sims4Tools/blob/fff19365a12711879bad26481a393a6fbc62c465/s4pi%20Wrappers/MeshChunks/GEOM.cs#L129C67-L129C77)"
- id: tgi_offset
type: u4
doc: Offset to the reference data from this object's offset -- may also be from this sequence entry's offset
- id: tgi_size
type: u4
shader:
seq:
- id: id
type: u4
doc: "also referred to as 'EmbeddedID' in some tools. see [simswiki \> Sims 3 \> GEOM](https://simswiki.info/wiki.php?title=Sims_3:0x015A1849)"
- id: size
type: u4
if: id != 0
- id: mtnf # Requires definition
type: mtnf
if: id != 0
vertex_collection_count:
seq:
- id: verteces
type: u4
- id: formats
type: u4
vertex_collection:
seq:
- id: count
type: vertex_collection_count
- id: formats
type: vertex_format
repeat: expr
repeat-expr: count.formats
- id: verteces
type: vertex
repeat: expr
repeat-expr: count.verteces
vertex_format:
seq:
- id: type
type: u4
valid:
any-of: [1,2,3,4,5,6,7,10]
doc: |
1. Position
2. Normal
3. UV
4. Bone Assignment
5. Weights
6. Tangent Normal
7. TagVal
10: VertexID
- id: subtype
type: u4
valid:
min: 1
max: 4
- id: size
type: u1
vertex:
seq:
- id: elements
type: vertex_element(_parent.formats[_index].type)
repeat: expr
repeat-expr: _parent.count.formats
vertex_element:
params:
- id: index
type: u4
seq:
- id: content
type:
switch-on: index
cases:
1: vertex_element_position
2: vertex_element_normal
3: vertex_element_uv
4: vertex_element_bone_assignment
5: vertex_element_weights
6: vertex_element_tangent_normal
7: vertex_element_tag_val
10: vertex_element_vertex_id
vertex_element_position:
seq:
- id: x
type: f4
- id: y
type: f4
- id: z
type: f4
vertex_element_normal:
seq:
- id: x
type: f4
- id: y
type: f4
- id: z
type: f4
vertex_element_uv:
seq:
- id: u
type: f4
- id: v
type: f4
vertex_element_bone_assignment:
seq:
- id: bone
type: u32
vertex_element_weights:
seq:
- id: weight
type: f4
repeat: expr
repeat-expr: 4
vertex_element_tangent_normal:
seq:
- id: x
type: f4
- id: y
type: f4
- id: z
type: f4
vertex_element_tag_val:
seq:
- id: value
type: u32
vertex_element_vertex_id:
seq:
- id: id
type: u32
body:
seq:
- id: face_size
type: u1
- id: face_count
type: u4
- id: faces
size: face_size
repeat: expr
repeat-expr: face_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment