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 _getActiveRigidbodyObject(prop):
    objects = SceneOp(bpy.context).id_objects
    active_obj = objects.active
    if mmd_model.isRigidBodyObject(active_obj):
        prop['active_rigidbody_object_index'] = objects.find(active_obj.name)
    return prop.get('active_rigidbody_object_index', 0)
Esempio n. 3
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
Esempio n. 4
0
 def poll(cls, context):
     return mmd_model.isRigidBodyObject(context.active_object)