BallanceBlenderHelper/ballance_blender_plugin/__init__.py

88 lines
2.8 KiB
Python
Raw Normal View History

2020-07-09 11:33:45 +08:00
bl_info={
"name":"Ballance Blender Plugin",
"description":"Ballance mapping tools for Blender",
"author":"yyc12345",
2020-08-08 11:35:32 +08:00
"version":(1,0),
2020-07-09 11:33:45 +08:00
"blender":(2,83,0),
"category":"Object",
2020-08-08 11:35:32 +08:00
"support":"TESTING",
"warning": "Please read document before using this plugin.",
"wiki_url": "https://github.com/yyc12345/BallanceBlenderHelper",
"tracker_url": "https://github.com/yyc12345/BallanceBlenderHelper/issues"
2020-07-09 11:33:45 +08:00
}
2020-07-12 21:04:38 +08:00
# ============================================= import system
2020-07-09 11:33:45 +08:00
import bpy,bpy_extras
# import my code (with reload)
if "bpy" in locals():
import importlib
if "bm_import_export" in locals():
importlib.reload(bm_import_export)
if "rail_uv" in locals():
importlib.reload(rail_uv)
2020-07-12 21:04:38 +08:00
if "utils" in locals():
importlib.reload(utils)
2020-07-14 14:55:12 +08:00
if "config" in locals():
importlib.reload(config)
2020-07-19 15:05:43 +08:00
if "preferences" in locals():
importlib.reload(preferences)
if "threedsmax_align" in locals():
importlib.reload(threedsmax_align)
if "no_uv_checker" in locals():
importlib.reload(no_uv_checker)
from . import config, utils, bm_import_export, rail_uv, preferences, threedsmax_align, no_uv_checker
2020-07-12 21:04:38 +08:00
# ============================================= menu system
class ThreeDViewerMenu(bpy.types.Menu):
2020-07-19 15:13:55 +08:00
"""Ballance related 3D operator"""
2020-07-12 21:04:38 +08:00
bl_label = "Ballance 3D"
bl_idname = "OBJECT_MT_ballance3d_menu"
def draw(self, context):
layout = self.layout
layout.operator("ballance.threedsmax_align")
2020-07-12 21:04:38 +08:00
layout.operator("ballance.rail_uv")
layout.operator("ballance.no_uv_checker")
2020-07-12 21:04:38 +08:00
# ============================================= blender call system
2020-07-09 11:33:45 +08:00
classes = (
2020-07-19 15:05:43 +08:00
preferences.BallanceBlenderPluginPreferences,
bm_import_export.ImportBM,
bm_import_export.ExportBM,
rail_uv.RailUVOperator,
threedsmax_align.SuperAlignOperator,
no_uv_checker.NoUVCheckerOperator,
2020-07-12 21:04:38 +08:00
ThreeDViewerMenu
2020-07-09 11:33:45 +08:00
)
def menu_func_bm_import(self, context):
self.layout.operator(bm_import_export.ImportBM.bl_idname, text="Ballance Map (.bm)")
2020-07-09 11:33:45 +08:00
def menu_func_bm_export(self, context):
self.layout.operator(bm_import_export.ExportBM.bl_idname, text="Ballance Map (.bm)")
2020-07-12 21:04:38 +08:00
def menu_func_ballance_3d(self, context):
layout = self.layout
layout.menu(ThreeDViewerMenu.bl_idname)
2020-07-09 11:33:45 +08:00
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.TOPBAR_MT_file_import.append(menu_func_bm_import)
bpy.types.TOPBAR_MT_file_export.append(menu_func_bm_export)
2020-07-12 21:04:38 +08:00
bpy.types.VIEW3D_HT_header.append(menu_func_ballance_3d)
2020-07-09 11:33:45 +08:00
def unregister():
bpy.types.TOPBAR_MT_file_import.remove(menu_func_bm_import)
bpy.types.TOPBAR_MT_file_export.remove(menu_func_bm_export)
2020-07-12 21:04:38 +08:00
bpy.types.VIEW3D_HT_header.remove(menu_func_ballance_3d)
2020-07-09 11:33:45 +08:00
for cls in classes:
bpy.utils.unregister_class(cls)
if __name__=="__main__":
register()