Merge branch 'main' into viseme-dev
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
import bpy
|
||||||
|
|
||||||
|
# Importers which don't need much code should be added here, however if a importer needs alot of code
|
||||||
|
# Like the PMX and PMD importers, they should be added to their own files.
|
||||||
|
|
||||||
|
|
||||||
|
# FBX Importer settings borrowed form Cat's Blender Plugin
|
||||||
|
def import_fbx(filepath):
|
||||||
|
try:
|
||||||
|
bpy.ops.import_scene.fbx(
|
||||||
|
filepath=filepath,
|
||||||
|
automatic_bone_orientation=False,
|
||||||
|
use_prepost_rot=False,
|
||||||
|
use_anim=False
|
||||||
|
)
|
||||||
|
except (TypeError, ValueError) as e:
|
||||||
|
print(f"Error importing FBX: {str(e)}")
|
||||||
+19
-5
@@ -13,6 +13,8 @@ def register() -> None:
|
|||||||
update=update_language
|
update=update_language
|
||||||
)
|
)
|
||||||
|
|
||||||
|
bpy.types.Scene.avatar_toolkit_language_changed = bpy.props.BoolProperty(default=False)
|
||||||
|
|
||||||
bpy.types.Scene.mouth_a = bpy.props.StringProperty(
|
bpy.types.Scene.mouth_a = bpy.props.StringProperty(
|
||||||
name=t("Scene.mouth_a.label"),
|
name=t("Scene.mouth_a.label"),
|
||||||
description=t("Scene.mouth_a.desc")
|
description=t("Scene.mouth_a.desc")
|
||||||
@@ -34,8 +36,20 @@ def register() -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def unregister() -> None:
|
def unregister() -> None:
|
||||||
del bpy.types.Scene.avatar_toolkit_language
|
if hasattr(bpy.types.Scene, "avatar_toolkit_language"):
|
||||||
del bpy.types.Scene.mouth_a
|
del bpy.types.Scene.avatar_toolkit_language
|
||||||
del bpy.types.Scene.mouth_o
|
|
||||||
del bpy.types.Scene.mouth_ch
|
if hasattr(bpy.types.Scene, "avatar_toolkit_language_changed"):
|
||||||
del bpy.types.Scene.shape_intensity
|
del bpy.types.Scene.avatar_toolkit_language_changed
|
||||||
|
|
||||||
|
if hasattr(bpy.types.Scene, "mouth_a"):
|
||||||
|
del bpy.types.Scene.mouth_a
|
||||||
|
|
||||||
|
if hasattr(bpy.types.Scene, "mouth_o"):
|
||||||
|
del bpy.types.Scene.mouth_o
|
||||||
|
|
||||||
|
if hasattr(bpy.types.Scene, "mouth_ch"):
|
||||||
|
del bpy.types.Scene.mouth_ch
|
||||||
|
|
||||||
|
if hasattr(bpy.types.Scene, "shape_intensity"):
|
||||||
|
del bpy.types.Scene.shape_intensity
|
||||||
|
|||||||
@@ -113,4 +113,3 @@ def toposort(deps_dict):
|
|||||||
deps_dict = {value : deps_dict[value] - sorted_values for value in unsorted}
|
deps_dict = {value : deps_dict[value] - sorted_values for value in unsorted}
|
||||||
|
|
||||||
return sorted_list
|
return sorted_list
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,10 @@ def update_language(self, context):
|
|||||||
print(f"Updating language to: {self.avatar_toolkit_language}") # Debug print
|
print(f"Updating language to: {self.avatar_toolkit_language}") # Debug print
|
||||||
save_preference("language", int(self.avatar_toolkit_language))
|
save_preference("language", int(self.avatar_toolkit_language))
|
||||||
load_translations()
|
load_translations()
|
||||||
# Reload the addon
|
# Set a flag to indicate that a language change has occurred
|
||||||
bpy.ops.script.reload()
|
context.scene.avatar_toolkit_language_changed = True
|
||||||
|
# Show popup after language change
|
||||||
|
bpy.ops.avatar_toolkit.translation_restart_popup('INVOKE_DEFAULT')
|
||||||
|
|
||||||
# Initial load of translations
|
# Initial load of translations
|
||||||
print("Performing initial load of translations") # Debug print
|
print("Performing initial load of translations") # Debug print
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"messages": {
|
"authors": ["Avatar Toolkit Team"],
|
||||||
|
"messages": {
|
||||||
"Language.auto": "Automatic",
|
"Language.auto": "Automatic",
|
||||||
"Language.en_US": "English",
|
"Language.en_US": "English",
|
||||||
"Language.ja_JP": "日本語",
|
"Language.ja_JP": "日本語",
|
||||||
@@ -45,6 +46,10 @@
|
|||||||
"AutoVisemeButton.error.noShapekeys": "No shape keys found",
|
"AutoVisemeButton.error.noShapekeys": "No shape keys found",
|
||||||
"AutoVisemeButton.error.selectShapekeys": "Please Select shape keys",
|
"AutoVisemeButton.error.selectShapekeys": "Please Select shape keys",
|
||||||
"AutoVisemeButton.success": "Visemes created successfully"
|
"AutoVisemeButton.success": "Visemes created successfully"
|
||||||
|
"Settings.translation_restart_popup.label": "Translation Update",
|
||||||
|
"Settings.translation_restart_popup.description": "Information about translation updates",
|
||||||
|
"Settings.translation_restart_popup.message1": "Some translations may not apply",
|
||||||
|
"Settings.translation_restart_popup.message2": "until you restart Blender."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"authors": ["Avatar Toolkit Team"],
|
||||||
"messages": {
|
"messages": {
|
||||||
"Language.auto": "自動",
|
"Language.auto": "自動",
|
||||||
"Language.en_US": "英語",
|
"Language.en_US": "英語",
|
||||||
@@ -45,5 +46,10 @@
|
|||||||
"AutoVisemeButton.error.noShapekeys": "シェイプキーが見つかりません",
|
"AutoVisemeButton.error.noShapekeys": "シェイプキーが見つかりません",
|
||||||
"AutoVisemeButton.error.selectShapekeys": "シェイプキーを選択してください",
|
"AutoVisemeButton.error.selectShapekeys": "シェイプキーを選択してください",
|
||||||
"AutoVisemeButton.success": "ビセームが正常に作成されました"
|
"AutoVisemeButton.success": "ビセームが正常に作成されました"
|
||||||
|
"Settings.language.desc": "アドオンのUI言語を選択してください",
|
||||||
|
"Settings.translation_restart_popup.label": "翻訳の更新",
|
||||||
|
"Settings.translation_restart_popup.description": "翻訳の更新に関する情報",
|
||||||
|
"Settings.translation_restart_popup.message1": "一部の翻訳は適用されない場合があります",
|
||||||
|
"Settings.translation_restart_popup.message2": "Blenderを再起動するまで。"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from ..functions.translations import t
|
|||||||
|
|
||||||
from ..core.import_pmx import import_pmx
|
from ..core.import_pmx import import_pmx
|
||||||
from ..core.import_pmd import import_pmd
|
from ..core.import_pmd import import_pmd
|
||||||
|
from ..core.importer import import_fbx
|
||||||
|
|
||||||
@register_wrap
|
@register_wrap
|
||||||
class AvatarToolkitQuickAccessPanel(bpy.types.Panel):
|
class AvatarToolkitQuickAccessPanel(bpy.types.Panel):
|
||||||
@@ -48,6 +49,7 @@ class AVATAR_TOOLKIT_OT_import_menu(bpy.types.Operator):
|
|||||||
layout.label(text="Select Import Method")
|
layout.label(text="Select Import Method")
|
||||||
layout.operator("avatar_toolkit.import_pmx", text=t("Quick_Access.import_pmx"))
|
layout.operator("avatar_toolkit.import_pmx", text=t("Quick_Access.import_pmx"))
|
||||||
layout.operator("avatar_toolkit.import_pmd", text=t("Quick_Access.import_pmd"))
|
layout.operator("avatar_toolkit.import_pmd", text=t("Quick_Access.import_pmd"))
|
||||||
|
layout.operator("avatar_toolkit.import_fbx", text="Import FBX")
|
||||||
|
|
||||||
@register_wrap
|
@register_wrap
|
||||||
class AVATAR_TOOLKIT_OT_export_menu(bpy.types.Operator):
|
class AVATAR_TOOLKIT_OT_export_menu(bpy.types.Operator):
|
||||||
@@ -55,6 +57,10 @@ class AVATAR_TOOLKIT_OT_export_menu(bpy.types.Operator):
|
|||||||
bl_label = t("Quick_Access.export_menu.label")
|
bl_label = t("Quick_Access.export_menu.label")
|
||||||
bl_description = t("Quick_Access.import_pmx.desc")
|
bl_description = t("Quick_Access.import_pmx.desc")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return any(obj.type == 'MESH' for obj in context.scene.objects)
|
||||||
|
|
||||||
def execute(self, context: Context):
|
def execute(self, context: Context):
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@@ -66,6 +72,7 @@ class AVATAR_TOOLKIT_OT_export_menu(bpy.types.Operator):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.label(text=t("Quick_Access.select_export.label"))
|
layout.label(text=t("Quick_Access.select_export.label"))
|
||||||
layout.operator("avatar_toolkit.export_resonite", text=t("Quick_Access.select_export_resonite.label"))
|
layout.operator("avatar_toolkit.export_resonite", text=t("Quick_Access.select_export_resonite.label"))
|
||||||
|
layout.operator("avatar_toolkit.export_fbx", text="Export FBX")
|
||||||
|
|
||||||
@register_wrap
|
@register_wrap
|
||||||
class AVATAR_TOOLKIT_OT_import_pmx(bpy.types.Operator):
|
class AVATAR_TOOLKIT_OT_import_pmx(bpy.types.Operator):
|
||||||
@@ -96,3 +103,31 @@ class AVATAR_TOOLKIT_OT_import_pmd(bpy.types.Operator):
|
|||||||
def invoke(self, context: Context, event):
|
def invoke(self, context: Context, event):
|
||||||
context.window_manager.fileselect_add(self)
|
context.window_manager.fileselect_add(self)
|
||||||
return {'RUNNING_MODAL'}
|
return {'RUNNING_MODAL'}
|
||||||
|
|
||||||
|
@register_wrap
|
||||||
|
class AVATAR_TOOLKIT_OT_import_fbx(bpy.types.Operator):
|
||||||
|
bl_idname = "avatar_toolkit.import_fbx"
|
||||||
|
bl_label = "Import FBX"
|
||||||
|
|
||||||
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
import_fbx(self.filepath)
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
context.window_manager.fileselect_add(self)
|
||||||
|
return {'RUNNING_MODAL'}
|
||||||
|
|
||||||
|
@register_wrap
|
||||||
|
class AVATAR_TOOLKIT_OT_export_fbx(bpy.types.Operator):
|
||||||
|
bl_idname = 'avatar_toolkit.export_fbx'
|
||||||
|
bl_label = "Export FBX"
|
||||||
|
bl_description = "Export the model as FBX"
|
||||||
|
bl_options = {'REGISTER', 'UNDO', 'INTERNAL'}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
bpy.ops.export_scene.fbx('INVOKE_DEFAULT')
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,25 @@ class AvatarToolkitSettingsPanel(bpy.types.Panel):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.prop(context.scene, "avatar_toolkit_language", text=t("Settings.language.label"))
|
layout.prop(context.scene, "avatar_toolkit_language", text=t("Settings.language.label"))
|
||||||
|
|
||||||
|
@register_wrap
|
||||||
|
class AVATAR_TOOLKIT_OT_translation_restart_popup(bpy.types.Operator):
|
||||||
|
bl_idname = "avatar_toolkit.translation_restart_popup"
|
||||||
|
bl_label = t("Settings.translation_restart_popup.label")
|
||||||
|
bl_description = t("Settings.translation_restart_popup.description")
|
||||||
|
bl_options = {'INTERNAL'}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
if context.scene.avatar_toolkit_language_changed:
|
||||||
|
# Reload the addon after the popup is closed
|
||||||
|
bpy.ops.script.reload()
|
||||||
|
context.scene.avatar_toolkit_language_changed = False
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
return context.window_manager.invoke_props_dialog(self, width=300)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.label(text=t("Settings.translation_restart_popup.message1"))
|
||||||
|
layout.label(text=t("Settings.translation_restart_popup.message2"))
|
||||||
|
|||||||
Reference in New Issue
Block a user