def execute(self, **args): if 'pmx' in args: self.__model = args['pmx'] else: self.__model = pmx.load(args['filepath']) self.__scale = args.get('scale', 1.0) self.__ignoreNonCollisionGroups = args.get('ignore_non_collision_groups', True) self.__use_mipmap = args.get('use_mipmap', True) self.__sph_blend_factor = args.get('sph_blend_factor', 1.0) self.__spa_blend_factor = args.get('spa_blend_factor', 1.0) logging.info('****************************************') logging.info(' mmd_tools.import_pmx module') logging.info('----------------------------------------') logging.info(' Start to load model data form a pmx file') logging.info(' by the mmd_tools.pmx modlue.') logging.info('') start_time = time.time() self.__createGroups() self.__createObjects() self.__importVertices() self.__importBones() self.__importMaterials() self.__importFaces() self.__importRigids() self.__importJoints() self.__importDisplayFrames() self.__importVertexMorphs() self.__importBoneMorphs() self.__importMaterialMorphs() if args.get('rename_LR_bones', False): self.__renameLRBones() self.__addArmatureModifier(self.__meshObj, self.__armObj) self.__meshObj.data.update() self.__armObj.pmx_import_scale = self.__scale for i in [self.__rigidObjGroup.objects, self.__jointObjGroup.objects, self.__tempObjGroup.objects]: for j in i: self.__allObjGroup.objects.link(j) bpy.context.scene.gravity[2] = -9.81 * 10 * self.__scale self.__rig.rootObject().mmd_root.show_meshes = True self.__rig.applyAdditionalTransformConstraints() logging.info(' Finished importing the model in %f seconds.', time.time() - start_time) logging.info('----------------------------------------') logging.info(' mmd_tools.import_pmx module') logging.info('****************************************')
def execute(self, **args): if 'pmx' in args: self.__model = args['pmx'] else: self.__model = pmx.load(args['filepath']) self.__fixRepeatedMorphName() types = args.get('types', set()) clean_model = args.get('clean_model', False) remove_doubles = args.get('remove_doubles', False) self.__scale = args.get('scale', 1.0) self.__use_mipmap = args.get('use_mipmap', True) self.__sph_blend_factor = args.get('sph_blend_factor', 1.0) self.__spa_blend_factor = args.get('spa_blend_factor', 1.0) self.__fix_IK_links = args.get('fix_IK_links', False) self.__apply_bone_fixed_axis = args.get('apply_bone_fixed_axis', False) self.__translator = args.get('translator', None) logging.info('****************************************') logging.info(' mmd_tools.import_pmx module') logging.info('----------------------------------------') logging.info(' Start to load model data form a pmx file') logging.info(' by the mmd_tools.pmx modlue.') logging.info('') start_time = time.time() self.__createObjects() if 'MESH' in types: if clean_model: _PMXCleaner.clean(self.__model, 'MORPHS' not in types) if remove_doubles: self.__vertex_map = _PMXCleaner.remove_doubles(self.__model, 'MORPHS' not in types) self.__createMeshObject() self.__importVertices() self.__importMaterials() self.__importFaces() self.__meshObj.data.update() self.__assignCustomNormals() self.__storeVerticesSDEF() if 'ARMATURE' in types: # for tracking bone order if 'MESH' not in types: self.__createMeshObject() self.__importVertexGroup() self.__importBones() if args.get('rename_LR_bones', False): use_underscore = args.get('use_underscore', False) self.__renameLRBones(use_underscore) if self.__translator: self.__translateBoneNames() if self.__apply_bone_fixed_axis: FnBone.apply_bone_fixed_axis(self.__armObj) FnBone.apply_additional_transformation(self.__armObj) if 'PHYSICS' in types: self.__importRigids() self.__importJoints() if 'DISPLAY' in types: self.__importDisplayFrames() else: self.__rig.initialDisplayFrames() if 'MORPHS' in types: self.__importGroupMorphs() self.__importVertexMorphs() self.__importBoneMorphs() self.__importMaterialMorphs() self.__importUVMorphs() if self.__meshObj: self.__addArmatureModifier(self.__meshObj, self.__armObj) #bpy.context.scene.gravity[2] = -9.81 * 10 * self.__scale root = self.__root if 'ARMATURE' in types: root.mmd_root.show_armature = True if 'MESH' in types: root.mmd_root.show_meshes = True self.__targetScene.active_object = root root.select = True logging.info(' Finished importing the model in %f seconds.', time.time() - start_time) logging.info('----------------------------------------') logging.info(' mmd_tools.import_pmx module') logging.info('****************************************')