From 3bb49fdc9459b57ba794aaf6e099001a0f0e6680 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Thu, 7 Mar 2024 21:39:07 -0800 Subject: [PATCH] openJSON: normalize paths to support loading materials on other OSes Even if Wolvenkit doesn't work on linux properly today, Blender does, and getting Blender to run in a VM is hard. So it's not crazy to end up running Wolvenkit in a VM and Blender on the Linux host. In these situations, if you set up appropriate shared storage, you can make all the material files available on the Linux side, but the Material json produced by an export is using '\\' for the path separator. This change normalises paths to use the current OS separator, so all the user has to do is adjust the depot path in the Material json to match the other side and materials will import. This should also help for MacOS. --- i_scene_cp77_gltf/main/common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/i_scene_cp77_gltf/main/common.py b/i_scene_cp77_gltf/main/common.py index 59108c2..b591de2 100644 --- a/i_scene_cp77_gltf/main/common.py +++ b/i_scene_cp77_gltf/main/common.py @@ -138,6 +138,10 @@ def json_ver_validate( json_data): return True def openJSON(path, mode='r', ProjPath='', DepotPath=''): + path = path.replace('\\', os.sep) + ProjPath = ProjPath.replace('\\', os.sep) + DepotPath = DepotPath.replace('\\', os.sep) + inproj=os.path.join(ProjPath,path) if os.path.exists(inproj): file = open(inproj,mode) @@ -666,4 +670,4 @@ def createHash12Group(): CurMat.links.new(separate2.outputs[2],mul.inputs[1]) CurMat.links.new(mul.outputs[0],frac2.inputs[0]) CurMat.links.new(frac2.outputs[0],GroupOutput.inputs[0]) - return CurMat \ No newline at end of file + return CurMat