Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.2 importer options change and root motion properties #162

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions i_scene_cp77_gltf/cyber_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def add_anim_props(animation, action):
# Extract properties from animation
schema = extras.get("schema", "")
animation_type = extras.get("animationType", "")
rootMotion_type = extras.get("rootMotionType"),"")
frame_clamping = extras.get("frameClamping", False)
frame_clamping_start_frame = extras.get("frameClampingStartFrame", -1)
frame_clamping_end_frame = extras.get("frameClampingEndFrame", -1)
Expand All @@ -272,6 +273,7 @@ def add_anim_props(animation, action):
action["schema"] = schema
# action["schemaVersion"] = schema['version']
action["animationType"] = animation_type
action["rootMotionType"] = rootMotion_type
action["frameClamping"] = frame_clamping
action["frameClampingStartFrame"] = frame_clamping_start_frame
action["frameClampingEndFrame"] = frame_clamping_end_frame
Expand Down
23 changes: 13 additions & 10 deletions i_scene_cp77_gltf/importers/import_with_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ def CP77GLBimport(self, exclude_unused_mats=True, image_format='png', with_mater
for f in loadfiles:
filename=os.path.splitext(f['name'])[0]
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":'BLENDER', "guess_original_bind_pose" : False, "import_user_extensions": "",'disable_bone_shape':False})
vers = bpy.app.version
if vers[0] >= 4.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})
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.read()
gltf_importer.checks()
existingMeshes = bpy.data.meshes.keys()
Expand Down Expand Up @@ -173,8 +176,8 @@ def CP77GLBimport(self, exclude_unused_mats=True, image_format='png', with_mater

import_mats(current_file_base_path, DepotPath, exclude_unused_mats, existingMeshes, gltf_importer, image_format, obj,
validmats)
if not cp77_addon_prefs.non_verbose:
print(f"GLB Import Time: {(time.time() - start_time)} Seconds")
if not cp77_addon_prefs.non_verbose:
print(f"GLB Import Time: {(time.time() - start_time)} Seconds")
print('')
print('-------------------- Finished importing Cyberpunk 2077 Model --------------------')

Expand Down Expand Up @@ -263,13 +266,13 @@ def import_mats(BasePath, DepotPath, exclude_unused_mats, existingMeshes, gltf_i
index = index + 1

counter = counter + 1
if not cp77_addon_prefs.non_verbose:
if not cp77_addon_prefs.non_verbose:
if len(failedon) == 0:
print(f"Shader Setup Completed Succesfully in {(time.time() - start_time)} Seconds")
else:
print(f"Material Setup Failed on: {', '.join(failedon)}")
print(f"Attempted Setup for {(time.time() - start_time)} seconds")

if exclude_unused_mats:
return

Expand All @@ -279,7 +282,7 @@ def import_mats(BasePath, DepotPath, exclude_unused_mats, existingMeshes, gltf_i
(rawmat["Name"] in MatImportList) or len(MatImportList) < 1):
Builder.create(index)
index = index + 1

def blender_4_scale_armature_bones():
vers = bpy.app.version
if vers[0] >= 4:
Expand Down Expand Up @@ -308,10 +311,10 @@ def import_meshes_and_anims(collection, gltf_importer, hide_armatures, o):
if meshes and "Icosphere" not in mesh.name:
if 'Armature' in o.name:
o.hide_set(hide_armatures)
else:
else:
if 'Armature' in o.name:
pass

else:
if 'Armature' in o.name:
o.hide_set(hide_armatures)
o.hide_set(hide_armatures)
Loading