Beispiel #1
0
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root
        if self.type == 'MORPH':
            morph_type = mmd_root.active_morph_type
            morph = ItemOp.get_by_index(getattr(mmd_root, morph_type),
                                        mmd_root.active_morph)
            if morph is None:
                return {'CANCELLED'}

            morph_name = morph.name

            def __check(item):
                return item.type == 'MORPH' and item.name == morph_name and item.morph_type == morph_type

            self._find_display_item(mmd_root, __check)
        else:
            if context.active_bone is None:
                return {'CANCELLED'}

            bone_name = context.active_bone.name

            def __check(item):
                return item.type == 'BONE' and item.name == bone_name

            self._find_display_item(mmd_root, __check)
        return {'FINISHED'}
Beispiel #2
0
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root
        morph_type = mmd_root.active_morph_type
        morph = ItemOp.get_by_index(getattr(mmd_root, morph_type), mmd_root.active_morph)
        if morph is None:
            return {'CANCELLED'}

        if morph_type.startswith('material'):
            bpy.ops.mmd_tools.clear_temp_materials()

        if self.all:
            if morph_type.startswith('vertex'):
                for obj in mmd_model.Model(root).meshes():
                    FnMorph.remove_shape_key(obj, morph.name)
                return {'FINISHED'}
            elif morph_type.startswith('uv'):
                if morph.data_type == 'VERTEX_GROUP':
                    for obj in mmd_model.Model(root).meshes():
                        FnMorph.store_uv_morph_data(obj, morph)
                    return {'FINISHED'}
            morph.data.clear()
            morph.active_data = 0
        else:
            morph.data.remove(morph.active_data)
            morph.active_data = max(0, morph.active_data-1)
        return { 'FINISHED' }
Beispiel #3
0
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root
        morph_type = mmd_root.active_morph_type
        morph = ItemOp.get_by_index(getattr(mmd_root, morph_type), mmd_root.active_morph)
        if morph is None:
            return {'CANCELLED'}

        item, morph.active_data = ItemOp.add_after(morph.data, morph.active_data)

        if morph_type.startswith('material'):
            if obj.type == 'MESH' and obj.mmd_type == 'NONE':
                item.related_mesh = obj.data.name
                active_material = obj.active_material
                if active_material and '_temp' not in active_material.name:
                    item.material = active_material.name

        elif morph_type.startswith('bone'):
            pose_bone = context.active_pose_bone
            if pose_bone:
                item.bone = pose_bone.name
                item.location = pose_bone.location
                item.rotation = pose_bone.rotation_quaternion

        return { 'FINISHED' }
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root
        frame = ItemOp.get_by_index(mmd_root.display_item_frames, mmd_root.active_display_item_frame)
        if frame is None:
            return {'CANCELLED'}

        if frame.name == u'表情':
            morph = ItemOp.get_by_index(getattr(mmd_root, mmd_root.active_morph_type), mmd_root.active_morph)
            morph_name = morph.name if morph else 'Morph Item'
            self._add_item(frame, 'MORPH', morph_name, mmd_root.active_morph_type)
        else:
            bone_name = context.active_bone.name if context.active_bone else 'Bone Item'
            self._add_item(frame, 'BONE', bone_name)
        return {'FINISHED'}
Beispiel #5
0
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root

        morph_type = mmd_root.active_morph_type
        morphs = getattr(mmd_root, morph_type)
        morph = ItemOp.get_by_index(morphs, mmd_root.active_morph)
        if morph is None:
            return {'CANCELLED'}

        name_orig, name_tmp = morph.name, '_tmp%s'%str(morph.as_pointer())

        if morph_type.startswith('vertex'):
            for obj in mmd_model.Model(root).meshes():
                FnMorph.copy_shape_key(obj, name_orig, name_tmp)

        elif morph_type.startswith('uv'):
            if morph.data_type == 'VERTEX_GROUP':
                for obj in mmd_model.Model(root).meshes():
                    FnMorph.copy_uv_morph_vertex_groups(obj, name_orig, name_tmp)

        morph_new, mmd_root.active_morph = ItemOp.add_after(morphs, mmd_root.active_morph)
        for k, v in morph.items():
            morph_new[k] = v if k != 'name' else name_tmp
        morph_new.name = name_orig + '_copy' # trigger name check
        return {'FINISHED'}
 def execute(self, context):
     obj = context.active_object
     root = mmd_model.Model.findRoot(obj)
     mmd_root = root.mmd_root
     frame = ItemOp.get_by_index(mmd_root.display_item_frames, mmd_root.active_display_item_frame)
     if frame is None:
         return {'CANCELLED'}
     frame.active_item = self.move(frame.items, frame.active_item, self.type)
     return {'FINISHED'}
    def draw(self, context):
        active_obj = context.active_object
        root = mmd_model.Model.findRoot(active_obj)
        if root is None:
            c = self.layout.column()
            c.label('Select a MMD Model')
            return

        mmd_root = root.mmd_root
        col = self.layout.column()
        row = col.row()
        row.template_list(
            "MMD_ROOT_UL_display_item_frames",
            "",
            mmd_root, "display_item_frames",
            mmd_root, "active_display_item_frame",
            )
        tb = row.column()
        tb1 = tb.column(align=True)
        tb1.operator('mmd_tools.display_item_frame_add', text='', icon='ZOOMIN')
        tb1.operator('mmd_tools.display_item_frame_remove', text='', icon='ZOOMOUT')
        tb1.menu('OBJECT_MT_mmd_tools_display_item_frame_menu', text='', icon='DOWNARROW_HLT')
        tb.separator()
        tb1 = tb.column(align=True)
        tb1.operator('mmd_tools.display_item_frame_move', text='', icon='TRIA_UP').type = 'UP'
        tb1.operator('mmd_tools.display_item_frame_move', text='', icon='TRIA_DOWN').type = 'DOWN'

        frame = ItemOp.get_by_index(mmd_root.display_item_frames, mmd_root.active_display_item_frame)
        if frame is None:
            return

        c = col.column(align=True)
        row = c.row()
        row.template_list(
            "MMD_ROOT_UL_display_items",
            "",
            frame, "items",
            frame, "active_item",
            )
        tb = row.column()
        tb1 = tb.column(align=True)
        tb1.operator('mmd_tools.display_item_add', text='', icon='ZOOMIN')
        tb1.operator('mmd_tools.display_item_remove', text='', icon='ZOOMOUT')
        tb1.menu('OBJECT_MT_mmd_tools_display_item_menu', text='', icon='DOWNARROW_HLT')
        tb.separator()
        tb1 = tb.column(align=True)
        tb1.operator('mmd_tools.display_item_move', text='', icon='TRIA_UP').type = 'UP'
        tb1.operator('mmd_tools.display_item_move', text='', icon='TRIA_DOWN').type = 'DOWN'

        row = col.row()
        r = row.row(align=True)
        r.operator('mmd_tools.display_item_find', text='Bone', icon='VIEWZOOM').type = 'BONE'
        r.operator('mmd_tools.display_item_find', text='Morph', icon='VIEWZOOM').type = 'MORPH'
        row.operator('mmd_tools.display_item_select_current', text='Select')
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root
        frame = ItemOp.get_by_index(mmd_root.display_item_frames, mmd_root.active_display_item_frame)
        if frame is None:
            return {'CANCELLED'}
        item = ItemOp.get_by_index(frame.items, frame.active_item)
        if item is None:
            return {'CANCELLED'}

        if item.type == 'MORPH':
            morphs = getattr(mmd_root, item.morph_type)
            index = morphs.find(item.name)
            if index >= 0:
                mmd_root.active_morph_type = item.morph_type
                mmd_root.active_morph = index
        else:
            utils.selectSingleBone(context, mmd_model.Model(root).armature(), item.name)
        return {'FINISHED'}
 def _template_morph_offset_list(self, layout, morph, list_type_name):
     row = layout.row()
     row.template_list(
         list_type_name, '',
         morph, 'data',
         morph, 'active_data',
         )
     tb = row.column()
     tb1 = tb.column(align=True)
     tb1.operator('mmd_tools.morph_offset_add', text='', icon='ZOOMIN')
     tb1.operator('mmd_tools.morph_offset_remove', text='', icon='ZOOMOUT')
     tb.operator('mmd_tools.morph_offset_remove', text='', icon='X').all = True
     return ItemOp.get_by_index(morph.data, morph.active_data)
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root

        index = mmd_root.active_display_item_frame
        frames = mmd_root.display_item_frames
        frame = ItemOp.get_by_index(frames, index)
        if frame and frame.is_special:
            pass
        else:
            mmd_root.active_display_item_frame = self.move(frames, index, self.type, index_min=2)
        return {'FINISHED'}
Beispiel #11
0
 def execute(self, context):
     obj = context.active_object
     root = mmd_model.Model.findRoot(obj)
     mmd_root = root.mmd_root
     frame = ItemOp.get_by_index(mmd_root.display_item_frames, mmd_root.active_display_item_frame)
     if frame is None:
         return {'CANCELLED'}
     if self.all:
         frame.items.clear()
         frame.active_item = 0
     else:
         frame.items.remove(frame.active_item)
         frame.active_item = max(0, frame.active_item-1)
     return {'FINISHED'}
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root

        index = mmd_root.active_display_item_frame
        frames = mmd_root.display_item_frames
        frame = ItemOp.get_by_index(frames, index)
        if frame and frame.is_special:
            frame.items.clear()
            frame.active_item = 0
        else:
            frames.remove(index)
            mmd_root.active_display_item_frame = min(len(frames)-1, max(2, index-1))
        return {'FINISHED'}
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        mmd_root = root.mmd_root
        morph_type = mmd_root.active_morph_type
        morph = ItemOp.get_by_index(getattr(mmd_root, morph_type),
                                    mmd_root.active_morph)
        if morph is None:
            return {'CANCELLED'}

        if morph_type.startswith('material'):
            bpy.ops.mmd_tools.clear_temp_materials()

        morph.data.remove(morph.active_data)
        morph.active_data = max(0, morph.active_data - 1)
        return {'FINISHED'}
Beispiel #14
0
    def draw(self, context):
        active_obj = context.active_object
        root = mmd_model.Model.findRoot(active_obj)
        if root is None:
            c = self.layout.column()
            c.label('Select a MMD Model')
            return

        rig = mmd_model.Model(root)
        mmd_root = root.mmd_root
        col = self.layout.column()
        row = col.row()
        row.prop(mmd_root, 'active_morph_type', expand=True)
        morph_type = mmd_root.active_morph_type

        c = col.column(align=True)
        row = c.row()
        row.template_list("UL_Morphs", "", mmd_root, morph_type, mmd_root,
                          "active_morph")
        tb = row.column()
        tb1 = tb.column(align=True)
        tb1.operator('mmd_tools.morph_add', text='', icon='ZOOMIN')
        tb1.operator('mmd_tools.morph_remove', text='', icon='ZOOMOUT')
        tb1.menu('OBJECT_MT_mmd_tools_morph_menu',
                 text='',
                 icon='DOWNARROW_HLT')
        tb.separator()
        tb1 = tb.column(align=True)
        tb1.operator('mmd_tools.morph_move', text='',
                     icon='TRIA_UP').type = 'UP'
        tb1.operator('mmd_tools.morph_move', text='',
                     icon='TRIA_DOWN').type = 'DOWN'

        morph = ItemOp.get_by_index(getattr(mmd_root, morph_type),
                                    mmd_root.active_morph)
        if morph:
            slider = rig.morph_slider.get(morph.name)
            if slider:
                col.row().prop(slider, 'value')
            draw_func = getattr(self, '_draw_%s_data' % morph_type[:-7], None)
            if draw_func:
                draw_func(context, rig, col, morph)