def test_roundtrip_compressed_animation(self): hierarchy_name = 'testhiera_skl' hierarchy = get_hierarchy(hierarchy_name) meshes = [ get_mesh(name='sword', skin=True), get_mesh(name='soldier', skin=True), get_mesh(name='TRUNK') ] hlod = get_hlod('testmodelname', hierarchy_name) boxes = [get_collision_box()] dazzles = [get_dazzle()] comp_animation = get_compressed_animation(hierarchy_name) self.filepath = self.outpath() + 'output_skn' create_data(self, meshes, hlod, hierarchy, boxes, None, comp_animation, dazzles) # export self.filepath = self.outpath() + 'output_skn' export_settings = {'mode': 'HM', 'use_existing_skeleton': True} save_data(self, export_settings) self.filepath = self.outpath() + 'testhiera_skl' export_settings['mode'] = 'H' save_data(self, export_settings) self.filepath = self.outpath() + 'output_comp_ani' export_settings['mode'] = 'A' export_settings['compression'] = 'TC' save_data(self, export_settings) # reset scene bpy.ops.wm.read_homefile(app_template='') # import self.filepath = self.outpath() + 'output_skn.w3d' load(self) self.filepath = self.outpath() + 'output_comp_ani.w3d' load(self) # check created objects self.assertTrue(hierarchy_name.upper() in bpy.data.objects) self.assertTrue(hierarchy_name.upper() in bpy.data.armatures) amt = bpy.data.armatures[hierarchy_name.upper()] self.assertEqual(7, len(amt.bones)) self.assertTrue('sword' in bpy.data.objects) self.assertTrue('soldier' in bpy.data.objects) self.assertTrue('TRUNK' in bpy.data.objects) self.assertTrue('Brakelight' in bpy.data.objects)
def test_skips_multiple_compressed_animation_chunks(self): animation = get_animation() comp_animation = get_compressed_animation() ani = open(self.outpath() + 'output.w3d', 'wb') comp_animation.write(ani) animation.write(ani) animation.write(ani) ani.close() # import with (patch.object(self, 'warning')) as warning_func: self.filepath = self.outpath() + 'output.w3d' load(self) msg = '-> already got one animation chunk (skipping this one)!' warning_func.assert_has_calls([call(msg), call(msg)])
def test_roundtrip_HAM(self): hierarchy_name = "TestName" hierarchy = get_hierarchy(hierarchy_name) meshes = [ get_mesh(name="sword", skin=True), get_mesh(name="soldier", skin=True), get_mesh(name="TRUNK")] hlod = get_hlod(hierarchy_name, hierarchy_name) box = get_box() animation = get_animation(hierarchy_name) comp_animation = get_compressed_animation(hierarchy_name) # write to file output = open(self.outpath() + "base.w3d", "wb") hierarchy.write(output) for mesh in meshes: mesh.write(output) hlod.write(output) box.write(output) animation.write(output) comp_animation.write(output) output.close() # import model = ImportWrapper(self.outpath() + "base.w3d") load(model, import_settings={}) # check created objects self.assertTrue("TestName" in bpy.data.armatures) amt = bpy.data.armatures["TestName"] self.assertEqual(6, len(amt.bones)) self.assertTrue("sword" in bpy.data.objects) self.assertTrue("soldier" in bpy.data.objects) self.assertTrue("TRUNK" in bpy.data.objects) # export export_settings = {} export_settings['w3d_mode'] = "HAM" export_settings['w3d_compression'] = "U" context = ImportWrapper(self.outpath() + "output.w3d") save(context, export_settings)
def test_roundtrip_HAM_tc_animation(self): hierarchy_name = 'TestName' hierarchy = get_hierarchy(hierarchy_name) meshes = [ get_mesh(name='sword', skin=True), get_mesh(name='soldier', skin=True), get_mesh(name='TRUNK') ] hlod = get_hlod(hierarchy_name, hierarchy_name) boxes = [get_collision_box()] dazzles = [get_dazzle()] comp_animation = get_compressed_animation(hierarchy_name) self.filepath = self.outpath() + 'output' create_data(self, meshes, hlod, hierarchy, boxes, None, comp_animation, dazzles) # export self.filepath = self.outpath() + 'output' export_settings = {'mode': 'HAM', 'compression': 'TC'} save_data(self, export_settings) # reset scene bpy.ops.wm.read_homefile(app_template='') # import self.filepath = self.outpath() + 'output.w3d' load(self) # check created objects self.assertTrue('output' in bpy.data.armatures) amt = bpy.data.armatures['output'] self.assertEqual(7, len(amt.bones)) self.assertTrue('sword' in bpy.data.objects) self.assertTrue('soldier' in bpy.data.objects) self.assertTrue('TRUNK' in bpy.data.objects) self.assertTrue('Brakelight' in bpy.data.objects)
def test_roundtrip(self): hierarchy_name = "TestHiera_SKL" hierarchy = get_hierarchy(hierarchy_name) meshes = [ get_mesh(name="sword", skin=True), get_mesh(name="soldier", skin=True), get_mesh(name="TRUNK")] hlod = get_hlod("TestModelName", hierarchy_name) box = get_box() animation = get_animation(hierarchy_name) comp_animation = get_compressed_animation(hierarchy_name) copyfile(up(up(self.relpath())) + "/testfiles/texture.dds", self.outpath() + "texture.dds") # write to file skn = open(self.outpath() + "base_skn.w3d", "wb") for mesh in meshes: mesh.write(skn) hlod.write(skn) box.write(skn) skn.close() skl = open(self.outpath() + hierarchy_name + ".w3d", "wb") hierarchy.write(skl) skl.close() ani = open(self.outpath() + "base_ani.w3d", "wb") animation.write(ani) comp_animation.write(ani) ani.close() comp_ani = open(self.outpath() + "base_comp_ani.w3d", "wb") comp_animation.write(comp_ani) comp_ani.close() # import model = ImportWrapper(self.outpath() + "base_skn.w3d") load(model, import_settings={}) anim = ImportWrapper(self.outpath() + "base_ani.w3d") load(anim, import_settings={}) comp_anim = ImportWrapper(self.outpath() + "base_comp_ani.w3d") load(comp_anim, import_settings={}) # check created objects self.assertTrue("TestHiera_SKL" in bpy.data.objects) self.assertTrue("TestHiera_SKL" in bpy.data.armatures) amt = bpy.data.armatures["TestHiera_SKL"] self.assertEqual(6, len(amt.bones)) self.assertTrue("sword" in bpy.data.objects) self.assertTrue("soldier" in bpy.data.objects) self.assertTrue("TRUNK" in bpy.data.objects) # export context = ImportWrapper(self.outpath() + "output_skn.w3d") export_settings = {} export_settings['w3d_mode'] = "M" save(context, export_settings) context = ImportWrapper(self.outpath() + "output_skl.w3d") export_settings['w3d_mode'] = "H" save(context, export_settings) context = ImportWrapper(self.outpath() + "output_ani.w3d") export_settings['w3d_mode'] = "A" export_settings['w3d_compression'] = "U" save(context, export_settings) context = ImportWrapper(self.outpath() + "output_comp_ani.w3d") export_settings['w3d_mode'] = "A" export_settings['w3d_compression'] = "TC" save(context, export_settings)