Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
upgrade to Blender 4.2 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoMico authored and NicoMico committed Nov 18, 2024
1 parent 1bebed9 commit fb7459d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 131 deletions.
28 changes: 16 additions & 12 deletions blender/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# DBMT的Blender插件
DirectX Buffer Mod Tool的Blender配套插件。
# DBMT's Blender Plugin
The DirectX Buffer Mod Tool plugin for Blender.

# 安装步骤
- 打包BlenderPlugins目录为zip文件。
- 下载并安装Blender3.6 LTS版本。
- 在 首选项=>插件 中安装打包的.zip文件
- 打开DBMT面板,选择DBMT-GUI.exe所在路径完成插件初始化。
# Installation Steps
- Pack the BlenderPlugins directory into a zip file.
- Download and install Blender version 4.2 LTS.
- In Preferences => Add-ons, install the packed .zip file.
- Open the DBMT panel, select the path where DBMT-GUI.exe is located to complete the plugin initialization.

# 开发环境
# Development Environment
- Visual Studio Code
- Python 3.9
- Blender 3.6 LTS
- pip install fake-bpy-module-3.6
- pip install numpy
- Python 3.12.7 or higher
- Blender 4.2 LTS
- `pip install fake-bpy-module-4.2`
- `pip install numpy`

# Notice
- fake-bpy-module-4.2 need at least Python 3.12 to work.
- VSCode is the best practice IDE in blender plugin development.
- Ctrl + Shift + P to start debug Blender.
15 changes: 0 additions & 15 deletions blender/README_EN.md

This file was deleted.

11 changes: 5 additions & 6 deletions blender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
# 插件基础信息
bl_info = {
"name": "DBMT-Blender-Plugin",
"description": "DBMT的Blender插件 目前只支持3.6LTS版本",
"blender": (3, 6, 0),
"version": (1, 0, 2, 0),
"description": "DBMT的Blender插件",
"blender": (4, 2, 3),
"version": (1, 0, 2, 1),
"location": "View3D",
"category": "Generic"
}


# 需要注册和取消注册的所有类
register_classes = (
# migoto
Expand Down Expand Up @@ -58,9 +57,7 @@
MMTDeleteLoose,
MMTResetRotation,
MigotoRightClickMenu,
MMTCancelAutoSmooth,
MMTShowIndexedVertices,
MMTSetAutoSmooth89,
SplitMeshByCommonVertexGroup,
RecalculateTANGENTWithVectorNormalizedNormal,
RecalculateCOLORWithVectorNormalizedNormal,
Expand Down Expand Up @@ -115,3 +112,5 @@ def unregister():
del bpy.types.Scene.mmt_mmd_animation_mod_play_speed


if __name__ == "__main__":
register()
20 changes: 0 additions & 20 deletions blender/rightclick_menu/mesh_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,26 +293,6 @@ def mmt_reset_rotation(self, context):
return {'FINISHED'}


def mmt_cancel_auto_smooth(self, context):
for obj in bpy.context.selected_objects:
if obj.type == "MESH":
# 取消勾选"Auto Smooth"
# TODO 4.1中移除了use_auto_smooth
obj.data.use_auto_smooth = False
return {'FINISHED'}


def mmt_set_auto_smooth_89(self, context):
for obj in bpy.context.selected_objects:
if obj.type == "MESH":
# 取消勾选"Auto Smooth"
# TODO 4.1中移除了use_auto_smooth
obj.data.use_auto_smooth = True
# TODO 4.1中移除了auto_smooth_angle
obj.data.auto_smooth_angle = math.radians(89)
return {'FINISHED'}


def split_mesh_by_common_vertex_group(self, context):
# Code copied and modified from @Kail_Nethunter, very useful in some special meets.
# https://blenderartists.org/t/split-a-mesh-by-vertex-groups/438990/11
Expand Down
39 changes: 3 additions & 36 deletions blender/rightclick_menu/mesh_operator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Nico: 此文件定义右键菜单的功能类。
# 所有操作都要加上bl_options = {'UNDO'},这样可以支持Ctrl + Z撤销。
# 4.2版本开始,bl_options里再加任何东西都会出现
# RuntimeError: Error: validating class:: 'REGISTER' not found in ('SEARCH_ON_KEY_PRESS')
from .mesh_functions import *


class RemoveUnusedVertexGroupOperator(bpy.types.Operator):
bl_idname = "object.remove_unused_vertex_group"
bl_label = "移除未使用的空顶点组"
bl_options = {'UNDO'}

def execute(self, context):
return remove_unused_vertex_group(self, context)
Expand All @@ -15,7 +15,6 @@ def execute(self, context):
class MergeVertexGroupsWithSameNumber(bpy.types.Operator):
bl_idname = "object.merge_vertex_group_with_same_number"
bl_label = "合并具有相同数字前缀名称的顶点组"
bl_options = {'UNDO'}

def execute(self, context):
return merge_vertex_group_with_same_number(self, context)
Expand All @@ -24,7 +23,6 @@ def execute(self, context):
class FillVertexGroupGaps(bpy.types.Operator):
bl_idname = "object.fill_vertex_group_gaps"
bl_label = "填充数字顶点组的间隙"
bl_options = {'UNDO'}

def execute(self, context):
return fill_vertex_group_gaps(self, context)
Expand All @@ -33,7 +31,6 @@ def execute(self, context):
class AddBoneFromVertexGroup(bpy.types.Operator):
bl_idname = "object.add_bone_from_vertex_group"
bl_label = "根据顶点组自动生成骨骼"
bl_options = {'UNDO'}

def execute(self, context):
return add_bone_from_vertex_group(self, context)
Expand All @@ -42,7 +39,6 @@ def execute(self, context):
class RemoveNotNumberVertexGroup(bpy.types.Operator):
bl_idname = "object.remove_not_number_vertex_group"
bl_label = "移除非数字名称的顶点组"
bl_options = {'UNDO'}

def execute(self, context):
return remove_not_number_vertex_group(self, context)
Expand All @@ -51,7 +47,6 @@ def execute(self, context):
class ConvertToFragmentOperator(bpy.types.Operator):
bl_idname = "object.convert_to_fragment"
bl_label = "转换为一个3Dmigoto碎片用于合并"
bl_options = {'UNDO'}

def execute(self, context):
return convert_to_fragment(self, context)
Expand All @@ -60,7 +55,6 @@ def execute(self, context):
class MMTDeleteLoose(bpy.types.Operator):
bl_idname = "object.mmt_delete_loose"
bl_label = "删除物体的松散点"
bl_options = {'UNDO'}

def execute(self, context):
return delete_loose(self, context)
Expand All @@ -69,34 +63,15 @@ def execute(self, context):
class MMTResetRotation(bpy.types.Operator):
bl_idname = "object.mmt_reset_rotation"
bl_label = "重置x,y,z的旋转角度为0 (UE Model)"
bl_options = {'UNDO'}

def execute(self, context):
return mmt_reset_rotation(self, context)


class MMTCancelAutoSmooth(bpy.types.Operator):
bl_idname = "object.mmt_cancel_auto_smooth"
bl_label = "取消自动平滑 (UE Model)"
bl_options = {'UNDO'}

def execute(self, context):
return mmt_cancel_auto_smooth(self, context)


class MMTSetAutoSmooth89(bpy.types.Operator):
bl_idname = "object.mmt_set_auto_smooth_89"
bl_label = "设置Normal的自动平滑为89° (Unity)"
bl_options = {'UNDO'}

def execute(self, context):
return mmt_set_auto_smooth_89(self, context)


class MMTShowIndexedVertices(bpy.types.Operator):
bl_idname = "object.mmt_show_indexed_vertices"
bl_label = "展示Indexed Vertices和Indexes Number"
bl_options = {'UNDO'}

def execute(self, context):
return show_indexed_vertices(self, context)
Expand All @@ -105,7 +80,6 @@ def execute(self, context):
class SplitMeshByCommonVertexGroup(bpy.types.Operator):
bl_idname = "object.split_mesh_by_common_vertex_group"
bl_label = "根据相同的顶点组分割物体"
bl_options = {'UNDO'}

def execute(self, context):
return split_mesh_by_common_vertex_group(self, context)
Expand All @@ -114,7 +88,6 @@ def execute(self, context):
class RecalculateTANGENTWithVectorNormalizedNormal(bpy.types.Operator):
bl_idname = "object.recalculate_tangent_arithmetic_average_normal"
bl_label = "使用向量相加归一化算法重计算TANGENT"
bl_options = {'UNDO'}

def execute(self, context):
for obj in bpy.context.selected_objects:
Expand All @@ -130,7 +103,6 @@ def execute(self, context):
class RecalculateCOLORWithVectorNormalizedNormal(bpy.types.Operator):
bl_idname = "object.recalculate_color_arithmetic_average_normal"
bl_label = "使用算术平均归一化算法重计算COLOR"
bl_options = {'UNDO'}

def execute(self, context):
for obj in bpy.context.selected_objects:
Expand All @@ -147,7 +119,6 @@ def execute(self, context):
class MigotoRightClickMenu(bpy.types.Menu):
bl_idname = "VIEW3D_MT_object_3Dmigoto"
bl_label = "3Dmigoto"
bl_options = {'UNDO'}

def draw(self, context):
layout = self.layout
Expand All @@ -160,8 +131,6 @@ def draw(self, context):
layout.operator(ConvertToFragmentOperator.bl_idname)
layout.operator(MMTDeleteLoose.bl_idname)
layout.operator(MMTResetRotation.bl_idname)
layout.operator(MMTCancelAutoSmooth.bl_idname)
layout.operator(MMTSetAutoSmooth89.bl_idname)
layout.operator(MMTShowIndexedVertices.bl_idname)
layout.operator(SplitMeshByCommonVertexGroup.bl_idname)
layout.operator(RecalculateTANGENTWithVectorNormalizedNormal.bl_idname)
Expand All @@ -173,26 +142,24 @@ def menu_func_migoto_right_click(self, context):
self.layout.menu(MigotoRightClickMenu.bl_idname)



# --------------------------
# Right click menu for collection.
class DBMT_MarkCollection_Switch(bpy.types.Operator):
# bl_idname必须小写,中间可以下划线分割,不然报错无法加载
bl_idname = "object.mark_collection_switch"
bl_label = "Mark Collection Switch"
bl_options = {'UNDO'}

def execute(self, context):
# 示例:打印当前选中的集合名称
if context.collection:
context.collection.color_tag = "COLOR_03"
return {'FINISHED'}


class DBMT_MarkCollection_Toggle(bpy.types.Operator):
# bl_idname必须小写,中间可以下划线分割,不然报错无法加载
bl_idname = "object.mark_collection_toggle"
bl_label = "Mark Collection Toggle"
bl_options = {'UNDO'}

def execute(self, context):
# 示例:打印当前选中的集合名称
Expand Down
Loading

0 comments on commit fb7459d

Please sign in to comment.