2022-01-16 05:52:02 +01:00
|
|
|
import typing
|
|
|
|
from collections import OrderedDict
|
2022-04-25 07:08:36 +02:00
|
|
|
from typing import List
|
|
|
|
|
2024-05-27 23:56:37 +02:00
|
|
|
from ..shared.data import *
|
2019-12-10 11:52:09 +01:00
|
|
|
|
2024-01-23 00:23:01 +01:00
|
|
|
'''
|
2022-01-15 06:04:18 +01:00
|
|
|
Note that keys are not stored within the Psa object.
|
2022-11-01 19:32:50 +01:00
|
|
|
Use the PsaReader::get_sequence_keys to get the keys for a sequence.
|
2024-01-23 00:23:01 +01:00
|
|
|
'''
|
2019-12-13 20:29:12 +01:00
|
|
|
|
2019-12-10 11:52:09 +01:00
|
|
|
|
2023-01-03 04:36:31 +01:00
|
|
|
class Psa:
|
2019-12-10 11:52:09 +01:00
|
|
|
class Bone(Structure):
|
|
|
|
_fields_ = [
|
|
|
|
('name', c_char * 64),
|
|
|
|
('flags', c_int32),
|
|
|
|
('children_count', c_int32),
|
|
|
|
('parent_index', c_int32),
|
|
|
|
('rotation', Quaternion),
|
|
|
|
('location', Vector3),
|
|
|
|
('padding', c_char * 16)
|
|
|
|
]
|
|
|
|
|
|
|
|
class Sequence(Structure):
|
|
|
|
_fields_ = [
|
|
|
|
('name', c_char * 64),
|
|
|
|
('group', c_char * 64),
|
|
|
|
('bone_count', c_int32),
|
|
|
|
('root_include', c_int32),
|
|
|
|
('compression_style', c_int32),
|
2021-09-07 09:02:59 +02:00
|
|
|
('key_quotum', c_int32),
|
2019-12-10 11:52:09 +01:00
|
|
|
('key_reduction', c_float),
|
|
|
|
('track_time', c_float),
|
|
|
|
('fps', c_float),
|
|
|
|
('start_bone', c_int32),
|
|
|
|
('frame_start_index', c_int32),
|
|
|
|
('frame_count', c_int32)
|
|
|
|
]
|
|
|
|
|
|
|
|
class Key(Structure):
|
|
|
|
_fields_ = [
|
|
|
|
('location', Vector3),
|
|
|
|
('rotation', Quaternion),
|
|
|
|
('time', c_float)
|
|
|
|
]
|
|
|
|
|
2022-01-19 11:55:10 +01:00
|
|
|
@property
|
|
|
|
def data(self):
|
|
|
|
yield self.rotation.w
|
|
|
|
yield self.rotation.x
|
|
|
|
yield self.rotation.y
|
|
|
|
yield self.rotation.z
|
|
|
|
yield self.location.x
|
|
|
|
yield self.location.y
|
|
|
|
yield self.location.z
|
|
|
|
|
2022-01-15 06:04:18 +01:00
|
|
|
def __repr__(self) -> str:
|
|
|
|
return repr((self.location, self.rotation, self.time))
|
|
|
|
|
2019-12-10 11:52:09 +01:00
|
|
|
def __init__(self):
|
|
|
|
self.bones: List[Psa.Bone] = []
|
2022-11-01 19:32:50 +01:00
|
|
|
self.sequences: typing.OrderedDict[str, Psa.Sequence] = OrderedDict()
|
2022-01-16 05:52:02 +01:00
|
|
|
self.keys: List[Psa.Key] = []
|