1
0
mirror of https://github.com/DarklightGames/io_scene_psk_psa.git synced 2024-11-23 22:40:59 +01:00

Implemented feature requested in #87

This commit is contained in:
Colin Basnett 2024-09-09 16:25:22 -07:00
parent 7cc5cbe667
commit b5dba35ac4
3 changed files with 16 additions and 0 deletions

View File

@ -156,6 +156,7 @@ class PSA_OT_import(Operator, ImportHelper):
options.bone_mapping_mode = pg.bone_mapping_mode
options.fps_source = pg.fps_source
options.fps_custom = pg.fps_custom
options.translation_scale = pg.translation_scale
if options.should_use_config_file:
# Read the PSA config file if it exists.
@ -248,6 +249,11 @@ class PSA_OT_import(Operator, ImportHelper):
col.use_property_decorate = False
col.prop(pg, 'bone_mapping_mode')
col = advanced_panel.column()
col.use_property_split = True
col.use_property_decorate = False
col.prop(pg, 'translation_scale', text='Translation Scale')
col = advanced_panel.column(heading='Options')
col.use_property_split = True
col.use_property_decorate = False

View File

@ -103,6 +103,11 @@ class PSA_PG_import(PropertyGroup):
soft_max=1.0,
step=0.0625,
)
translation_scale: FloatProperty(
name='Translation Scale',
default=1.0,
description='Scale factor for bone translation values. Use this when the scale of the armature does not match the PSA file'
)
def filter_sequences(pg: PSA_PG_import, sequences) -> List[int]:

View File

@ -24,6 +24,7 @@ class PsaImportOptions(object):
self.bone_mapping_mode = 'CASE_INSENSITIVE'
self.fps_source = 'SEQUENCE'
self.fps_custom: float = 30.0
self.translation_scale: float = 1.0
self.should_use_config_file = True
self.psa_config: PsaConfig = PsaConfig()
@ -271,6 +272,10 @@ def import_psa(context: Context, psa_reader: PsaReader, armature_object: Object,
# Read the sequence data matrix from the PSA.
sequence_data_matrix = psa_reader.read_sequence_data_matrix(sequence_name)
if options.translation_scale != 1.0:
# Scale the translation data.
sequence_data_matrix[:, :, 4:] *= options.translation_scale
# Convert the sequence's data from world-space to local-space.
for bone_index, import_bone in enumerate(import_bones):
if import_bone is None: