Added "Scale" option for PSK import
This commit is contained in:
@@ -176,14 +176,14 @@ def import_psa(context: Context, psa_reader: PsaReader, armature_object: Object,
|
|||||||
action = bpy.data.actions.new(name=action_name)
|
action = bpy.data.actions.new(name=action_name)
|
||||||
|
|
||||||
# Calculate the target FPS.
|
# Calculate the target FPS.
|
||||||
target_fps = sequence.fps
|
match options.fps_source:
|
||||||
if options.fps_source == 'CUSTOM':
|
case 'CUSTOM':
|
||||||
target_fps = options.fps_custom
|
target_fps = options.fps_custom
|
||||||
elif options.fps_source == 'SCENE':
|
case 'SCENE':
|
||||||
target_fps = context.scene.render.fps
|
target_fps = context.scene.render.fps
|
||||||
elif options.fps_source == 'SEQUENCE':
|
case 'SEQUENCE':
|
||||||
target_fps = sequence.fps
|
target_fps = sequence.fps
|
||||||
else:
|
case _:
|
||||||
raise ValueError(f'Unknown FPS source: {options.fps_source}')
|
raise ValueError(f'Unknown FPS source: {options.fps_source}')
|
||||||
|
|
||||||
keyframe_time_dilation = target_fps / sequence.fps
|
keyframe_time_dilation = target_fps / sequence.fps
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class PSK_OT_import(Operator, ImportHelper):
|
|||||||
should_import_vertex_colors: BoolProperty(
|
should_import_vertex_colors: BoolProperty(
|
||||||
default=True,
|
default=True,
|
||||||
options=empty_set,
|
options=empty_set,
|
||||||
name='Vertex Colors',
|
name='Import Vertex Colors',
|
||||||
description='Import vertex colors from PSKX files, if available'
|
description='Import vertex colors, if available'
|
||||||
)
|
)
|
||||||
vertex_color_space: EnumProperty(
|
vertex_color_space: EnumProperty(
|
||||||
name='Vertex Color Space',
|
name='Vertex Color Space',
|
||||||
@@ -42,13 +42,13 @@ class PSK_OT_import(Operator, ImportHelper):
|
|||||||
)
|
)
|
||||||
should_import_vertex_normals: BoolProperty(
|
should_import_vertex_normals: BoolProperty(
|
||||||
default=True,
|
default=True,
|
||||||
name='Vertex Normals',
|
name='Import Vertex Normals',
|
||||||
options=empty_set,
|
options=empty_set,
|
||||||
description='Import vertex normals, if available'
|
description='Import vertex normals, if available'
|
||||||
)
|
)
|
||||||
should_import_extra_uvs: BoolProperty(
|
should_import_extra_uvs: BoolProperty(
|
||||||
default=True,
|
default=True,
|
||||||
name='Extra UVs',
|
name='Import Extra UVs',
|
||||||
options=empty_set,
|
options=empty_set,
|
||||||
description='Import extra UV maps, if available'
|
description='Import extra UV maps, if available'
|
||||||
)
|
)
|
||||||
@@ -63,12 +63,6 @@ class PSK_OT_import(Operator, ImportHelper):
|
|||||||
name='Import Materials',
|
name='Import Materials',
|
||||||
options=empty_set,
|
options=empty_set,
|
||||||
)
|
)
|
||||||
should_reuse_materials: BoolProperty(
|
|
||||||
default=True,
|
|
||||||
name='Reuse Materials',
|
|
||||||
options=empty_set,
|
|
||||||
description='Existing materials with matching names will be reused when available'
|
|
||||||
)
|
|
||||||
should_import_skeleton: BoolProperty(
|
should_import_skeleton: BoolProperty(
|
||||||
default=True,
|
default=True,
|
||||||
name='Import Skeleton',
|
name='Import Skeleton',
|
||||||
@@ -87,10 +81,15 @@ class PSK_OT_import(Operator, ImportHelper):
|
|||||||
)
|
)
|
||||||
should_import_shape_keys: BoolProperty(
|
should_import_shape_keys: BoolProperty(
|
||||||
default=True,
|
default=True,
|
||||||
name='Shape Keys',
|
name='Import Shape Keys',
|
||||||
options=empty_set,
|
options=empty_set,
|
||||||
description='Import shape keys, if available'
|
description='Import shape keys, if available'
|
||||||
)
|
)
|
||||||
|
scale: FloatProperty(
|
||||||
|
name='Scale',
|
||||||
|
default=1.0,
|
||||||
|
soft_min=0.0,
|
||||||
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
psk = read_psk(self.filepath)
|
psk = read_psk(self.filepath)
|
||||||
@@ -106,6 +105,7 @@ class PSK_OT_import(Operator, ImportHelper):
|
|||||||
options.bone_length = self.bone_length
|
options.bone_length = self.bone_length
|
||||||
options.should_import_materials = self.should_import_materials
|
options.should_import_materials = self.should_import_materials
|
||||||
options.should_import_shape_keys = self.should_import_shape_keys
|
options.should_import_shape_keys = self.should_import_shape_keys
|
||||||
|
options.scale = self.scale
|
||||||
|
|
||||||
result = import_psk(psk, context, options)
|
result = import_psk(psk, context, options)
|
||||||
|
|
||||||
@@ -120,24 +120,36 @@ class PSK_OT_import(Operator, ImportHelper):
|
|||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.prop(self, 'should_import_materials')
|
|
||||||
|
row = layout.row()
|
||||||
|
|
||||||
|
col = row.column()
|
||||||
|
col.use_property_split = True
|
||||||
|
col.use_property_decorate = False
|
||||||
|
col.prop(self, 'scale')
|
||||||
|
|
||||||
layout.prop(self, 'should_import_mesh')
|
layout.prop(self, 'should_import_mesh')
|
||||||
row = layout.column()
|
|
||||||
row.use_property_split = True
|
|
||||||
row.use_property_decorate = False
|
|
||||||
if self.should_import_mesh:
|
if self.should_import_mesh:
|
||||||
row.prop(self, 'should_import_vertex_normals')
|
row = layout.row()
|
||||||
row.prop(self, 'should_import_extra_uvs')
|
col = row.column()
|
||||||
row.prop(self, 'should_import_vertex_colors')
|
col.use_property_split = True
|
||||||
|
col.use_property_decorate = False
|
||||||
|
col.prop(self, 'should_import_materials', text='Materials')
|
||||||
|
col.prop(self, 'should_import_vertex_normals', text='Vertex Normals')
|
||||||
|
col.prop(self, 'should_import_extra_uvs', text='Extra UVs')
|
||||||
|
col.prop(self, 'should_import_vertex_colors', text='Vertex Colors')
|
||||||
if self.should_import_vertex_colors:
|
if self.should_import_vertex_colors:
|
||||||
row.prop(self, 'vertex_color_space')
|
col.prop(self, 'vertex_color_space')
|
||||||
row.prop(self, 'should_import_shape_keys')
|
col.prop(self, 'should_import_shape_keys', text='Shape Keys')
|
||||||
|
|
||||||
layout.prop(self, 'should_import_skeleton')
|
layout.prop(self, 'should_import_skeleton')
|
||||||
row = layout.column()
|
|
||||||
row.use_property_split = True
|
|
||||||
row.use_property_decorate = False
|
|
||||||
if self.should_import_skeleton:
|
if self.should_import_skeleton:
|
||||||
row.prop(self, 'bone_length')
|
row = layout.row()
|
||||||
|
col = row.column()
|
||||||
|
col.use_property_split = True
|
||||||
|
col.use_property_decorate = False
|
||||||
|
col.prop(self, 'bone_length')
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class PskImportOptions:
|
|||||||
self.should_import_shape_keys = True
|
self.should_import_shape_keys = True
|
||||||
self.bone_length = 1.0
|
self.bone_length = 1.0
|
||||||
self.should_import_materials = True
|
self.should_import_materials = True
|
||||||
|
self.scale = 1.0
|
||||||
|
|
||||||
|
|
||||||
class ImportBone:
|
class ImportBone:
|
||||||
@@ -51,6 +52,10 @@ class PskImportResult:
|
|||||||
def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
|
def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
|
||||||
result = PskImportResult()
|
result = PskImportResult()
|
||||||
armature_object = None
|
armature_object = None
|
||||||
|
mesh_object = None
|
||||||
|
|
||||||
|
if not options.should_import_mesh and not options.should_import_skeleton:
|
||||||
|
raise Exception('Nothing to import')
|
||||||
|
|
||||||
if options.should_import_skeleton:
|
if options.should_import_skeleton:
|
||||||
# ARMATURE
|
# ARMATURE
|
||||||
@@ -266,6 +271,9 @@ def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
|
|||||||
armature_modifier.object = armature_object
|
armature_modifier.object = armature_object
|
||||||
mesh_object.parent = armature_object
|
mesh_object.parent = armature_object
|
||||||
|
|
||||||
|
root_object = armature_object if options.should_import_skeleton else mesh_object
|
||||||
|
root_object.scale = (options.scale, options.scale, options.scale)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bpy.ops.object.mode_set(mode='OBJECT')
|
bpy.ops.object.mode_set(mode='OBJECT')
|
||||||
except:
|
except:
|
||||||
|
|||||||
Reference in New Issue
Block a user