|
diff -u -r 2.79/model_finalizer/__init__.py 2.8/model_finalizer/__init__.py |
|
--- 2.79/model_finalizer/__init__.py 2018-12-08 22:53:13.769417900 +0900 |
|
+++ 2.8/model_finalizer/__init__.py 2020-05-01 09:48:15.034567700 +0900 |
|
@@ -6,8 +6,8 @@ |
|
bl_info = { |
|
'name' : 'Model Finalizer', # Name of this Addon |
|
'author' : 'Kafuji', # Author of this Addon |
|
- 'version' : (0,7), # Version of this Addon |
|
- 'blender' : (2, 7, 9), # Blender Version that this addon is compatible to |
|
+ 'version' : (0, 7), # Version of this Addon |
|
+ 'blender' : (2, 80, 0), # Blender Version that this addon is compatible to |
|
'location' : 'View3D > Toolbar', # Where to access to this Addon |
|
'description' : 'Model Finalizing tools for models targeted to use in runtime engines', # Description of this Addon |
|
'warning' : 'This Addon is still under development. Some Features are disabled for future expansions.', |
|
@@ -32,19 +32,19 @@ |
|
import bpy |
|
|
|
######################################################################################### |
|
-class UL_PoseList(UIList): |
|
+class MODELFINALIZER_UL_PoseList(bpy.types.UIList): |
|
'''UI: Custom Pose List''' |
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): |
|
- split = layout.split(0.2) |
|
- split.label(str(index)) |
|
+ split = layout.split(factor=0.2) |
|
+ split.label(text=str(index)) |
|
split.prop(item, 'name', text='', emboss=False, translate=False ) |
|
|
|
######################################################################################### |
|
-class VIEW3D_ToolPanel(bpy.types.Panel): |
|
+class MODELFINALIZER_PT_VIEW3D_ToolPanel(bpy.types.Panel): |
|
'''UI: Custom Tool Panel for Model Finalizer''' |
|
bl_label = bl_info['name'] |
|
bl_space_type = 'VIEW_3D' |
|
- bl_region_type = 'TOOLS' |
|
+ bl_region_type = 'UI' |
|
bl_category = 'Tools' |
|
#bl_context = 'armature_edit' |
|
#bl_options = {'DEFAULT_CLOSED'} |
|
@@ -60,7 +60,7 @@ |
|
################################################# |
|
# PoseLib to Shapekey Converter |
|
col.prop(props, 'ShowPoseToShapeKey', text='PoseLib to ShapeKey', toggle=True, |
|
- icon='ZOOMOUT' if props.ShowPoseToShapeKey else 'ZOOMIN') |
|
+ icon='ZOOM_OUT' if props.ShowPoseToShapeKey else 'ZOOM_IN') |
|
|
|
if props.ShowPoseToShapeKey: |
|
col = col_outside_box.box().column() |
|
@@ -71,13 +71,13 @@ |
|
if poselib is not None and context.mode == 'OBJECT': |
|
#layout.template_ID(ob, 'pose_library',new='poselib.new',unlink='poselib.unlink') |
|
# display pose library and buttons |
|
- col.label('PoseLib: '+poselib.name, icon='ACTION') |
|
+ col.label(text='PoseLib: '+poselib.name, icon='ACTION') |
|
row = col.row() |
|
#row.template_list('UI_UL_list','pose_markers',poselib,'pose_markers',poselib.pose_markers,'active_index',rows=3) |
|
- row.template_list('UL_PoseList', 'Pose List', poselib, 'pose_markers', poselib.pose_markers, 'active_index') |
|
+ row.template_list('MODELFINALIZER_UL_PoseList', 'Pose List', poselib, 'pose_markers', poselib.pose_markers, 'active_index') |
|
col2 = row.column(align=True) |
|
- col2.operator(OP_Apply_Pose.bl_idname, icon='ZOOM_SELECTED', text='') |
|
- col2.operator(OP_Reset_Pose.bl_idname, icon='FILE_REFRESH', text='') |
|
+ col2.operator(MODELFINALIZER_OT_Apply_Pose.bl_idname, icon='ZOOM_SELECTED', text='') |
|
+ col2.operator(MODELFINALIZER_OT_Reset_Pose.bl_idname, icon='FILE_REFRESH', text='') |
|
col.prop(props, 'BatchConvert') |
|
|
|
row=col.row(align=True) |
|
@@ -87,22 +87,22 @@ |
|
props.BatchFrom = props.BatchTo |
|
|
|
row.prop(props, 'BatchFrom') |
|
- row.label('',icon='FORWARD') |
|
+ row.label(text='',icon='FORWARD') |
|
row.prop(props, 'BatchTo', text='End') |
|
|
|
col.separator() |
|
|
|
# display target mesh list |
|
meshes = GetMeshObjectsWithArmatureFromSelected(GetArmatureFromSelected().name) |
|
- col.label('Target Objects: ' + str(len(meshes)), icon='OBJECT_DATA') |
|
+ col.label(text='Target Objects: ' + str(len(meshes)), icon='OBJECT_DATA') |
|
#for m in meshes: |
|
- # col.label(m.name, icon='OBJECT_DATA') |
|
+ # col.label(text=m.name, icon='OBJECT_DATA') |
|
col.prop(props, 'ApplyMirrorModifier') |
|
col.prop(props, 'RemoveConvertedPose') |
|
col.separator() |
|
- col.operator(OP_ConvertPoseToShapeKey.bl_idname, icon='SHAPEKEY_DATA',text='Convert To ShapeKey') |
|
+ col.operator(MODELFINALIZER_OT_ConvertPoseToShapeKey.bl_idname, icon='SHAPEKEY_DATA', text='Convert To ShapeKey') |
|
else: |
|
- col.label('Select an Armature with Pose Library', icon='INFO') |
|
+ col.label(text='Select an Armature with Pose Library', icon='INFO') |
|
|
|
################################################# |
|
# Mesh Modifier Finalizer |
|
@@ -110,17 +110,17 @@ |
|
col.separator() |
|
col.separator() |
|
col.prop(props, 'ShowMeshFinalizer', text='Mesh Finalizer', toggle=True, |
|
- icon='ZOOMOUT' if props.ShowMeshFinalizer else 'ZOOMIN') |
|
+ icon='ZOOM_OUT' if props.ShowMeshFinalizer else 'ZOOM_IN') |
|
|
|
if props.ShowMeshFinalizer: |
|
col = col.box().column() |
|
row = col.row(align=True) |
|
- row.operator(OP_Finalize_Modifiers.bl_idname, icon='MOD_REMESH') |
|
- row.operator(OP_Select_All_Meshes_With_Modifiers.bl_idname, text='',icon='HAND') |
|
+ row.operator(MODELFINALIZER_OT_Finalize_Modifiers.bl_idname, icon='MOD_REMESH') |
|
+ row.operator(MODELFINALIZER_OT_Select_All_Meshes_With_Modifiers.bl_idname, text='', icon='HAND') |
|
|
|
meshes = GetMeshObjectsWithModifiersFromSelected() |
|
col.separator() |
|
- col.label( 'Target Objects: ' + str(len(meshes)), icon='OBJECT_DATA') |
|
+ col.label(text='Target Objects: ' + str(len(meshes)), icon='OBJECT_DATA') |
|
col.separator() |
|
|
|
row=col.row() |
|
@@ -147,14 +147,14 @@ |
|
col.separator() |
|
col.separator() |
|
col.prop(props, 'ShowExtraUtils', text='Extra Utilities', toggle=True, |
|
- icon='ZOOMOUT' if props.ShowExtraUtils else 'ZOOMIN') |
|
+ icon='ZOOM_OUT' if props.ShowExtraUtils else 'ZOOM_IN') |
|
if props.ShowExtraUtils: |
|
col = col.box().column(align=True) |
|
col_in_box = col |
|
|
|
# Weight Transfer Utility |
|
col=col_in_box.box().column(align=True) |
|
- col.operator(OP_TransferWeightsFromSelectedToActive.bl_idname, icon='BRUSH_VERTEXDRAW') |
|
+ col.operator(MODELFINALIZER_OT_TransferWeightsFromSelectedToActive.bl_idname, icon='MOD_VERTEX_WEIGHT') |
|
col.separator() |
|
|
|
meshes = GetMeshObjectsFromSelected() |
|
@@ -166,32 +166,32 @@ |
|
mesh_from = meshes[1] if meshes[0].name == mesh_to.name else meshes[0] |
|
row = col.row(align=True) |
|
row.alignment='CENTER' |
|
- row.label(mesh_from.name,icon='OBJECT_DATA') |
|
- row.label('',icon='FORWARD') |
|
- row.label(mesh_to.name,icon='OBJECT_DATA') |
|
+ row.label(text=mesh_from.name,icon='OBJECT_DATA') |
|
+ row.label(text='',icon='FORWARD') |
|
+ row.label(text=mesh_to.name,icon='OBJECT_DATA') |
|
else: |
|
- col.label('Select 2 Mesh Objects', icon='INFO') |
|
+ col.label(text='Select 2 Mesh Objects', icon='INFO') |
|
|
|
col_in_box.separator() |
|
|
|
# Clean Vertex Weights |
|
col=col_in_box.box().column(align=True) |
|
- col.operator(OP_RemoveUnusedVertexGroups.bl_idname, icon='GROUP_VERTEX') |
|
+ col.operator(MODELFINALIZER_OT_RemoveUnusedVertexGroups.bl_idname, icon='GROUP_VERTEX') |
|
col.separator() |
|
- col.label( 'Target Objects: '+str(len(meshes)), icon='OBJECT_DATA') |
|
+ col.label(text='Target Objects: '+str(len(meshes)), icon='OBJECT_DATA') |
|
|
|
col_in_box.separator() |
|
|
|
# Apply current pose as new Rest |
|
col=col_in_box.box().column(align=True) |
|
row=col.row(align=True) |
|
- row.operator(OP_ApplyCurrentPoseAsNewRestPose.bl_idname, icon='MOD_ARMATURE') |
|
- row.operator(OP_Select_All_Meshes_RelativeToSelectedArmature.bl_idname, text='',icon='HAND') |
|
+ row.operator(MODELFINALIZER_OT_ApplyCurrentPoseAsNewRestPose.bl_idname, icon='MOD_ARMATURE') |
|
+ row.operator(MODELFINALIZER_OT_Select_All_Meshes_RelativeToSelectedArmature.bl_idname, text='', icon='HAND') |
|
col.separator() |
|
arm = GetArmatureFromSelected() |
|
num_targets = 0 if arm is None else len(GetMeshObjectsWithArmatureFromSelected(arm.name)) |
|
- col.label( 'Target Armature: '+(arm.name if arm is not None else 'None'), icon='ARMATURE_DATA') |
|
- col.label( 'Target Objects: '+str(num_targets), icon='OBJECT_DATA') |
|
+ col.label(text='Target Armature: '+(arm.name if arm is not None else 'None'), icon='ARMATURE_DATA') |
|
+ col.label(text='Target Objects: '+str(num_targets), icon='OBJECT_DATA') |
|
col.prop(props, 'ApplyPoseAsNewRest_AutoApplyMirror') |
|
|
|
col_in_box.separator() |
|
@@ -199,22 +199,22 @@ |
|
# Remove All Modifiers |
|
col=col_in_box.box().column(align=True) |
|
row=col.row(align=True) |
|
- col.operator(OP_RemoveAllModifiers.bl_idname, icon='MODIFIER') |
|
- col.label( 'Target Objects: '+str(len(GetMeshObjectsWithModifiersFromSelected(including_armature=props.RemoveModifiers_IncluidngArmature))), icon='OBJECT_DATA') |
|
+ col.operator(MODELFINALIZER_OT_RemoveAllModifiers.bl_idname, icon='MODIFIER') |
|
+ col.label(text='Target Objects: '+str(len(GetMeshObjectsWithModifiersFromSelected(including_armature=props.RemoveModifiers_IncluidngArmature))), icon='OBJECT_DATA') |
|
col.prop(props,'RemoveModifiers_IncluidngArmature') |
|
col_in_box.separator() |
|
|
|
# Triangulate Selected Meshes |
|
col=col_in_box.box().column(align=True) |
|
row=col.row(align=True) |
|
- row.operator(OP_TriangulateSelectedMeshes.bl_idname, icon='OUTLINER_DATA_MESH') |
|
- row.operator(OP_Select_All_Meshes.bl_idname, text='',icon='HAND') |
|
+ row.operator(MODELFINALIZER_OT_TriangulateSelectedMeshes.bl_idname, icon='OUTLINER_DATA_MESH') |
|
+ row.operator(MODELFINALIZER_OT_Select_All_Meshes.bl_idname, text='', icon='HAND') |
|
col.separator() |
|
num_targets = len(GetMeshObjectsFromSelected()) |
|
- col.label( 'Target Objects: '+str(num_targets), icon='OBJECT_DATA') |
|
+ col.label(text='Target Objects: '+str(num_targets), icon='OBJECT_DATA') |
|
|
|
#col=col_in_box.box().column(align=True) |
|
- #col.label('-- Under Development --') |
|
+ #col.label(text='-- Under Development --') |
|
#col.separator() |
|
#col.operator(OP_StraightenSelectedEditableBones.bl_idname, icon='BONE_DATA') |
|
#col.separator() |
|
@@ -224,18 +224,38 @@ |
|
|
|
|
|
# Register This Addon |
|
+classes = [ |
|
+ MODELFINALIZER_UL_PoseList, |
|
+ MODELFINALIZER_PT_VIEW3D_ToolPanel, |
|
+ MODELFINALIZER_OT_ConvertPoseToShapeKey, |
|
+ MODELFINALIZER_OT_Apply_Pose, |
|
+ MODELFINALIZER_OT_Reset_Pose, |
|
+ MODELFINALIZER_OT_Select_All_Meshes_With_Modifiers, |
|
+ MODELFINALIZER_OT_Select_All_Meshes_RelativeToSelectedArmature, |
|
+ MODELFINALIZER_OT_Select_All_Meshes, |
|
+ MODELFINALIZER_OT_Finalize_Modifiers, |
|
+ MODELFINALIZER_OT_StraightenSelectedEditableBones, |
|
+ MODELFINALIZER_OT_ApplyCurrentPoseAsNewRestPose, |
|
+ MODELFINALIZER_OT_RemoveAllModifiers, |
|
+ MODELFINALIZER_OT_ConvertArmatureToMMDCompatible, |
|
+ MODELFINALIZER_OT_SaveAsFinalizedFileName, |
|
+ MODELFINALIZER_OT_TransferWeightsFromSelectedToActive, |
|
+ MODELFINALIZER_OT_RemoveUnusedVertexGroups, |
|
+ MODELFINALIZER_OT_TriangulateSelectedMeshes, |
|
+] |
|
+ |
|
def register(): |
|
-# for c in classes: |
|
-# bpy.utils.register_class(c) |
|
- bpy.utils.register_module(__name__) |
|
-# bpy.utils.register_class(addon_properties) |
|
+ for c in classes: |
|
+ bpy.utils.register_class(c) |
|
+# bpy.utils.register_module(__name__) |
|
+ bpy.utils.register_class(addon_properties) |
|
|
|
# Unregister This Addon |
|
def unregister(): |
|
-# for c in classes: |
|
-# bpy.utils.unregister_class(c) |
|
- bpy.utils.unregister_module(__name__) |
|
-# bpy.utils.unregister_class(addon_properties) |
|
+ for c in classes: |
|
+ bpy.utils.unregister_class(c) |
|
+# bpy.utils.unregister_module(__name__) |
|
+ bpy.utils.unregister_class(addon_properties) |
|
|
|
# call register() if this script is invoked under main process of Blender |
|
if __name__ == '__main__': |
|
diff -u -r 2.79/model_finalizer/helpers.py 2.8/model_finalizer/helpers.py |
|
--- 2.79/model_finalizer/helpers.py 2018-12-08 18:56:34.824132200 +0900 |
|
+++ 2.8/model_finalizer/helpers.py 2020-05-01 09:48:28.411566600 +0900 |
|
@@ -102,10 +102,10 @@ |
|
'''Helper: Apply All Modifiers matching to given Type''' |
|
for mod in mesh.modifiers: |
|
if mod.type == modifier_type: |
|
- lastActiveObject = bpy.context.scene.objects.active |
|
- bpy.context.scene.objects.active = mesh |
|
+ lastActiveObject = bpy.context.view_layer.objects.active |
|
+ bpy.context.view_layer.objects.active = mesh |
|
bpy.ops.object.modifier_apply(apply_as='DATA', modifier=mod.name) |
|
- bpy.context.scene.objects.active = lastActiveObject |
|
+ bpy.context.view_layer.objects.active = lastActiveObject |
|
|
|
################################################################################################## |
|
def GetModifierByType( mesh, modifier_type ): |
|
@@ -164,14 +164,14 @@ |
|
|
|
# if this mesh has no Shapekey, just apply modifiers and finish |
|
if mesh.data.shape_keys is None: |
|
- lastActiveObject = bpy.context.scene.objects.active |
|
- bpy.context.scene.objects.active = mesh |
|
+ lastActiveObject = bpy.context.view_layer.objects.active |
|
+ bpy.context.view_layer.objects.active = mesh |
|
ApplyModsByControlledOrder( applying_mods ) |
|
- bpy.context.scene.objects.active = lastActiveObject |
|
+ bpy.context.view_layer.objects.active = lastActiveObject |
|
return |
|
|
|
# Save Selection, before doing complicated things |
|
- lastActiveObject = bpy.context.scene.objects.active |
|
+ lastActiveObject = bpy.context.view_layer.objects.active |
|
lastSelectedObjects = bpy.context.selected_objects |
|
lastSelectedShapeKeyIndex = mesh.active_shape_key_index |
|
mesh.active_shape_key_index = 0 |
|
@@ -189,8 +189,8 @@ |
|
|
|
shape_key_index = 1 |
|
for shapekey in mesh.data.shape_keys.key_blocks[1:]: |
|
- mesh.select = True |
|
- bpy.context.scene.objects.active = mesh |
|
+ mesh.select_set(True) |
|
+ bpy.context.view_layer.objects.active = mesh |
|
bpy.ops.object.shape_key_clear() # reset to base shape |
|
shapekey.value = 1.0 # invoke this Shape Key |
|
|
|
@@ -215,11 +215,11 @@ |
|
bpy.ops.object.convert(target='MESH') |
|
TemporalShapes.append(bpy.context.active_object) |
|
# apply target mods on dupulicated shape, to keep it identical to original |
|
- duplicated_mesh.select = False |
|
+ duplicated_mesh.select_set(False) |
|
shape_key_index+=1 |
|
|
|
# Remove ShapeKeys from the Mesh |
|
- bpy.context.scene.objects.active = mesh |
|
+ bpy.context.view_layer.objects.active = mesh |
|
bpy.ops.object.shape_key_clear() |
|
bpy.ops.object.shape_key_remove(all=True) |
|
|
|
@@ -228,16 +228,16 @@ |
|
|
|
# Join Temporal Shapes as ShapeKeys |
|
for shape in TemporalShapes: |
|
- shape.select = True |
|
- mesh.select = True |
|
- bpy.context.scene.objects.active = mesh |
|
+ shape.select_set(True) |
|
+ mesh.select_set(True) |
|
+ bpy.context.view_layer.objects.active = mesh |
|
bpy.ops.object.join_shapes() |
|
- shape.select = False |
|
+ shape.select_set(False) |
|
|
|
# Delete Temporal Objects |
|
- mesh.select = False |
|
+ mesh.select_set(False) |
|
for shape in TemporalShapes: |
|
- shape.select = True |
|
+ shape.select_set(True) |
|
bpy.ops.object.delete(use_global=False) |
|
|
|
# Restore visibility of excluded modifiers |
|
@@ -246,16 +246,16 @@ |
|
|
|
# Restore Selection |
|
for obj in lastSelectedObjects: |
|
- obj.select = True |
|
- bpy.context.scene.objects.active = lastActiveObject |
|
+ obj.select_set(True) |
|
+ bpy.context.view_layer.objects.active = lastActiveObject |
|
|
|
mesh.active_shape_key_index = lastSelectedShapeKeyIndex if lastSelectedShapeKeyIndex is not None else 0 |
|
|
|
################################################################################################## |
|
def ApplyArmatureAsShapeKey( mesh, arm_name, shapekey_name ): |
|
'''Helper: Apply given armature as a shapekey on mesh, while preserving armature modifier''' |
|
- lastActiveObject = bpy.context.scene.objects.active |
|
- bpy.context.scene.objects.active = mesh |
|
+ lastActiveObject = bpy.context.view_layer.objects.active |
|
+ bpy.context.view_layer.objects.active = mesh |
|
|
|
mod_name = None # name of Armature Modifier that connect to given Armature Object |
|
mod_index = 0 |
|
@@ -279,17 +279,17 @@ |
|
# rename duplicated modifier to original name |
|
mesh.modifiers[mod_index].name = mod_name |
|
|
|
- bpy.context.scene.objects.active = lastActiveObject |
|
+ bpy.context.view_layer.objects.active = lastActiveObject |
|
|
|
|
|
################################################################################################## |
|
def SmoothWeightsOnMesh( mesh, value=1.0 ): |
|
'''Helper: Do Weight Smoothing on given mesh''' |
|
|
|
- lastActiveObject = bpy.context.scene.objects.active |
|
+ lastActiveObject = bpy.context.view_layer.objects.active |
|
lastMode = bpy.context.mode |
|
|
|
- bpy.context.scene.objects.active = mesh |
|
+ bpy.context.view_layer.objects.active = mesh |
|
bpy.ops.object.mode_set(mode='EDIT') |
|
bpy.context.tool_settings.mesh_select_mode = (True, False, False) # Only Vertex Selection |
|
# select non_manifold vertices |
|
@@ -306,17 +306,17 @@ |
|
bpy.ops.object.vertex_group_smooth( group_select_mode='ALL', factor=value ) |
|
|
|
bpy.ops.object.mode_set(mode=lastMode) |
|
- bpy.context.scene.objects.active = lastActiveObject |
|
+ bpy.context.view_layer.objects.active = lastActiveObject |
|
return |
|
|
|
################################################################################################## |
|
def LimitWeightsOnMesh( mesh, value=4 ): |
|
'''Helper: Limit Deform Weights on given mesh''' |
|
|
|
- lastActiveObject = bpy.context.scene.objects.active |
|
+ lastActiveObject = bpy.context.view_layer.objects.active |
|
lastMode = bpy.context.mode |
|
|
|
- bpy.context.scene.objects.active = mesh |
|
+ bpy.context.view_layer.objects.active = mesh |
|
bpy.ops.object.mode_set(mode='EDIT') |
|
bpy.context.tool_settings.mesh_select_mode = (True, False, False) # Only Vertex Selection |
|
|
|
@@ -333,7 +333,7 @@ |
|
bpy.ops.object.vertex_group_limit_total( group_select_mode='ALL', limit=value ) |
|
|
|
bpy.ops.object.mode_set(mode=lastMode) |
|
- bpy.context.scene.objects.active = lastActiveObject |
|
+ bpy.context.view_layer.objects.active = lastActiveObject |
|
return |
|
|
|
################################################################################################## |
|
diff -u -r 2.79/model_finalizer/operators.py 2.8/model_finalizer/operators.py |
|
--- 2.79/model_finalizer/operators.py 2018-12-08 20:07:07.936900900 +0900 |
|
+++ 2.8/model_finalizer/operators.py 2020-05-01 09:48:43.473567400 +0900 |
|
@@ -9,7 +9,7 @@ |
|
from .helpers import * |
|
|
|
################################################################################################## |
|
-class OP_ConvertPoseToShapeKey(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_ConvertPoseToShapeKey(bpy.types.Operator): |
|
'''Operator: Apply Selected Poses as ShapeKey''' |
|
bl_idname = 'finalizer.convert_pose_to_shape_key' # Operator identifier |
|
bl_label = 'Pose To ShapeKey' # Menu label |
|
@@ -46,9 +46,9 @@ |
|
ApplyModifiers_PreserveShapeKeys( mesh, mod_types_apply=['MIRROR'], mod_types_exclude=['ARMATURE'] ) |
|
|
|
# Set this Armature as Active Object |
|
- lastActiveObject = context.scene.objects.active |
|
+ lastActiveObject = context.view_layer.objects.active |
|
lastMode = context.mode |
|
- context.scene.objects.active = arm |
|
+ context.view_layer.objects.active = arm |
|
|
|
# pick pose indexes |
|
pose_indexes = [] |
|
@@ -67,7 +67,7 @@ |
|
# apply pose |
|
bpy.ops.object.mode_set(mode='POSE') |
|
for pb in arm.pose.bones: |
|
- pb.bone.select = True |
|
+ pb.bone.select_set(True) |
|
bpy.ops.pose.transforms_clear() |
|
bpy.ops.poselib.apply_pose(pose_index=index) |
|
|
|
@@ -90,7 +90,7 @@ |
|
bpy.ops.poselib.pose_remove(pose=name) |
|
|
|
# Restore Active Object and Mode |
|
- context.scene.objects.active = lastActiveObject |
|
+ context.view_layer.objects.active = lastActiveObject |
|
bpy.ops.object.mode_set(mode=lastMode) |
|
|
|
self.report({'INFO'}, 'Pose to Shape Key Finished') |
|
@@ -98,7 +98,7 @@ |
|
|
|
|
|
################################################################################################## |
|
-class OP_Apply_Pose(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_Apply_Pose(bpy.types.Operator): |
|
'''Operator: Apply Selected Pose''' |
|
bl_idname = 'finalizer.apply_pose' # Operator identifier |
|
bl_label = 'Apply Pose' # Menu label |
|
@@ -120,27 +120,27 @@ |
|
return {'FAILED'} |
|
|
|
# Set this Armature as Active Object |
|
- lastActiveObject = context.scene.objects.active |
|
- context.scene.objects.active = arm |
|
+ lastActiveObject = context.view_layer.objects.active |
|
+ context.view_layer.objects.active = arm |
|
poselib = arm.pose_library |
|
|
|
# clear current pose and apply selected pose |
|
last_mode = context.mode |
|
bpy.ops.object.mode_set(mode='POSE') |
|
for pb in arm.pose.bones: |
|
- pb.bone.select = True |
|
+ pb.bone.select_set(True) |
|
bpy.ops.pose.transforms_clear() |
|
bpy.ops.poselib.apply_pose(pose_index=poselib.pose_markers.active_index) |
|
bpy.ops.object.mode_set(mode=last_mode) |
|
|
|
# Restore Active Object |
|
- context.scene.objects.active = lastActiveObject |
|
+ context.view_layer.objects.active = lastActiveObject |
|
|
|
self.report({'INFO'}, 'Pose: '+poselib.pose_markers.active.name+' applied') |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_Reset_Pose(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_Reset_Pose(bpy.types.Operator): |
|
'''Operator: Reset(Relax) Pose to Default''' |
|
bl_idname = 'finalizer.reset_pose' # Operator identifier |
|
bl_label = 'Reset Pose' # Menu label |
|
@@ -164,25 +164,25 @@ |
|
return {'FAILED'} |
|
|
|
# Set Active Object to this Armature |
|
- lastActiveObject = context.scene.objects.active |
|
- context.scene.objects.active = arm |
|
+ lastActiveObject = context.view_layer.objects.active |
|
+ context.view_layer.objects.active = arm |
|
|
|
# get into Pose mode and clear pose |
|
last_mode = context.mode |
|
bpy.ops.object.mode_set(mode='POSE') |
|
for pb in arm.pose.bones: |
|
- pb.bone.select = True |
|
+ pb.bone.select_set(True) |
|
bpy.ops.pose.transforms_clear() |
|
bpy.ops.object.mode_set(mode=last_mode) |
|
|
|
# Restore Active Object |
|
- context.scene.objects.active = lastActiveObject |
|
+ context.view_layer.objects.active = lastActiveObject |
|
|
|
self.report({'INFO'}, 'Pose set to default') |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_Select_All_Meshes_With_Modifiers(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_Select_All_Meshes_With_Modifiers(bpy.types.Operator): |
|
'''Operator : Select All Mesh Objects with Modifiers''' |
|
bl_idname = 'finalizer.select_all_meshes_with_modifiers' # Operator identifier |
|
bl_label = 'Select All Meshes with Modifiers' # Menu label |
|
@@ -199,13 +199,13 @@ |
|
DeselectAllObjects() |
|
meshes = GetMeshObjectsWithModifiersFromSelectable() |
|
for m in meshes: |
|
- m.select = True |
|
+ m.select_set(True) |
|
|
|
self.report({'INFO'}, str(len(meshes))+' Mesh selected') |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_Select_All_Meshes_RelativeToSelectedArmature(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_Select_All_Meshes_RelativeToSelectedArmature(bpy.types.Operator): |
|
'''Operator : Select All Mesh Objects, Relative to selected Armature''' |
|
bl_idname = 'finalizer.select_all_meshes_relativetoselectedarmature' # Operator identifier |
|
bl_label = 'Select All Meshes relative to selected Armature' # Menu label |
|
@@ -223,16 +223,16 @@ |
|
def execute(self, context): |
|
arm = GetArmatureFromSelected() |
|
DeselectAllObjects() |
|
- arm.select = True |
|
+ arm.select_set(True) |
|
meshes = GetMeshObjectsWithArmatureFromSelectable(arm.name) |
|
for m in meshes: |
|
- m.select = True |
|
+ m.select_set(True) |
|
|
|
self.report({'INFO'}, str(len(meshes))+' Mesh selected') |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_Select_All_Meshes(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_Select_All_Meshes(bpy.types.Operator): |
|
'''Operator : Select All Mesh Objects''' |
|
bl_idname = 'finalizer.select_all_meshes' # Operator identifier |
|
bl_label = 'Select All Meshes' # Menu label |
|
@@ -249,14 +249,14 @@ |
|
DeselectAllObjects() |
|
meshes = GetMeshObjectsFromSelectable() |
|
for m in meshes: |
|
- m.select = True |
|
+ m.select_set(True) |
|
|
|
self.report({'INFO'}, str(len(meshes))+' Mesh selected') |
|
return {'FINISHED'} |
|
|
|
|
|
################################################################################################## |
|
-class OP_Finalize_Modifiers(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_Finalize_Modifiers(bpy.types.Operator): |
|
'''Operator: Apply All Modifiers(except armature) to Finfalize Mesh''' |
|
bl_idname = 'finalizer.finalize_modifiers' # Operator identifier |
|
bl_label = 'Apply All Modifiers' # Menu label |
|
@@ -325,7 +325,7 @@ |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_StraightenSelectedEditableBones(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_StraightenSelectedEditableBones(bpy.types.Operator): |
|
'''Operator : Straighten Selected Editable Bones''' |
|
bl_idname = 'finalizer.straighten_selected_editable_bones' # Operator identifier |
|
bl_label = 'Straighten Selected Bones' # Menu label |
|
@@ -371,7 +371,7 @@ |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_ApplyCurrentPoseAsNewRestPose(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_ApplyCurrentPoseAsNewRestPose(bpy.types.Operator): |
|
'''Operator : Apply Current Pose as New Rest Pose''' |
|
bl_idname = 'finalizer.apply_current_pose_as_new_rest_pose' # Operator identifier |
|
bl_label = 'Apply Pose as new Rest' # Menu label |
|
@@ -387,13 +387,13 @@ |
|
def execute(self, context): |
|
props = context.scene.finalizer_props |
|
arm = GetArmatureFromSelected() |
|
- lastActiveObject = bpy.context.scene.objects.active |
|
+ lastActiveObject = bpy.context.view_layer.objects.active |
|
|
|
# Apply Armature on All Mesh Objects that are connected with this Armature, within selected objects |
|
meshes = GetMeshObjectsWithArmatureFromSelected(arm.name) |
|
|
|
for mesh in meshes: |
|
- bpy.context.scene.objects.active = mesh |
|
+ bpy.context.view_layer.objects.active = mesh |
|
# before applying armature, we need apply Mirror modifier if needed |
|
if props.ApplyPoseAsNewRest_AutoApplyMirror: |
|
ApplyModifiers_PreserveShapeKeys(mesh, mod_types_apply=['MIRROR'], mod_types_exclude=['ARMATURE']) |
|
@@ -412,19 +412,19 @@ |
|
mod_index += 1 |
|
|
|
# armature is applied on all target meshes, now make the armature itself to a new rest pose |
|
- bpy.context.scene.objects.active = arm |
|
+ bpy.context.view_layer.objects.active = arm |
|
bpy.ops.object.mode_set(mode='POSE') |
|
bpy.ops.pose.select_all(action='SELECT') |
|
bpy.ops.pose.armature_apply() |
|
bpy.ops.object.mode_set(mode='OBJECT') |
|
- bpy.context.scene.objects.active = lastActiveObject |
|
+ bpy.context.view_layer.objects.active = lastActiveObject |
|
|
|
# Re-assign this Armature on all deformed Mesh Objects |
|
|
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_RemoveAllModifiers(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_RemoveAllModifiers(bpy.types.Operator): |
|
'''Operator : Remove all modifiers from selected Objects''' |
|
bl_idname = 'finalizer.remove_all_modifiers' # Operator identifier |
|
bl_label = 'Remove All Modifiers' # Menu label |
|
@@ -457,7 +457,7 @@ |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_ConvertArmatureToMMDCompatible(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_ConvertArmatureToMMDCompatible(bpy.types.Operator): |
|
'''Operator : Convert Selected Armature to MMD Compatible Structure''' |
|
bl_idname = 'finalizer.convert_rig_to_mmd_compatible' # Operator identifier |
|
bl_label = 'Convert Rig to MMD friendly' # Menu label |
|
@@ -476,7 +476,7 @@ |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_SaveAsFinalizedFileName(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_SaveAsFinalizedFileName(bpy.types.Operator): |
|
'''Operator : Save this .blend as Finalized Branch''' |
|
bl_idname = 'finalizer.save_as_finalized_filename' # Operator identifier |
|
bl_label = 'Save As' # Menu label |
|
@@ -493,7 +493,7 @@ |
|
return {'FINISHED'} |
|
|
|
################################################################################################## |
|
-class OP_TransferWeightsFromSelectedToActive(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_TransferWeightsFromSelectedToActive(bpy.types.Operator): |
|
'''Operator: Transfer Weights form Selected Mesh to Active Mesh''' |
|
bl_idname = 'finalizer.transfer_weights_from_selected_to_active' # Operator identifier |
|
bl_label = 'Transfer Weights' # Menu label |
|
@@ -501,7 +501,7 @@ |
|
bl_options = {'REGISTER', 'UNDO'} # Options |
|
|
|
# Properties |
|
- UseRestPose = BoolProperty( |
|
+ UseRestPose: BoolProperty( |
|
name='Use Rest Pose', |
|
description='Temporally disable armature deforms during transfering, to prevent unexpected result', |
|
default=True |
|
@@ -515,7 +515,7 @@ |
|
('POLYINTERP_VNORPROJ', 'Projected Face Interpolated', 'Copy from interpolated values of vertices from point on closest face hit by normal-projection') |
|
) |
|
|
|
- MappingMode = EnumProperty( |
|
+ MappingMode: EnumProperty( |
|
name = 'Mapping', |
|
description = 'Method used to map source vertices destination ones', |
|
items=EnumTransferMappingModes, |
|
@@ -523,7 +523,7 @@ |
|
|
|
) |
|
|
|
- MaxDistance = FloatProperty( |
|
+ MaxDistance: FloatProperty( |
|
name='Max Distance', |
|
description='Max Distance to the surface, to pick vertex weights', |
|
subtype='DISTANCE', |
|
@@ -534,13 +534,13 @@ |
|
step=1 |
|
) |
|
|
|
- DoCleanupAfterTransfer = BoolProperty( |
|
+ DoCleanupAfterTransfer: BoolProperty( |
|
name='Clean weights', |
|
description='After transfer, low value weights will be removed and remained weights will be normalized', |
|
default=True |
|
) |
|
|
|
- CleanupValue = FloatProperty( |
|
+ CleanupValue: FloatProperty( |
|
name='Limit', |
|
description='Weights below this value will be removed', |
|
default = 0.009, |
|
@@ -559,7 +559,7 @@ |
|
col = self.layout.column() |
|
col.prop(self, 'MappingMode') |
|
row = col.row() |
|
- row.label('Max Distance:') |
|
+ row.label(text='Max Distance:') |
|
row.prop(self, 'MaxDistance' ) |
|
row=col.row() |
|
row.prop(self, 'DoCleanupAfterTransfer' ) |
|
@@ -625,7 +625,7 @@ |
|
|
|
|
|
################################################################################################## |
|
-class OP_RemoveUnusedVertexGroups(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_RemoveUnusedVertexGroups(bpy.types.Operator): |
|
'''Operator: Remove Unused Vertex Groups from Selected Objects''' |
|
bl_idname = 'finalizer.remove_unused_vertex_groups' |
|
bl_label = 'Clean Vertex Groups' |
|
@@ -633,13 +633,13 @@ |
|
bl_options = {'REGISTER', 'UNDO'} |
|
|
|
# properties |
|
- DoCleanupBeforeRemovingUnusedWeights = BoolProperty( |
|
+ DoCleanupBeforeRemovingUnusedWeights: BoolProperty( |
|
name='Clean weights', |
|
description='Before removing unused weight groups, low value weights will be removed and remained weights will be normalized', |
|
default=True |
|
) |
|
|
|
- CleanupValue = FloatProperty( |
|
+ CleanupValue: FloatProperty( |
|
name='Limit', |
|
description='Weights below this value will be removed', |
|
default = 0.009, |
|
@@ -655,10 +655,10 @@ |
|
# Main Function |
|
def execute(self, context): |
|
# iterate for all selected Mesh Objects |
|
- lastActiveObject = bpy.context.scene.objects.active |
|
+ lastActiveObject = bpy.context.view_layer.objects.active |
|
lastMode = bpy.context.mode |
|
bpy.ops.object.mode_set(mode='OBJECT') |
|
- bpy.context.scene.objects.active = None |
|
+ bpy.context.view_layer.objects.active = None |
|
|
|
meshes = GetMeshObjectsFromSelected() |
|
|
|
@@ -667,7 +667,7 @@ |
|
# print( 'OP_RemoveUnusedVertexGroups:'+mesh.name) |
|
if self.DoCleanupBeforeRemovingUnusedWeights: |
|
# select all vertices |
|
- bpy.context.scene.objects.active = mesh |
|
+ bpy.context.view_layer.objects.active = mesh |
|
bpy.ops.object.mode_set(mode='EDIT') # vertex selection only available in edit mode |
|
bpy.context.tool_settings.mesh_select_mode = (True, False, False) # Only Vertex Selection |
|
bpy.ops.mesh.select_all(action='SELECT') |
|
@@ -682,33 +682,33 @@ |
|
total+=count |
|
|
|
bpy.ops.object.mode_set(mode=lastMode) |
|
- bpy.context.scene.objects.active = lastActiveObject |
|
+ bpy.context.view_layer.objects.active = lastActiveObject |
|
|
|
self.report({'INFO'}, 'Removed '+str(total)+' Vertex Groups from '+str(len(meshes))+' Objects') |
|
return {'FINISHED'} |
|
|
|
|
|
################################################################################################## |
|
-class OP_TriangulateSelectedMeshes(bpy.types.Operator): |
|
+class MODELFINALIZER_OT_TriangulateSelectedMeshes(bpy.types.Operator): |
|
'''Operator: Triangulate Selected Meshes''' |
|
bl_idname = 'finalizer.triangulate_selected_meshes' |
|
bl_label = 'Triangulate' |
|
bl_description = 'Triangulate selected meshes. Then sort faces to sanitize transparent objects' |
|
bl_options = {'REGISTER', 'UNDO'} |
|
|
|
- QuadMethod = EnumProperty( |
|
+ QuadMethod: EnumProperty( |
|
name="Initial Quad Method", |
|
items=( |
|
- ('0', "Beauty", ""), |
|
- ('1', "Fixed", ""), |
|
- ('2', "Fixed Alternate", ""), |
|
- ('3', "Shortest Diagonal", "") |
|
+ ('BEAUTY', "Beauty", ""), |
|
+ ('FIXED', "Fixed", ""), |
|
+ ('ALTERNATE', "Fixed Alternate", ""), |
|
+ ('SHORT_EDGE', "Shortest Diagonal", "") |
|
), |
|
- default='0' |
|
+ default='BEAUTY' |
|
) |
|
|
|
# properties |
|
- SortElements = BoolProperty( |
|
+ SortElements: BoolProperty( |
|
name='Sort Faces', |
|
description='Sort faces in controlled order to get best transparent render result.', |
|
default=True |
|
@@ -729,7 +729,7 @@ |
|
# Triangulate the Mesh by using BMesh functions, to use world coodinate to sort |
|
bm = bmesh.new() |
|
bm.from_mesh(mesh.data) |
|
- bmesh.ops.triangulate(bm, faces=bm.faces, quad_method=int(self.QuadMethod), ngon_method=int(self.QuadMethod)) |
|
+ bmesh.ops.triangulate(bm, faces=bm.faces, quad_method=self.QuadMethod, ngon_method='BEAUTY') |
|
|
|
if self.SortElements: |
|
|
|
diff -u -r 2.79/model_finalizer/properties.py 2.8/model_finalizer/properties.py |
|
--- 2.79/model_finalizer/properties.py 2018-05-20 13:17:38.935842200 +0900 |
|
+++ 2.8/model_finalizer/properties.py 2020-05-01 09:48:53.193915800 +0900 |
|
@@ -9,31 +9,31 @@ |
|
class addon_properties(PropertyGroup): |
|
'''Properties for Model Finalizer''' |
|
|
|
- ShowExtraUtils =BoolProperty( |
|
+ ShowExtraUtils: BoolProperty( |
|
name='Bone Utils', |
|
description='Utilities for Bone Editing', |
|
default=False |
|
) |
|
|
|
- ShowMeshFinalizer = BoolProperty( |
|
+ ShowMeshFinalizer: BoolProperty( |
|
name='Mesh Finalizer', |
|
description='Apply modifiers and Finalize Mesh', |
|
default=False |
|
) |
|
|
|
- ShowPoseToShapeKey = BoolProperty( |
|
+ ShowPoseToShapeKey: BoolProperty( |
|
name='PoseLib to ShapeKey', |
|
description='Convert PoseLib to ShapeKey', |
|
default=False |
|
) |
|
|
|
- BatchConvert = BoolProperty( |
|
+ BatchConvert: BoolProperty( |
|
name='Batch Convert', |
|
description='If enabled, convert all Poses in PoseLib', |
|
default=False |
|
) |
|
|
|
- BatchFrom = IntProperty( |
|
+ BatchFrom: IntProperty( |
|
name='From', |
|
description='Batch convert from this index', |
|
default=0, |
|
@@ -41,7 +41,7 @@ |
|
max=100 |
|
) |
|
|
|
- BatchTo = IntProperty( |
|
+ BatchTo: IntProperty( |
|
name='To', |
|
description='Batch convert to this index', |
|
default=0, |
|
@@ -49,25 +49,25 @@ |
|
max=100 |
|
) |
|
|
|
- ApplyMirrorModifier = BoolProperty( |
|
+ ApplyMirrorModifier: BoolProperty( |
|
name = 'Apply Mirror Modifier', |
|
description = 'Apply and Remove Mirror Modifier before adding ShapeKeys', |
|
default = True |
|
) |
|
|
|
- RemoveConvertedPose = BoolProperty( |
|
+ RemoveConvertedPose: BoolProperty( |
|
name = 'Remove Converted Poses', |
|
description = 'After Pose To ShapeKey Conversion, Remove Converted Poses from Pose Library', |
|
default = True |
|
) |
|
|
|
- ForceSubsurfLevel = BoolProperty( |
|
+ ForceSubsurfLevel: BoolProperty( |
|
name='Force Subsurf Level', |
|
description='Force Subsurf Level when applying Subsurf Modifier', |
|
default=False |
|
) |
|
|
|
- SubsurfLevel = IntProperty( |
|
+ SubsurfLevel: IntProperty( |
|
name='Subsurf Level', |
|
description='Subsurf Level forced to this value', |
|
default=1, |
|
@@ -75,13 +75,13 @@ |
|
max=2 |
|
) |
|
|
|
- SmoothWeights = BoolProperty( |
|
+ SmoothWeights: BoolProperty( |
|
name='Smooth Weights', |
|
description='Do Weight Smoothing after applying Subsurf Modifier', |
|
default=True |
|
) |
|
|
|
- SmoothingStrength = FloatProperty( |
|
+ SmoothingStrength: FloatProperty( |
|
name='Smoothing Strength', |
|
description='Parameter used for Smoothing Weights', |
|
default = 1.0, |
|
@@ -89,13 +89,13 @@ |
|
max=1.0 |
|
) |
|
|
|
- LimitWeights = BoolProperty( |
|
+ LimitWeights: BoolProperty( |
|
name='Limit Weights', |
|
description='Limit deform weights per a vertex to a specified number', |
|
default=True |
|
) |
|
|
|
- LimitWeightsTo = IntProperty( |
|
+ LimitWeightsTo: IntProperty( |
|
name='Limit To', |
|
description='Maximun number of deform weigths per a vertex. Unity is limited to 4', |
|
default = 4, |
|
@@ -103,26 +103,25 @@ |
|
max = 32 |
|
) |
|
|
|
- ExcludeEdgeSplit = BoolProperty( |
|
+ ExcludeEdgeSplit: BoolProperty( |
|
name='Exclude EdgeSplit Modifier', |
|
description='Exclude EdgeSplit from Applying Modifiers', |
|
default=False |
|
) |
|
|
|
- ExcludeDataTransfer = BoolProperty( |
|
+ ExcludeDataTransfer: BoolProperty( |
|
name='Exclude DataTransfer Modifier', |
|
description='Exclude DataTransfer from Applying Modifiers', |
|
default=False |
|
) |
|
|
|
- ApplyPoseAsNewRest_AutoApplyMirror = BoolProperty( |
|
+ ApplyPoseAsNewRest_AutoApplyMirror: BoolProperty( |
|
name = 'Apply Mirror Modifier', |
|
description = 'If pose is asymmetrical, you need this turned on to get ideal result', |
|
default = False |
|
) |
|
|
|
- |
|
- RemoveModifiers_IncluidngArmature = BoolProperty( |
|
+ RemoveModifiers_IncluidngArmature: BoolProperty( |
|
name='Including Armature', |
|
description='Remove Armature modifiers too', |
|
default=True |