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'}
def execute(self, context): obj = context.active_object root = mmd_model.Model.findRoot(obj) if root is None: self.report({'ERROR'}, "The model root can't be found") return {'CANCELLED'} if not mmd_model.isRigidBodyObject(obj): self.report({'ERROR'}, 'Active object is not a MMD rigidbody') return {'CANCELLED'} rig = mmd_model.Model(root) selection = set(rig.rigidBodies()) for prop_name in self.properties: prop_value = getattr(obj.mmd_rigid, prop_name) if prop_name == 'collision_group_mask': prop_value = tuple(prop_value) for i in selection.copy(): if tuple(i.mmd_rigid.collision_group_mask) != prop_value: selection.remove(i) if self.hide_others: i.select = False i.hide = True else: for i in selection.copy(): if getattr(i.mmd_rigid, prop_name) != prop_value: selection.remove(i) if self.hide_others: i.select = False i.hide = True for i in selection: i.hide = False i.select = True return {'FINISHED'}
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)
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
def poll(cls, context): return mmd_model.isRigidBodyObject(context.active_object)