def test_export_import_dae_eq(self): AutoFix.set_fix_level(0, load_config.turn_off_fixes) tmp = self._get_tmp('.dae') tmp_brres = self._get_tmp('.brres') for x in gather_files(self.root): try: converter = DaeConverter(Brres(x), tmp) for model in converter.brres.models: converter.save_model(model) importer = DaeConverter(Brres(tmp_brres, read_file=False), tmp) importer.load_model() mats = sorted(model.materials, key=lambda x: x.name) imported_mats = sorted(importer.mdl0.materials, key=lambda x: x.name) self.assertTrue(node_eq(mats, imported_mats)) except: print(f'ERROR converting {x}') if converter.brres.version == 11: raise
def load_config(app_dir=None, loudness=None, autofix_level=None): if app_dir is None: app_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'etc', 'abmatt') conf = Config.get_instance(os.path.join(app_dir, 'config.conf')) tmp_dir = os.path.join(app_dir, 'temp_files') converter = ImgConverter(tmp_dir) Tex0.converter = converter if not loudness: loudness = conf['loudness'] if loudness: try: AutoFix.set_loudness(loudness) except ValueError: AutoFix.warn('Invalid loudness level {}'.format(loudness)) AutoFix.set_fix_level(autofix_level, turn_off_fixes) if not len(conf): AutoFix.warn('No configuration detected (etc/abmatt/config.conf).') return Command.set_max_brres_files(conf) # Matching stuff MATCHING.set_case_sensitive(conf['case_sensitive']) MATCHING.set_partial_matching(conf['partial_matching']) MATCHING.set_regex_enable(conf['regex_matching']) # Autofixes try: SubFile.FORCE_VERSION = validBool(conf['force_version']) except ValueError: pass try: Brres.REMOVE_UNUSED_TEXTURES = validBool( conf['remove_unused_textures']) except ValueError: pass try: Layer.MINFILTER_AUTO = validBool(conf['minfilter_auto']) except ValueError: pass set_rename_unknown(conf['rename_unknown_refs']) set_remove_unknown(conf['remove_unknown_refs']) set_remove_unused(conf['remove_unused_refs']) try: Mdl0.DETECT_MODEL_NAME = validBool(conf['detect_model_name']) except ValueError: pass try: Shader.MAP_ID_AUTO = validBool(conf['map_id_auto']) except ValueError: pass try: Material.DEFAULT_COLOR = parse_color(conf['default_material_color']) except ValueError: pass try: Tex0.RESIZE_TO_POW_TWO = validBool(conf['resize_pow_two']) except ValueError: pass try: Tex0.set_max_image_size(validInt(conf['max_image_size'], 0, 10000)) except (TypeError, ValueError): pass try: Geometry.ENABLE_VERTEX_COLORS = validBool(conf['enable_vertex_colors']) except ValueError: pass Converter.ENCODE_PRESET = conf['encode_preset'] resample = conf['img_resample'] if resample is not None: ImgConverterI.set_resample(resample) if conf['material_library']: MaterialLibrary.LIBRARY_PATH = conf.config.get('material_library') else: MaterialLibrary.LIBRARY_PATH = os.path.join(app_dir, 'mat_lib.brres') return conf