feat: add ava display

This commit is contained in:
BennyKok
2023-09-26 16:49:12 +08:00
parent 5ebb9c4a18
commit 3bc93d10c8
2 changed files with 16 additions and 5 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ class AvatarMainOutput(blender_node.ObjectOps):
"multiline": False,
"default": "out"
}),
"model_type": (["GLB", "GLTF_EMBEDDED"],),
"model_type": (["AVA","GLB", "GLTF_EMBEDDED"],),
"write_mode": (["Overwrite", "Increment"],),
"SHAPE_FLOW": ("SHAPE_FLOW",),
+15 -4
View File
@@ -210,18 +210,29 @@ def export_gltf(output_dir, bpy_objects, filename, model_type, write_mode, metad
for obj in bpy_objects:
obj.select_set(True)
filepath = output_dir + "/" + filename + '.' + ("glb" if model_type == "GLB" else "gltf")
def get_file_extension(model_type):
if model_type == "GLB":
return ".glb"
elif model_type == "GLTF_EMBEDDED":
return ".gltf"
elif model_type == "GLTF_SEPARATE":
return ".gltf"
elif model_type == "AVA":
return ".ava"
ext = get_file_extension(model_type)
filepath = output_dir + "/" + filename + '.' + ext
if write_mode == "Increment":
count = 0
# while file exists, increment count
while os.path.exists(output_dir + "/" + filename + '_' + str(count) + '.' + ("glb" if model_type == "GLB" else "gltf")):
while os.path.exists(output_dir + "/" + filename + '_' + str(count) + '.' + ext):
count += 1
filepath = output_dir + "/" + filename + '_' + str(count) + '.' + ("glb" if model_type == "GLB" else "gltf")
filepath = output_dir + "/" + filename + '_' + str(count) + '.' + ext
with bpy.context.temp_override(**override):
bpy.ops.export_scene.gltf(filepath=filepath, export_format=model_type, use_selection=True, export_extras=True)
bpy.ops.export_scene.gltf(filepath=filepath, export_format="GLB" if model_type == "AVA" else model_type, use_selection=True, export_extras=True)
# print(filepath)
return filepath