2019-12-02 03:18:05 +01:00
|
|
|
from typing import List
|
2022-04-25 07:08:36 +02:00
|
|
|
|
2024-05-27 23:56:37 +02:00
|
|
|
from ..shared.data import *
|
2019-12-02 03:18:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Psk(object):
|
2021-09-08 06:40:42 +02:00
|
|
|
class Wedge(object):
|
2024-02-06 22:26:48 +01:00
|
|
|
def __init__(self, point_index: int, u: float, v: float, material_index: int = 0):
|
|
|
|
self.point_index: int = point_index
|
|
|
|
self.u: float = u
|
|
|
|
self.v: float = v
|
|
|
|
self.material_index = material_index
|
2021-09-08 06:40:42 +02:00
|
|
|
|
|
|
|
def __hash__(self):
|
|
|
|
return hash(f'{self.point_index}-{self.u}-{self.v}-{self.material_index}')
|
|
|
|
|
2019-12-03 10:27:50 +01:00
|
|
|
class Wedge16(Structure):
|
|
|
|
_fields_ = [
|
2023-08-10 05:14:24 +02:00
|
|
|
('point_index', c_uint32),
|
2019-12-03 10:27:50 +01:00
|
|
|
('u', c_float),
|
|
|
|
('v', c_float),
|
2021-09-08 06:40:42 +02:00
|
|
|
('material_index', c_uint8),
|
2019-12-03 10:27:50 +01:00
|
|
|
('reserved', c_int8),
|
|
|
|
('padding2', c_int16)
|
|
|
|
]
|
|
|
|
|
|
|
|
class Wedge32(Structure):
|
|
|
|
_fields_ = [
|
2021-09-08 06:40:42 +02:00
|
|
|
('point_index', c_uint32),
|
2019-12-03 10:27:50 +01:00
|
|
|
('u', c_float),
|
|
|
|
('v', c_float),
|
2021-09-08 06:40:42 +02:00
|
|
|
('material_index', c_uint32)
|
2019-12-03 10:27:50 +01:00
|
|
|
]
|
2019-12-02 03:18:05 +01:00
|
|
|
|
2019-12-03 10:27:50 +01:00
|
|
|
class Face(Structure):
|
|
|
|
_fields_ = [
|
2021-09-08 06:40:42 +02:00
|
|
|
('wedge_indices', c_uint16 * 3),
|
2022-01-14 21:26:35 +01:00
|
|
|
('material_index', c_uint8),
|
|
|
|
('aux_material_index', c_uint8),
|
2019-12-03 10:27:50 +01:00
|
|
|
('smoothing_groups', c_int32)
|
|
|
|
]
|
2019-12-02 03:18:05 +01:00
|
|
|
|
2022-01-26 04:41:09 +01:00
|
|
|
class Face32(Structure):
|
|
|
|
_pack_ = 1
|
|
|
|
_fields_ = [
|
|
|
|
('wedge_indices', c_uint32 * 3),
|
|
|
|
('material_index', c_uint8),
|
|
|
|
('aux_material_index', c_uint8),
|
|
|
|
('smoothing_groups', c_int32)
|
|
|
|
]
|
|
|
|
|
2019-12-03 10:27:50 +01:00
|
|
|
class Material(Structure):
|
|
|
|
_fields_ = [
|
|
|
|
('name', c_char * 64),
|
|
|
|
('texture_index', c_int32),
|
|
|
|
('poly_flags', c_int32),
|
|
|
|
('aux_material', c_int32),
|
|
|
|
('aux_flags', c_int32),
|
|
|
|
('lod_bias', c_int32),
|
|
|
|
('lod_style', c_int32)
|
|
|
|
]
|
2019-12-02 03:18:05 +01:00
|
|
|
|
2019-12-03 10:27:50 +01:00
|
|
|
class Bone(Structure):
|
|
|
|
_fields_ = [
|
|
|
|
('name', c_char * 64),
|
|
|
|
('flags', c_int32),
|
|
|
|
('children_count', c_int32),
|
|
|
|
('parent_index', c_int32),
|
|
|
|
('rotation', Quaternion),
|
2019-12-10 06:18:51 +01:00
|
|
|
('location', Vector3),
|
2019-12-03 10:27:50 +01:00
|
|
|
('length', c_float),
|
|
|
|
('size', Vector3)
|
|
|
|
]
|
2019-12-02 03:18:05 +01:00
|
|
|
|
2019-12-03 10:27:50 +01:00
|
|
|
class Weight(Structure):
|
|
|
|
_fields_ = [
|
|
|
|
('weight', c_float),
|
|
|
|
('point_index', c_int32),
|
|
|
|
('bone_index', c_int32),
|
|
|
|
]
|
2019-12-02 03:18:05 +01:00
|
|
|
|
2023-04-04 06:28:08 +02:00
|
|
|
class MorphInfo(Structure):
|
|
|
|
_fields_ = [
|
|
|
|
('name', c_char * 64),
|
|
|
|
('vertex_count', c_int32)
|
|
|
|
]
|
|
|
|
|
|
|
|
class MorphData(Structure):
|
|
|
|
_fields_ = [
|
|
|
|
('position_delta', Vector3),
|
|
|
|
('tangent_z_delta', Vector3),
|
|
|
|
('point_index', c_int32)
|
|
|
|
]
|
|
|
|
|
2022-01-26 04:41:09 +01:00
|
|
|
@property
|
|
|
|
def has_extra_uvs(self):
|
|
|
|
return len(self.extra_uvs) > 0
|
|
|
|
|
|
|
|
@property
|
|
|
|
def has_vertex_colors(self):
|
2022-01-26 06:09:47 +01:00
|
|
|
return len(self.vertex_colors) > 0
|
2022-01-26 04:41:09 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def has_vertex_normals(self):
|
2022-01-26 06:09:47 +01:00
|
|
|
return len(self.vertex_normals) > 0
|
2022-01-26 04:41:09 +01:00
|
|
|
|
2023-01-04 05:05:45 +01:00
|
|
|
@property
|
|
|
|
def has_material_references(self):
|
|
|
|
return len(self.material_references) > 0
|
|
|
|
|
2023-04-04 06:28:08 +02:00
|
|
|
@property
|
|
|
|
def has_morph_data(self):
|
|
|
|
return len(self.morph_infos) > 0
|
2023-04-28 04:56:09 +02:00
|
|
|
|
2019-12-02 03:18:05 +01:00
|
|
|
def __init__(self):
|
2019-12-03 10:27:50 +01:00
|
|
|
self.points: List[Vector3] = []
|
2021-09-08 06:40:42 +02:00
|
|
|
self.wedges: List[Psk.Wedge] = []
|
2019-12-02 03:18:05 +01:00
|
|
|
self.faces: List[Psk.Face] = []
|
|
|
|
self.materials: List[Psk.Material] = []
|
|
|
|
self.weights: List[Psk.Weight] = []
|
|
|
|
self.bones: List[Psk.Bone] = []
|
2022-01-26 04:41:09 +01:00
|
|
|
self.extra_uvs: List[Vector2] = []
|
|
|
|
self.vertex_colors: List[Color] = []
|
|
|
|
self.vertex_normals: List[Vector3] = []
|
2023-04-04 06:28:08 +02:00
|
|
|
self.morph_infos: List[Psk.MorphInfo] = []
|
|
|
|
self.morph_data: List[Psk.MorphData] = []
|
2023-01-04 05:05:45 +01:00
|
|
|
self.material_references: List[str] = []
|