Skip to content

Commit

Permalink
Merge pull request #197 from Simarilius-uk/OS_support
Browse files Browse the repository at this point in the history
Options for bone heuristic and Bone Shape
  • Loading branch information
Simarilius-uk authored Jan 20, 2025
2 parents 59411dc + ef4b8b3 commit 0e2f673
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
19 changes: 18 additions & 1 deletion i_scene_cp77_gltf/cyber_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ class CP77IOSuitePreferences(AddonPreferences):
subtype='DIR_PATH',
default="//MaterialDepot"
)

enable_temperance: BoolProperty(
name= "Enable the Temperance bone heuristic MAY BREAK ANIM EXPORT",
description="Switch the bone heuristic back to TEMPERANCE, may break anim export",
default=False,
)
enable_octo: BoolProperty(
name= "Enable the Octohedral bone representation",
description="Probably want to use with the temperance option above",
default=False,
)

# toggle the mod tools tab and its sub panels - default True
show_modtools: BoolProperty(
Expand Down Expand Up @@ -78,6 +87,14 @@ def draw(self, context):
row = box.row()
row.prop(self, "depotfolder_path", text="")
row = box.row()
# Toggle for temperance bone heuristic
box = layout.box()
box.label(text="Enable Temperance Bone Heuristic (MAY BREAK ANIM EXPORT):")
row = box.row()
row.prop(self, "enable_temperance",toggle=1)
row = box.row()
row.prop(self, "enable_octo",toggle=1)
row = box.row()
if self.show_modtools:
row.alignment = 'LEFT'
box = layout.box()
Expand Down
14 changes: 10 additions & 4 deletions i_scene_cp77_gltf/importers/import_with_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ def CP77GLBimport(self, with_materials, remap_depot, exclude_unused_mats=True, i
file_paths.append(os.path.join(directory, f['name']))

# check materials
heuristic='BLENDER'
if cp77_addon_prefs.enable_temperance:
heuristic='TEMPERANCE'
octos=False
if cp77_addon_prefs.enable_octo:
octos=True

#Kwek: Gate this--do the block iff corresponding Material.json exist
#Kwek: was tempted to do a try-catch, but that is just La-Z
Expand All @@ -95,9 +101,9 @@ def CP77GLBimport(self, with_materials, remap_depot, exclude_unused_mats=True, i
filepath = os.path.join(directory, f['name'])
vers = bpy.app.version
if vers[0] == 4 and vers[1] >= 2:
gltf_importer = glTFImporter(filepath, { "files": None, "loglevel": 0, "import_pack_images" :True, "merge_vertices" :False, "import_shading" : 'NORMALS', "bone_heuristic":'BLENDER', "guess_original_bind_pose" : False, "import_user_extensions": "",'disable_bone_shape':False, 'bone_shape_scale_factor':1.0})
gltf_importer = glTFImporter(filepath, { "files": None, "loglevel": 0, "import_pack_images" :True, "merge_vertices" :False, "import_shading" : 'NORMALS', "bone_heuristic":heuristic, "guess_original_bind_pose" : False, "import_user_extensions": "",'disable_bone_shape':octos, 'bone_shape_scale_factor':1.0})
else:
gltf_importer = glTFImporter(filepath, { "files": None, "loglevel": 0, "import_pack_images" :True, "merge_vertices" :False, "import_shading" : 'NORMALS', "bone_heuristic":'BLENDER', "guess_original_bind_pose" : False, "import_user_extensions": "",'disable_bone_shape':False,})
gltf_importer = glTFImporter(filepath, { "files": None, "loglevel": 0, "import_pack_images" :True, "merge_vertices" :False, "import_shading" : 'NORMALS', "bone_heuristic":heuristic, "guess_original_bind_pose" : False, "import_user_extensions": "",'disable_bone_shape':octos,})
gltf_importer.read()
gltf_importer.checks()
existingMeshes = bpy.data.meshes.keys()
Expand Down Expand Up @@ -157,8 +163,8 @@ def CP77GLBimport(self, with_materials, remap_depot, exclude_unused_mats=True, i

#DepotPath = str(obj["MaterialRepo"]) + "\\"
context=bpy.context
if remap_depot and os.path.exists(context.preferences.addons[__name__.split('.')[0]].preferences.depotfolder_path):
DepotPath = context.preferences.addons[__name__.split('.')[0]].preferences.depotfolder_path
if remap_depot and os.path.exists(cp77_addon_prefs.depotfolder_path):
DepotPath = cp77_addon_prefs.depotfolder_path
if not cp77_addon_prefs.non_verbose:
print(f"Using depot path: {DepotPath}")
DepotPath= DepotPath.replace('\\', os.sep)
Expand Down

0 comments on commit 0e2f673

Please sign in to comment.