mirror of
https://github.com/DarklightGames/io_scene_psk_psa.git
synced 2024-11-28 00:20:48 +01:00
Initial commit for UE1 exec command export
This commit is contained in:
parent
3de1f075dd
commit
bc98c26793
@ -31,6 +31,7 @@ class PsaBuildOptions:
|
|||||||
self.sequence_name_prefix: str = ''
|
self.sequence_name_prefix: str = ''
|
||||||
self.sequence_name_suffix: str = ''
|
self.sequence_name_suffix: str = ''
|
||||||
self.root_motion: bool = False
|
self.root_motion: bool = False
|
||||||
|
self.unreal_engine_1_mode: bool = False
|
||||||
|
|
||||||
|
|
||||||
def _get_pose_bone_location_and_rotation(pose_bone: PoseBone, armature_object: Object, options: PsaBuildOptions):
|
def _get_pose_bone_location_and_rotation(pose_bone: PoseBone, armature_object: Object, options: PsaBuildOptions):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import os.path
|
||||||
import re
|
import re
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from typing import List, Iterable, Dict, Tuple
|
from typing import List, Iterable, Dict, Tuple
|
||||||
@ -10,7 +11,7 @@ from bpy_types import Operator
|
|||||||
|
|
||||||
from .properties import PSA_PG_export, PSA_PG_export_action_list_item, filter_sequences
|
from .properties import PSA_PG_export, PSA_PG_export_action_list_item, filter_sequences
|
||||||
from ..builder import build_psa, PsaBuildSequence, PsaBuildOptions
|
from ..builder import build_psa, PsaBuildSequence, PsaBuildOptions
|
||||||
from ..writer import write_psa
|
from ..writer import write_psa, write_psa_import_commands
|
||||||
from ...helpers import populate_bone_group_list, get_nla_strips_in_frame_range
|
from ...helpers import populate_bone_group_list, get_nla_strips_in_frame_range
|
||||||
|
|
||||||
|
|
||||||
@ -313,8 +314,9 @@ class PSA_OT_export(Operator, ExportHelper):
|
|||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
# ROOT MOTION
|
|
||||||
layout.prop(pg, 'root_motion', text='Root Motion')
|
layout.prop(pg, 'root_motion', text='Root Motion')
|
||||||
|
layout.prop(pg, 'should_write_import_commands', text='Write Import Commands')
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _check_context(cls, context):
|
def _check_context(cls, context):
|
||||||
@ -423,6 +425,12 @@ class PSA_OT_export(Operator, ExportHelper):
|
|||||||
|
|
||||||
write_psa(psa, self.filepath)
|
write_psa(psa, self.filepath)
|
||||||
|
|
||||||
|
if pg.should_write_import_commands:
|
||||||
|
# Replace the extension in the file path to be ".uc" instead of ".psa".
|
||||||
|
# This is because the Unreal Engine 1 import command expects the file to have a ".uc" extension.
|
||||||
|
filepath = os.path.splitext(self.filepath)[0] + '.uc'
|
||||||
|
write_psa_import_commands(psa, filepath)
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,6 +184,12 @@ class PSA_PG_export(PropertyGroup):
|
|||||||
name='Show Reversed',
|
name='Show Reversed',
|
||||||
description='Show reversed sequences'
|
description='Show reversed sequences'
|
||||||
)
|
)
|
||||||
|
should_write_import_commands: BoolProperty(
|
||||||
|
default=True,
|
||||||
|
options=empty_set,
|
||||||
|
name='Write PSA Import Commands',
|
||||||
|
description='Write PSA import commands to a UnrealScript file in the same directory as the exported file'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def filter_sequences(pg: PSA_PG_export, sequences) -> List[int]:
|
def filter_sequences(pg: PSA_PG_export, sequences) -> List[int]:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import os.path
|
||||||
from ctypes import Structure, sizeof
|
from ctypes import Structure, sizeof
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
@ -23,3 +24,15 @@ def write_psa(psa: Psa, path: str):
|
|||||||
write_section(fp, b'BONENAMES', Psa.Bone, psa.bones)
|
write_section(fp, b'BONENAMES', Psa.Bone, psa.bones)
|
||||||
write_section(fp, b'ANIMINFO', Psa.Sequence, list(psa.sequences.values()))
|
write_section(fp, b'ANIMINFO', Psa.Sequence, list(psa.sequences.values()))
|
||||||
write_section(fp, b'ANIMKEYS', Psa.Key, psa.keys)
|
write_section(fp, b'ANIMKEYS', Psa.Key, psa.keys)
|
||||||
|
|
||||||
|
|
||||||
|
def write_psa_import_commands(psa: Psa, path: str):
|
||||||
|
anim = os.path.splitext(os.path.basename(path))[0]
|
||||||
|
with open(path, 'w') as fp:
|
||||||
|
for sequence_name, sequence in psa.sequences.items():
|
||||||
|
fp.write(f'#EXEC ANIM SEQUENCE '
|
||||||
|
f'ANIM={anim} '
|
||||||
|
f'SEQ={sequence_name} '
|
||||||
|
f'STARTFRAME={sequence.frame_start_index} '
|
||||||
|
f'NUMFRAMES={sequence.frame_count} '
|
||||||
|
f'RATE={sequence.fps}\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user