コード例 #1
0
    def test_roundtrip_splitted(self):
        hierarchy_name = 'testname_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(hierarchy_name, hierarchy_name)
        boxes = [get_collision_box()]
        animation = get_animation(hierarchy_name, xml=True)

        self.set_format('W3X')
        self.filepath = self.outpath() + 'output_skn'
        create_data(self, meshes, hlod, hierarchy, boxes, animation, None)

        # export
        self.filepath = self.outpath() + 'output_skn'
        export_settings = {
            'mode': 'HM',
            'compression': 'U',
            'individual_files': True,
            'create_texture_xmls': True,
            'use_existing_skeleton': False
        }
        save_data(self, export_settings)

        # check created files
        self.assertTrue(os.path.exists(self.outpath() + 'output_skn.w3x'))
        self.assertTrue(os.path.exists(self.outpath() +
                                       'output_skn.sword.w3x'))
        self.assertTrue(
            os.path.exists(self.outpath() + 'output_skn.soldier.w3x'))
        self.assertTrue(os.path.exists(self.outpath() +
                                       'output_skn.TRUNK.w3x'))
        self.assertTrue(
            os.path.exists(self.outpath() + 'output_skn.BOUNDINGBOX.w3x'))
        self.assertTrue(os.path.exists(self.outpath() + 'testname_skl.w3x'))
        self.assertTrue(os.path.exists(self.outpath() + 'texture.xml'))

        # check created include entries
        root = find_root(self, self.outpath() + 'output_skn.w3x')
        self.assertEqual(6, len(root.find('Includes').findall('Include')))

        # reset scene
        bpy.ops.wm.read_homefile(app_template='')

        # import
        self.filepath = self.outpath() + 'output_skn.w3x'
        load(self)

        # check created objects
        self.assertTrue('testname_skl' in bpy.data.objects)
        self.assertTrue('testname_skl' in bpy.data.armatures)
        amt = bpy.data.armatures['testname_skl']
        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)
コード例 #2
0
    def test_hierarchy_name_is_container_name_on_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)
        animation = get_animation(hierarchy_name)
        create_data(self, meshes, hlod, hierarchy, [], animation)

        # export
        self.filepath = self.outpath() + 'output'
        export_settings = {'mode': 'HAM', 'compression': 'U'}
        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))
コード例 #3
0
    def test_animation_import_no_skeleton_file(self):
        hierarchy_name = 'TestHiera_SKL'
        animation = get_animation(hierarchy_name)

        # write to file
        write_struct(animation, self.outpath() + 'animation.w3x')

        # import
        self.set_format('W3X')
        self.filepath = self.outpath() + 'animation.w3x'
        load(self)
コード例 #4
0
    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)
        boxes = [get_collision_box()]
        animation = get_animation(hierarchy_name, xml=True)

        self.filepath = self.outpath() + 'output_skn'
        create_data(self, meshes, hlod, hierarchy, boxes, animation, None)

        self.set_format('W3X')

        # export
        self.filepath = self.outpath() + 'output_skn'
        export_settings = {
            'mode': 'HM',
            'individual_files': False,
            'use_existing_skeleton': True,
            'create_texture_xmls': 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_ani'
        export_settings['mode'] = 'A'
        export_settings['compression'] = 'U'
        save_data(self, export_settings)

        # reset scene
        bpy.ops.wm.read_homefile(app_template='')

        # import
        self.filepath = self.outpath() + 'output_skn.w3x'
        load(self)
        self.filepath = self.outpath() + 'output_ani.w3x'
        load(self)

        # check created objects
        self.assertTrue(hierarchy_name in bpy.data.objects)
        self.assertTrue(hierarchy_name in bpy.data.armatures)
        amt = bpy.data.armatures[hierarchy_name]
        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)
コード例 #5
0
    def test_animation_import_no_skeleton_file_found(self):
        hierarchy_name = 'TestHiera_SKL'
        animation = get_animation(hierarchy_name)

        # write to file
        ani = open(self.outpath() + 'animation.w3d', 'wb')
        animation.write(ani)
        ani.close()

        # import
        self.filepath = self.outpath() + 'animation.w3d'
        load(self)
コード例 #6
0
    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)
        boxes = [get_collision_box()]
        dazzles = [get_dazzle()]
        animation = get_animation(hierarchy_name)

        self.filepath = self.outpath() + 'output_skn'
        create_data(self, meshes, hlod, hierarchy, boxes, animation, None,
                    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_ani'
        export_settings['mode'] = 'A'
        export_settings['compression'] = 'U'
        save_data(self, export_settings)

        # reset scene
        bpy.ops.wm.read_homefile(use_empty=True)

        # import
        self.filepath = self.outpath() + 'output_skn.w3d'
        load(self)
        self.filepath = self.outpath() + 'output_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)
コード例 #7
0
    def test_import_animation_only_no_include(self):
        hierarchy_name = 'TestHiera_SKL'
        hierarchy = get_hierarchy(hierarchy_name)
        animation = get_animation(hierarchy_name)

        # write to file
        write_struct(hierarchy, self.outpath() + hierarchy_name + '.w3x')
        write_struct(animation, self.outpath() + 'animation.w3x')

        # import
        self.set_format('W3X')
        self.filepath = self.outpath() + 'animation.w3x'
        load(self)

        self.assertTrue(hierarchy_name in bpy.data.objects)
        self.assertTrue(hierarchy_name in bpy.data.armatures)
コード例 #8
0
    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)
        boxes = [get_collision_box()]
        animation = get_animation(hierarchy_name, xml=True)

        self.set_format('W3X')
        self.filepath = self.outpath() + 'output'
        create_data(self, meshes, hlod, hierarchy, boxes, animation, None)

        # export
        self.filepath = self.outpath() + 'output'
        export_settings = {
            'mode': 'HAM',
            'compression': 'U',
            'individual_files': False,
            'create_texture_xmls': True
        }
        save_data(self, export_settings)

        # check created files
        self.assertTrue(os.path.exists(self.outpath() + 'output.w3x'))
        self.assertTrue(os.path.exists(self.outpath() + 'texture.xml'))

        # reset scene
        bpy.ops.wm.read_homefile(app_template='')

        # import
        self.filepath = self.outpath() + 'output.w3x'
        load(self)

        # check created objects
        self.assertTrue('testname' in bpy.data.objects)
        self.assertTrue('testname' in bpy.data.armatures)
        amt = bpy.data.armatures['testname']
        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)
コード例 #9
0
    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)])
コード例 #10
0
    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)
        boxes = [get_collision_box()]
        dazzles = [get_dazzle()]
        animation = get_animation(hierarchy_name)

        self.filepath = self.outpath() + 'output'
        create_data(self, meshes, hlod, hierarchy, boxes, animation, None,
                    dazzles)

        # export
        self.filepath = self.outpath() + 'output'
        export_settings = {'mode': 'HAM', 'compression': 'U'}
        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)