Skip to content

Commit

Permalink
Merge pull request WolvenKit#9 from kwekmaster/filePathRestoration
Browse files Browse the repository at this point in the history
Integrating Simarilius changes as-is to restore filepath functionality
  • Loading branch information
dragonzkiller authored Nov 5, 2022
2 parents dac73b0 + bf3def5 commit 958e02f
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions i_scene_cp77_gltf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,31 @@ def draw(self, context):


def execute(self, context):
directory = self.directory

for f in self.files:
filepath = os.path.join(directory, f.name)
loadfiles=self.files


# prevent crash if no directory supplied when using filepath
if len(self.directory)>0:
directory = self.directory
else:
directory = os.path.dirname(self.filepath)

#kwekmaster: modified to reflect user choice
print(filepath + " Loaded; With materials: "+str(self.with_materials))

#if no files were supplied and a filepath is populate the files from the filepath
if len(loadfiles)==0 and len(self.filepath)>0:
f={}
f['name']=os.path.basename(self.filepath)
loadfiles=(f,)


for f in loadfiles:
filepath = os.path.join(directory, f['name'])

gltf_importer = glTFImporter(filepath, { "files": None, "loglevel": 0, "import_pack_images" :True, "merge_vertices" :False, "import_shading" : 'NORMALS', "bone_heuristic":'TEMPERANCE', "guess_original_bind_pose" : False, "import_user_extensions": ""})
gltf_importer.read()
gltf_importer.checks()


#kwekmaster: modified to reflect user choice
print(filepath + " Loaded; With materials: "+str(self.with_materials))

existingMeshes = bpy.data.meshes.keys()
existingObjects = bpy.data.objects.keys()
Expand Down Expand Up @@ -170,7 +183,7 @@ def execute(self, context):
index = index + 1


collection = bpy.data.collections.new(os.path.splitext(f.name)[0])
collection = bpy.data.collections.new(os.path.splitext(f['name'])[0])
bpy.context.scene.collection.children.link(collection)

for name in bpy.data.objects.keys():
Expand Down

0 comments on commit 958e02f

Please sign in to comment.