def test_save_and_load_multi_bind_equal(self): fname = self._get_tmp('.dae') converter = DaeConverter( self._get_brres('simple_multi_bone_multi_bind.brres'), fname) converter.save_model() original = converter.mdl0 converter = DaeConverter(self._get_tmp('.brres'), fname) converter.load_model() self.assertTrue(CheckPositions().model_equal(original, converter.mdl0))
def test_save_and_load_uv_mtx(self): fname = self._get_tmp('.dae') converter = DaeConverter(self._get_brres('kuribo.brres'), fname) converter.save_model('kuribo') converter = DaeConverter(self._get_tmp('.brres'), fname) converter.load_model() # converter.brres.save(overwrite=True) poly = converter.mdl0.objects[0] expected = [False, True, True] expected.extend([False] * 5) self.assertEqual(expected, [poly.has_uv_matrix(i) for i in range(8)])
def test_save_multi_bone_single_bind(self): fname = self._get_tmp('.dae') converter = DaeConverter( self._get_brres('simple_multi_bone_single_bind.brres'), fname) converter.save_model() original = converter.mdl0 converter = DaeConverter(self._get_tmp('.brres'), fname) converter.load_model() converter.brres.save(overwrite=True) self.assertTrue(CheckPositions().model_equal(original, converter.mdl0, 0.01, 0.001))
def test_save_multi_influence_per_face_index(self): converter = DaeConverter(self._get_brres('koopaFigure.brres'), self._get_tmp('.dae')) converter.save_model() original = converter.mdl0 new = DaeConverter(self._get_tmp('.brres'), converter.mdl_file).load_model() self.assertTrue( CheckPositions.positions_equal(original.vertices, new.vertices, rtol=0.1, atol=0.01)) self.assertTrue(CheckPositions.bones_equal(original.bones, new.bones))
def test_save_multi_bone_scaled_as_single_bone(self): fname = self._get_tmp('.dae') converter = DaeConverter( self._get_brres('simple_multi_bone_scaled.brres'), fname, flags=DaeConverter.SINGLE_BONE) converter.save_model() # load it to test against original converter = DaeConverter(self._get_tmp('.brres'), fname) converter.load_model() original = self._get_brres('simple.brres').models[0] self.assertTrue(CheckPositions().positions_equal( original.vertices, converter.mdl0.vertices)) self.assertNotEqual(original.bones, converter.mdl0.bones) # should be scaled
def test_save_and_load_polygons_bound_to_single_material(self): converter = DaeConverter(self._get_brres('castleflower1.brres'), self._get_tmp('.dae')) converter.save_model() original = converter.mdl0 new = DaeConverter(self._get_tmp('.brres'), converter.mdl_file).load_model() self.assertTrue( CheckPositions.positions_equal(original.vertices, new.vertices, rtol=0.1, atol=0.01)) self.assertTrue( CheckPositions.bones_equal( [x.linked_bone for x in original.objects], [x.linked_bone for x in new.objects]))
def test_save_multi_bone_as_single_bone(self): fname = self._get_tmp('.dae') converter = DaeConverter( self._get_brres('simple_multi_bone_single_bind.brres'), fname, flags=DaeConverter.SINGLE_BONE) converter.save_model() # load it to test against original converter = DaeConverter(self._get_tmp('.brres'), fname) converter.load_model() # converter.brres.save(overwrite=True) original = self._get_brres('simple.brres').models[0] new = converter.mdl0 self.assertTrue(CheckPositions().bones_equal(original.bones, new.bones, 0.01, 0.001)) self.assertTrue(CheckPositions().positions_equal( original.vertices, new.vertices, 0.01, 0.001))
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