Esempio n. 1
0
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        rig = mmd_model.Model(root)

        arm = rig.armature()
        bone_map = {}
        for i in context.selected_objects:
            if mmd_model.isRigidBodyObject(i):
                bone_map[i] = arm.data.bones.get(i.mmd_rigid.bone, None)

        if len(bone_map) < 2:
            self.report({'ERROR'},
                        "Please select two or more mmd rigid objects")
            return {'CANCELLED'}

        utils.selectAObject(root)
        root.select = False
        if context.scene.rigidbody_world is None:
            bpy.ops.rigidbody.world_add()

        for pair in self.__enumerate_rigid_pair(bone_map):
            joint = self.__add_joint(rig, pair, bone_map)
            joint.select = True

        return {'FINISHED'}
Esempio n. 2
0
 def execute(self, context):
     obj = context.active_object
     root = mmd_model.Model.findRoot(obj)
     utils.selectAObject(obj)  #ensure this is the only one object select
     bpy.ops.object.delete(use_global=True)
     if root:
         utils.selectAObject(root)
     return {'FINISHED'}
Esempio n. 3
0
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        rig = mmd_model.Model(root)
        arm = rig.armature()
        if obj != arm:
            utils.selectAObject(root)
            root.select = False
        elif arm.mode != 'POSE':
            bpy.ops.object.mode_set(mode='POSE')

        selected_pose_bones = []
        if context.selected_pose_bones:
            selected_pose_bones = context.selected_pose_bones

        arm.select = False
        if len(selected_pose_bones) > 0:
            for pose_bone in selected_pose_bones:
                rigid = self.__add_rigid_body(rig, arm, pose_bone)
                rigid.select = True
        else:
            rigid = self.__add_rigid_body(rig)
            rigid.select = True
        return {'FINISHED'}
Esempio n. 4
0
def _setActiveMeshObject(prop, v):
    obj = SceneOp(bpy.context).id_objects[v]
    if obj.type == 'MESH' and obj.mmd_type == 'NONE':
        obj.hide = False
        utils.selectAObject(obj)
    prop['active_mesh_index'] = v
Esempio n. 5
0
def _setActiveJointObject(prop, v):
    obj = SceneOp(bpy.context).id_objects[v]
    if mmd_model.isJointObject(obj):
        obj.hide = False
        utils.selectAObject(obj)
    prop['active_joint_object_index'] = v
Esempio n. 6
0
def _setActiveRigidbodyObject(prop, v):
    obj = SceneOp(bpy.context).id_objects[v]
    if mmd_model.isRigidBodyObject(obj):
        obj.hide = False
        utils.selectAObject(obj)
    prop['active_rigidbody_object_index'] = v