src.mkds_extensions package¶
Submodules¶
src.mkds_extensions.kcl_torch module¶
- class src.mkds_extensions.kcl_torch.PrismsTensor(_height: Sequence[float], _pos_i: Sequence[int], _fnrm_i: Sequence[int], _enrm1_i: Sequence[int], _enrm2_i: Sequence[int], _enrm3_i: Sequence[int], _attributes: Sequence[Sequence[int]], device=None)[source]¶
Bases:
PrismsBase
Represents the triangular prisms section of the KCL file.
Each prism is a 0x10 byte structure with the following layout:
Prism Entry Layout (Size:
0x10
)¶Offset
Type
Name
Description
0x00
f32
height
Prism height from vertex 1 to opposite side
0x04
u16
pos_i
Index of first vertex in positions array
0x06
u16
fnrm_i
Face normal index
0x08
u16
enrm1_i
Edge normal A index
0x0A
u16
enrm2_i
Edge normal B index
0x0C
u16
enrm3_i
Edge normal C index
0x0E
u16
attributes
Collision attributes
- _height¶
Prism heights
- Type:
list[float]
- _pos_i¶
Vertex indices
- Type:
list[int]
- _fnrm_i¶
Face normal indices
- Type:
list[int]
- _enrm1_i¶
Edge normal 1 indices
- Type:
list[int]
- _enrm2_i¶
Edge normal 2 indices
- Type:
list[int]
- _enrm3_i¶
Edge normal 3 indices
- Type:
list[int]
- _attributes¶
Collision attribute flags
- Type:
list[int]
- property map_2d_shadow¶
- property light_id¶
- property ignore_drivers¶
- property collision_variant¶
- property collision_type¶
- property ignore_items¶
- property is_wall¶
- property is_floor¶
- class src.mkds_extensions.kcl_torch.KCLTensor(data: bytes, prisms: PrismsTensor, positions: Sequence[Sequence[float]], normals: Sequence[Sequence[float]], _positions_offset: int, _normals_offset: int, _prisms_offset: int, _block_data_offset: int, _prism_thickness: float, _area_min_pos: tuple[float, float, float], _area_x_width_mask: int, _area_y_width_mask: int, _area_z_width_mask: int, _block_width_shift: int, _area_x_blocks_shift: int, _area_xy_blocks_shift: int, _sphere_radius: int | None, device=None)[source]¶
Bases:
KCLBase
Represents a KCL (collision) file.
KCL files store simplified model data for collision detection in games such as Mario Kart Wii / DS. They consist of a header, positions, normals, triangular prisms, and octree blocks.
Header Layout¶
Offset
Type
Name
Description
0x00
u32
positions_offset
Offset to vertex positions section
0x04
u32
normals_offset
Offset to normal vectors section
0x08
u32
prisms_offset
Offset to triangular prisms section
0x0C
u32
block_data_offset
Offset to octree blocks
0x10
f32
prism_thickness
Depth of triangular prism along normal
0x14
Vec3
area_min_pos
Minimum coordinates of model bounding box
0x20
u32
area_x_width_mask
X-axis mask for octree
0x24
u32
area_y_width_mask
Y-axis mask for octree
0x28
u32
area_z_width_mask
Z-axis mask for octree
0x2C
u32
block_width_shift
Octree leaf block size shift
0x30
u32
area_x_blocks_shift
Root child index shift (Y axis)
0x34
u32
area_xy_blocks_shift
Root child index shift (Z axis)
0x38
f32?
sphere_radius
Optional: max sphere radius for collisions
- _positions_offset¶
File offset to position vectors
- Type:
int
- _normals_offset¶
File offset to normal vectors
- Type:
int
- _prisms_offset¶
File offset to prism data
- Type:
int
- _block_data_offset¶
File offset to octree blocks
- Type:
int
- _prism_thickness¶
Depth of each prism
- Type:
float
- _area_min_pos¶
Minimum coordinates of the collision area
- Type:
list[float]
- _area_x_width_mask¶
X-axis mask for octree
- Type:
int
- _area_y_width_mask¶
Y-axis mask for octree
- Type:
int
- _area_z_width_mask¶
Z-axis mask for octree
- Type:
int
- _block_width_shift¶
Octree leaf size shift
- Type:
int
- _area_x_blocks_shift¶
Root block child index shift (Y)
- Type:
int
- _area_xy_blocks_shift¶
Root block child index shift (Z)
- Type:
int
- _sphere_radius¶
Optional maximum sphere radius for collisions
- Type:
float or None
- _positions¶
List of vertex positions
- Type:
list
- _normals¶
List of normal vectors
- Type:
list
- prism_cls¶
alias of
PrismsTensor