From cc8370258e28cb3a0a7ccdb7fb157d82a81e1a84 Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Thu, 2 Nov 2023 16:49:34 +0800 Subject: [PATCH] vault backup: 2023-11-02 16:49:34 --- .../转换NinjaRipper Blender Scene To FBX.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/06-DCC/Blender/转换NinjaRipper Blender Scene To FBX.md b/06-DCC/Blender/转换NinjaRipper Blender Scene To FBX.md index 7f6fa20..ad23418 100644 --- a/06-DCC/Blender/转换NinjaRipper Blender Scene To FBX.md +++ b/06-DCC/Blender/转换NinjaRipper Blender Scene To FBX.md @@ -28,4 +28,54 @@ for i in bpy.data.images: bpy.ops.wm.save_as_mainfile() # Export FBX # bpy.ops.export_scene.fbx(fbxPath) +``` + +## 贴图格式转换 +```python + +#dds 转 jpg ------ +import bpy + +for i in bpy.data.images: + i.filepath = i.filepath.replace('.dds', '.jpg') + + +#dds 转 png ------ +import bpy + +for i in bpy.data.images: + i.filepath = i.filepath.replace('.dds', '.png') + +#dds 自动转 tga 并关联 fbx +import bpy + +def convert_image_tga(sourceImagePath): + image = bpy.data.images.load(sourceImagePath) + image.file_format = "TARGA" + image.save_render(sourceImagePath.replace(".dds",".tga")) + +# Pack +bpy.ops.file.pack_all() +# Unpack +blendPath=bpy.data.filepath +fbxPath=blendPath.replace(".blend",".fbx") +print(fbxPath) +bpy.ops.file.unpack_all() +bpy.ops.wm.save_as_mainfile() + +for i in bpy.data.images: + if i.filepath == '': + continue + + currentFilePath=bpy.path.abspath(i.filepath) + print(currentFilePath) + convert_image_tga(currentFilePath) + i.filepath = i.filepath.replace('.dds', '.tga') + +# Save Blender Project +bpy.ops.wm.save_as_mainfile() +# Export FBX + +# bpy.ops.export_scene.fbx(fbxPath) + ``` \ No newline at end of file