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 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 _add_item(self, frame, item_type, item_name, morph_type=None): items = frame.data item, index = ItemOp.add_after(items, frame.active_item) item.type = item_type item.name = item_name if morph_type: item.morph_type = morph_type frame.active_item = index
def execute(self, context): obj = context.active_object root = mmd_model.Model.findRoot(obj) mmd_root = root.mmd_root frames = mmd_root.display_item_frames item, index = ItemOp.add_after( frames, max(1, mmd_root.active_display_item_frame)) item.name = 'Display Frame' mmd_root.active_display_item_frame = index 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 morphs = getattr(mmd_root, morph_type) morph, mmd_root.active_morph = ItemOp.add_after( morphs, mmd_root.active_morph) morph.name = 'New Morph' if morph_type.startswith('uv'): morph.data_type = 'VERTEX_GROUP' return {'FINISHED'}