BlueRoseNote/06-DCC/Blender/导出PSK_PSA脚本 & 部分UModel AES Key.md

183 lines
8.1 KiB
Markdown
Raw Normal View History

2023-09-07 14:11:06 +08:00
# 导出PSK插件地址
- https://github.com/Befzz/blender3d_import_psk_psa/releases
- https://github.com/DarklightGames/io_scene_psk_psa/releases
2023-09-25 12:41:58 +08:00
# 清空数据
bpy.ops.wm.read_factory_settings(use_empty=True)
2023-08-05 23:06:37 +08:00
# PSK
```python
import bpy
import os
import math
from io_import_scene_unreal_psa_psk_280 import *
pskPath = 'C:\\Users\\BlueRose\\Desktop\\BLUEPROTOCOL\\Game\\Character\\Enemy'
for root, subdirs, files in os.walk(pskPath):
for dirName in subdirs:
print(root + '\\'+ dirName)
for modelroot, modeldirs, modelfiles in os.walk(root + '\\'+ dirName +'\\Model'):
for f in modelfiles:
if f.endswith('.psk'):
psk_file = os.path.join(modelroot, f)
fbx_file = os.path.splitext(psk_file)[0] + ".fbx"
# 清空场景
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
pskimport(psk_file, bReorientBones = False)
# 使用SmoothShading
for obj in bpy.data.objects:
if obj.type=='MESH':
obj.data.use_auto_smooth = True
obj.data.auto_smooth_angle = math.radians(180)
currentmesh = obj.data
for setting in currentmesh.polygons:
setting.use_smooth = True
2023-08-06 09:30:24 +08:00
2023-08-05 23:06:37 +08:00
# 输出骨骼模型
bpy.ops.object.select_all(action='SELECT')
2023-08-05 23:29:45 +08:00
bpy.ops.export_scene.fbx(filepath=fbx_file,add_leaf_bones=False)
```
2023-09-07 16:39:38 +08:00
直接生成fbx版本
```python
import bpy
import os
import math
from io_import_scene_unreal_psa_psk_280 import *
pskPath = 'C:\\Users\\BlueRose\\Desktop\\ScarletNexus\\Game\\Character\\wp\\wp0100\\04_Mesh'
for modelroot, modeldirs, modelfiles in os.walk(pskPath):
for f in modelfiles:
if f.endswith('.psk'):
psk_file = os.path.join(modelroot, f)
fbx_file = os.path.splitext(psk_file)[0] + ".fbx"
# 清空场景
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
pskimport(psk_file, bReorientBones = False)
# 使用SmoothShading
for obj in bpy.data.objects:
if obj.type=='MESH':
obj.data.use_auto_smooth = True
obj.data.auto_smooth_angle = math.radians(180)
currentmesh = obj.data
for setting in currentmesh.polygons:
setting.use_smooth = True
# 输出骨骼模型
bpy.ops.object.select_all(action='SELECT')
bpy.ops.export_scene.fbx(filepath=fbx_file,add_leaf_bones=False)
```
2023-08-05 23:29:45 +08:00
# PSA
2023-08-06 22:52:04 +08:00
注意该脚本因为Blender运行bug会导致输出的FBX文件越来越大越来越慢。一次转换的量不建议超过50个。建议分几个文件夹同时开多个Blender一起转换。
2023-08-05 23:29:45 +08:00
```python
import bpy
import os
import math
from io_import_scene_unreal_psa_psk_280 import *
pskPath = 'C:\\Users\\BlueRose\\Desktop\\BLUEPROTOCOL\\Game\\Character\\Enemy\\E000_00\\Model\\SK_CH_E000_00.psk'
psaDirPath = 'C:\\Users\\BlueRose\\Desktop\\BLUEPROTOCOL\\Game\\Animations\\Enemy\\E000'
# 清空场景并且导入模型
for root, subdirs, files in os.walk(psaDirPath):
for f in files:
if f.endswith('.psa'):
2023-08-06 20:26:32 +08:00
bpy.ops.scene.new(type='EMPTY')
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
pskimport(pskPath, bReorientBones = False, bImportmesh = False, bImportbone = True)
2023-08-05 23:29:45 +08:00
psa_file = os.path.join(root, f)
pskDirPath = os.path.dirname(pskPath)
fbx_file = os.path.join(pskDirPath,f)
fbx_file = os.path.splitext(fbx_file)[0] + ".fbx"
print(fbx_file)
psaimport(psa_file)
2023-08-06 20:26:32 +08:00
2023-08-05 23:29:45 +08:00
bpy.ops.object.select_all(action='SELECT')
bpy.ops.export_scene.fbx(filepath=fbx_file,add_leaf_bones=False)
2023-08-06 20:26:32 +08:00
bpy.ops.scene.new(type='EMPTY')
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
2023-08-06 10:27:19 +08:00
```
2023-09-07 21:42:17 +08:00
## 添加平滑组
```python
import bpy
import os
import math
for obj in bpy.data.objects:
if obj.type=='MESH':
obj.data.use_auto_smooth = True
obj.data.auto_smooth_angle = math.radians(180)
currentmesh = obj.data
for setting in currentmesh.polygons:
setting.use_smooth = True
```
2023-08-06 10:27:19 +08:00
# 其他
2023-08-06 12:26:44 +08:00
获取UModel解包游戏所需的AES Key:https://cs.rin.ru/forum/viewtopic.php?t=100672
## 蓝色协议
AES Key:0xEA9051DDACE1CCF98A0510F0E370BD986A75C74756E0309E6A578A47AF564255
UE版本为4.27.2
## 绯红结系
2023-08-06 13:59:52 +08:00
AES Key:0x48AE8311350417BDC50A440FCD0E98B2FA6BCEAE3EDA8D0E24881F205E6C4540
UE版本为4.26
2023-08-06 15:39:22 +08:00
```bash
2024-02-09 13:00:48 +08:00
D:\OtherTools\GameAssets\umodel_win32\umodel_scarlet_nexus_v5.exe -path=C:\Game\ScarletNexus -out=C:\Users\BlueRose\Desktop\ScarletNexus -game=ue4.26 -aes=0x48AE8311350417BDC50A440FCD0E98B2FA6BCEAE3EDA8D0E24881F205E6C4540
D:\OtherTools\GameAssets\umodel_win32\umodel_scarlet_nexus_v5.exe -path=D:\SteamLibrary\steamapps\common\ScarletNexus -out=C:\Users\BlueRose\Desktop\ScarletNexus -game=ue4.26 -aes=0x48AE8311350417BDC50A440FCD0E98B2FA6BCEAE3EDA8D0E24881F205E6C4540
D:\OtherTools\GameAssets\umodel_win32\umodel_scarlet_nexus_legacy.exe -path=D:\SteamLibrary\steamapps\common\ScarletNexus -out=C:\Users\BlueRose\Desktop\ScarletNexus -game=ue4.26 -aes=0x48AE8311350417BDC50A440FCD0E98B2FA6BCEAE3EDA8D0E24881F205E6C4540
2023-08-06 15:39:22 +08:00
```
2023-08-06 13:59:52 +08:00
需要特殊的UModel进行提取:https://www.gildor.org/smf/index.php/topic,7814.0.html#msg40636
2023-08-06 15:21:38 +08:00
下载地址:https://drive.google.com/file/d/1S_037OmnxY28cQymu8NMwFApsBahFqx6/view
导出动画方法:
1. 选择骨骼模型右键点击Open(add to locate set)之后按o。
2. 选择动画资产AS开头右键点击Open(add to locate set)。
3. 点击Tools - ExportCurrentObject就可以导出指定的动画。
4. 如果选择多个动画的情况下在Blender psk/psa插件中可以勾选`All actions to NLA track`
2023-08-06 15:39:22 +08:00
5. 导出动画时在烘焙动画选项中选择全部动作、NLA片段。所有动画数据都会以NLA Clip的方式存储。
6. 导入UE就可以显示所有的动画数据。
2023-08-06 15:21:38 +08:00
# UModel
2023-08-06 15:39:22 +08:00
## CMD启动
```bash
2023-09-07 13:03:23 +08:00
D:\OtherTools\GameAssets\umodel_win32\umodel_scarlet_nexus_v5.exe -path=C:\Game\ScarletNexus -out=C:\Users\BlueRose\Desktop\ScarletNexus -game=ue4.26 -aes=0x48AE8311350417BDC50A440FCD0E98B2FA6BCEAE3EDA8D0E24881F205E6C4540
2023-08-06 15:39:22 +08:00
```
2023-08-06 15:21:38 +08:00
2023-08-06 15:39:22 +08:00
## 取得资产路径
2023-08-06 15:21:38 +08:00
1. 批量选择动画资产
2. 右键点击Copy package path
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_906_FC_smile_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_901_FC_default_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_906_FC_smile_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_911_FC_angry_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_916_FC_sad_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_921_FC_surprise_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_926_FC_fear_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_931_FC_aversion_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_936_FC_damage_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_937_FC_dead.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_941_FC_serious_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_946_FC_blushing_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_951_FC_ex01_m.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_AL_pose001_ST.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_AL_pose002_ST.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_AL_pose003_ST.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_AL_pose004_ST.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_AL_pose005_ST.uasset
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_AL_pose006_ST.uasset
2023-09-07 16:39:38 +08:00
/Game/Character/ch/ch0200/05_Animation/AS_ch0200_AL_pose007_ST.uasset
# 解决Blender导出问题的根骨骼问题
使用Blender的**Better Fbx Importer & Exporter** addon就可以解决问题。