def test_roundtrip_prelit(self):
        hierarchy_name = 'testhiera_skl'
        hierarchy = get_hierarchy(hierarchy_name)
        meshes = [
            get_mesh(name='sword', skin=True, prelit=True),
            get_mesh(name='soldier', skin=True),
            get_mesh(name='TRUNK', prelit=True)
        ]
        hlod = get_hlod('TestModelName', hierarchy_name)

        self.filepath = self.outpath() + 'output'
        create_data(self, meshes, hlod, hierarchy, [], None, None, [])

        # export
        self.filepath = self.outpath() + 'output'
        export_settings = {'mode': 'HM', 'use_existing_skeleton': False}
        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.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)
    def test_hierarchy_name_is_container_name_on_HM_and_not_use_existing_skeleton(
            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)
        self.filepath = self.outpath() + 'output'
        create_data(self, meshes, hlod, hierarchy)

        # export
        self.filepath = self.outpath() + 'output'
        export_settings = {
            'mode': 'HM',
            'compression': 'U',
            'use_existing_skeleton': False
        }
        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))
    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)
Exemplo n.º 4
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)
        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)
Exemplo n.º 5
0
    def test_roundtrip_prelit(self):
        hierarchy_name = "TestHiera_SKL"
        hierarchy = get_hierarchy(hierarchy_name)
        meshes = [get_mesh(name="sword", skin=True, prelit=True),
                  get_mesh(name="soldier", skin=True),
                  get_mesh(name="TRUNK", prelit=True)]
        hlod = get_hlod("TestModelName", 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)
        skn.close()

        skl = open(self.outpath() + hierarchy_name + ".w3d", "wb")
        hierarchy.write(skl)
        skl.close()

        # import
        model = ImportWrapper(self.outpath() + "base_skn.w3d")
        load(model, 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)
    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)