diff --git a/tools/armature.py b/tools/armature.py index 45e57d1..5445e55 100644 --- a/tools/armature.py +++ b/tools/armature.py @@ -209,9 +209,6 @@ def execute(self, context): except TypeError: print('Color Management View Transform "Standard" not found!') - # Set shading to 3D view - set_material_shading() - # Remove Rigidbodies and joints if context.scene.remove_rigidbodies_joints: to_delete = [] @@ -322,10 +319,6 @@ def execute(self, context): Common.sort_shape_keys(mesh.name, shapekey_order) - - # Clean material names. Combining mats would do this too - Common.clean_material_names(mesh) - # Remove empty shape keys and then save the shape key order Common.clean_shapekeys(mesh) Common.save_shapekey_order(mesh.name) @@ -1163,7 +1156,7 @@ def add_eye_children(eye_bone, parent_name): if not source_engine: try: bpy.ops.mmd_tools_local.set_shadeless_glsl_shading() - set_material_shading() + Common.set_material_shading() except RuntimeError: pass @@ -1236,17 +1229,3 @@ def check_hierarchy(check_parenting, correct_hierarchy_array): return {'result': False, 'message': bone.name + t('FixArmature.notParentTo1') + previous + t('FixArmature.notParentTo2')} return {'result': True} - - -def set_material_shading(): - # Set shading to 3D view - for area in bpy.context.screen.areas: # iterate through areas in current screen - if area.type == 'VIEW_3D': - for space in area.spaces: # iterate through spaces in current VIEW_3D area - if space.type == 'VIEW_3D': # check if space is a 3D view - space.shading.type = 'MATERIAL' # set the viewport shading to rendered - space.shading.studio_light = 'forest.exr' - space.shading.studiolight_rotate_z = 0.0 - space.shading.studiolight_background_alpha = 0.0 - if bpy.app.version >= (2, 82): - space.shading.render_pass = 'COMBINED' diff --git a/tools/common.py b/tools/common.py index 4b8e571..46b75b7 100644 --- a/tools/common.py +++ b/tools/common.py @@ -2360,3 +2360,16 @@ def op_override(operator, context_override: Dict[str, Any], context: Optional[bp args.append(undo) return operator(*args, **operator_args) + +def set_material_shading(): + # Set shading to 3D view + for area in bpy.context.screen.areas: # iterate through areas in current screen + if area.type == 'VIEW_3D': + for space in area.spaces: # iterate through spaces in current VIEW_3D area + if space.type == 'VIEW_3D': # check if space is a 3D view + space.shading.type = 'MATERIAL' # set the viewport shading to rendered + space.shading.studio_light = 'forest.exr' + space.shading.studiolight_rotate_z = 0.0 + space.shading.studiolight_background_alpha = 0.0 + if bpy.app.version >= (2, 82): + space.shading.render_pass = 'COMBINED' \ No newline at end of file diff --git a/tools/material.py b/tools/material.py index 747f249..dc3189b 100644 --- a/tools/material.py +++ b/tools/material.py @@ -167,6 +167,9 @@ def poll(cls, context): def execute(self, context): armature = Common.get_armature() meshes = Common.get_meshes_objects() + + Common.set_material_shading() + # If all materials are transparent, make them visible. Also set transparency always to Z-Transparency # Make materials exportable in Blender 2.80 and remove glossy mmd shader look # Common.remove_toon_shader(mesh)