diff --git a/io_mesh_w3d/common/shading/vertex_material_group.py b/io_mesh_w3d/common/shading/vertex_material_group.py index b64626cf..3bf441b4 100644 --- a/io_mesh_w3d/common/shading/vertex_material_group.py +++ b/io_mesh_w3d/common/shading/vertex_material_group.py @@ -42,8 +42,8 @@ def create(node_tree, vert_mat, shader): instance.inputs['Specular'].default_value = vert_mat.vm_info.specular.to_vector_rgba() instance.inputs['Emissive'].default_value = vert_mat.vm_info.emissive.to_vector_rgba() instance.inputs['Shininess'].default_value = vert_mat.vm_info.shininess - instance.inputs['Opacity'].default_value = vert_mat.vm_info.shininess - instance.inputs['Translucency'].default_value = vert_mat.vm_info.shininess + instance.inputs['Opacity'].default_value = vert_mat.vm_info.opacity + instance.inputs['Translucency'].default_value = vert_mat.vm_info.translucency instance.inputs['DepthCompare'].default_value = str(shader.depth_compare) instance.inputs['DepthMaskWrite'].default_value = str(shader.depth_mask) diff --git a/io_mesh_w3d/common/structs/mesh_structs/texture.py b/io_mesh_w3d/common/structs/mesh_structs/texture.py index a074fcf4..b0e51749 100644 --- a/io_mesh_w3d/common/structs/mesh_structs/texture.py +++ b/io_mesh_w3d/common/structs/mesh_structs/texture.py @@ -40,7 +40,7 @@ def write(self, io_stream): class Texture: - def __init__(self, id='', file='', texture_info=None): + def __init__(self, id='', file='', texture_info=TextureInfo()): self.id = id self.file = file self.texture_info = texture_info diff --git a/io_mesh_w3d/common/utils/material_export.py b/io_mesh_w3d/common/utils/material_export.py index 32088854..0cd1c7b0 100644 --- a/io_mesh_w3d/common/utils/material_export.py +++ b/io_mesh_w3d/common/utils/material_export.py @@ -1,6 +1,8 @@ # # Written by Stephan Vedder and Michael Schnabel +import os + from mathutils import Vector from io_mesh_w3d.common.shading.vertex_material_group import * from io_mesh_w3d.common.structs.mesh_structs.texture import * @@ -38,12 +40,12 @@ def retrieve_materials(context, mesh_struct, b_mesh, mesh, used_textures): # -> only export shader materials so convert VertexMaterial to DefaultW3D if shader_node.node_tree.name == 'VertexMaterial': - vert_mat, shader, tex_name, uv_layer_name = retrieve_vertex_material(context, material, shader_node) + vert_mat, shader, tex_name, tex_path, uv_layer_name = retrieve_vertex_material(context, material, shader_node) if not tex_name in used_textures: used_textures.append(tex_name) mesh_struct.vert_materials = [vert_mat] mesh_struct.shaders = [shader] - mesh_struct.textures = [Texture(file=tex_name)] + mesh_struct.textures = [Texture(id=tex_name, file=tex_path if tex_path != '' else tex_name)] tx_stage = TextureStage( tx_ids=[[0]], @@ -118,11 +120,11 @@ def retrieve_vertex_material(context, material, shader_node): post_detail_color_func=get_value(context, node_tree, shader_node.inputs['PostDetailColorFunc'], int), post_detail_alpha_func=get_value(context, node_tree, shader_node.inputs['PostDetailAlphaFunc'], int)) - texture, uv_layer_name = get_texture_value(context, node_tree, shader_node.inputs['DiffuseTexture']) + texture, texture_path, uv_layer_name = get_texture_value(context, node_tree, shader_node.inputs['DiffuseTexture']) shader.texturing = 1 if texture is not None else 0 - return vert_mat, shader, texture, uv_layer_name + return vert_mat, shader, texture, texture_path, uv_layer_name def retrieve_shader_material(context, shader_node): @@ -134,28 +136,31 @@ def retrieve_shader_material(context, shader_node): shader_mat.header.technique_index = get_value(context, node_tree, shader_node.inputs['Technique'], int) for input_socket in shader_node.inputs: - if isinstance(input_socket, NodeSocketTexture): + if input_socket.bl_idname == 'NodeSocketTexture': prop_type = STRING_PROPERTY - value, _ = get_texture_value(context, node_tree, input_socket) + value, _, _ = get_texture_value(context, node_tree, input_socket) tex_name = value - elif isinstance(input_socket, NodeSocketTextureAlpha): + elif input_socket.bl_idname == 'NodeSocketTextureAlpha': continue - elif isinstance(input_socket, NodeSocketFloat): + elif input_socket.bl_idname == 'NodeSocketFloat': prop_type = FLOAT_PROPERTY value = get_value(context, node_tree, input_socket, float) - elif isinstance(input_socket, NodeSocketVector2): + elif input_socket.bl_idname == 'NodeSocketVector2': prop_type = VEC2_PROPERTY value = get_vec2_value(context, node_tree, input_socket) - elif isinstance(input_socket, NodeSocketVector): + elif input_socket.bl_idname == 'NodeSocketVector': prop_type = VEC3_PROPERTY value = get_vec_value(context, node_tree, input_socket) - elif isinstance(input_socket, (NodeSocketVector4, NodeSocketColor)): + elif input_socket.bl_idname == 'NodeSocketVector4': + prop_type = VEC4_PROPERTY + value = get_color_value(context, node_tree, input_socket) + elif input_socket.bl_idname == 'NodeSocketColor': prop_type = VEC4_PROPERTY value = get_color_value(context, node_tree, input_socket) - elif isinstance(input_socket, NodeSocketInt): + elif input_socket.bl_idname == 'NodeSocketInt': prop_type = LONG_PROPERTY value = get_value(context, node_tree, input_socket, int) - elif isinstance(input_socket, NodeSocketBool): + elif input_socket.bl_idname == 'NodeSocketBool': prop_type = BOOL_PROPERTY value = get_value(context, node_tree, input_socket, bool) else: @@ -205,10 +210,11 @@ def get_texture_value(context, node_tree, socket): for link in socket.links: if link.from_node.bl_idname == node_type: - return link.from_node.image.name, get_uv_layer_name(context, node_tree, link.from_node.inputs['Vector']) + image = link.from_node.image + return image.name, os.path.basename(image.filepath), get_uv_layer_name(context, node_tree, link.from_node.inputs['Vector']) context.error('Node ' + link.from_node.bl_idname + ' connected to ' + socket.name + ' in ' + node_tree.name + ' is not of type ' + type) - return None, None + return None, None, None def get_value(context, node_tree, socket, cast): diff --git a/io_mesh_w3d/w3d/structs/mesh_structs/prelit.py b/io_mesh_w3d/w3d/structs/mesh_structs/prelit.py index 41e272ae..7cc22e0a 100644 --- a/io_mesh_w3d/w3d/structs/mesh_structs/prelit.py +++ b/io_mesh_w3d/w3d/structs/mesh_structs/prelit.py @@ -61,7 +61,7 @@ def size(self, include_head=True): return size def write(self, io_stream): - write_chunk_head(self.type, io_stream, + write_chunk_head(self.prelit_type, io_stream, self.size(False), has_sub_chunks=True) self.mat_info.write(io_stream) diff --git a/tests/common/cases/structs/test_animation.py b/tests/common/cases/structs/test_animation.py index 1d895a84..6c5b3dea 100644 --- a/tests/common/cases/structs/test_animation.py +++ b/tests/common/cases/structs/test_animation.py @@ -42,30 +42,49 @@ def test_unknown_chunk_skip(self): Animation.read(self, io_stream, subchunk_end) report_func.assert_called_with('unknown chunk_type in io_stream: 0x0') - def test_validate(self): + def test_is_valid_if_w3d(self): ani = get_animation() self.file_format = 'W3D' self.assertTrue(ani.validate(self)) + + def test_is_valid_if_w3x(self): + ani = get_animation() self.file_format = 'W3X' self.assertTrue(ani.validate(self)) + def test_is_invalid_if_w3d_and_too_long_name(self): + ani = get_animation() ani.header.name = 'tooooolonganiname' self.file_format = 'W3D' self.assertFalse(ani.validate(self)) + + def test_is_valid_if_w3x_and_too_long_name(self): + ani = get_animation() + ani.header.name = 'tooooolonganiname' self.file_format = 'W3X' self.assertTrue(ani.validate(self)) + def test_is_invalid_if_w3d_and_too_long_hierarchy_name(self): ani = get_animation() - ani.header.hierarchy_name = 'tooooolonganiname' + ani.header.hierarchy_name = 'tooooolonghieraname' self.file_format = 'W3D' self.assertFalse(ani.validate(self)) + + def test_is_valid_if_w3x_and_too_long_hierarchy_name(self): + ani = get_animation() + ani.header.name = 'tooooolonghieraname' self.file_format = 'W3X' self.assertTrue(ani.validate(self)) + def test_is_invalid_if_w3d_and_no_channels(self): ani = get_animation() ani.channels = [] self.file_format = 'W3D' self.assertFalse(ani.validate(self)) + + def test_is_invalid_if_w3x_and_no_channels(self): + ani = get_animation() + ani.channels = [] self.file_format = 'W3X' self.assertFalse(ani.validate(self)) diff --git a/tests/common/cases/test_utils.py b/tests/common/cases/test_utils.py index 72cd0a49..66b55077 100644 --- a/tests/common/cases/test_utils.py +++ b/tests/common/cases/test_utils.py @@ -54,24 +54,6 @@ def test_shader_material_roundtrip(self): actual = retrieve_materials(self, material, principled) compare_shader_materials(self, mesh.shader_materials[0], actual) - # is that really a valid scenario? might only be a single shader material per mesh - def test_duplicate_shader_material_roundtrip(self): - mesh = get_mesh(shader_mat=True) - mesh.shader_materials = [get_shader_material(), get_shader_material()] - - materials = [] - for mat in mesh.shader_materials: - material = create_shader_material(self, mat, 'uv_layer') - materials.append(material) - - self.assertEqual(1, len(bpy.data.materials)) - self.assertTrue('meshName.NormalMapped.fx' in bpy.data.materials) - - for i, expected in enumerate(mesh.shader_materials): - principled = node_shader_utils.PrincipledBSDFWrapper(materials[i], is_readonly=True) - actual = retrieve_shader_material(self, materials[i], principled) - compare_shader_materials(self, expected, actual) - def test_shader_material_w3x_roundtrip(self): mesh = get_mesh(shader_mat=True) mesh.shader_materials = [get_shader_material()] @@ -80,7 +62,7 @@ def test_shader_material_w3x_roundtrip(self): for source in mesh.shader_materials: material = create_shader_material(self, source, 'uv_layer') principled = node_shader_utils.PrincipledBSDFWrapper(material, is_readonly=True) - actual = retrieve_shader_material(self, material, principled, w3x=True) + actual = retrieve_shader_material(self, material, principled) compare_shader_materials(self, source, actual) def test_shader_material_w3x_rgb_colors_roundtrip(self): @@ -99,30 +81,6 @@ def test_shader_material_w3x_rgb_colors_roundtrip(self): compare_shader_materials(self, source, actual) - def test_shader_material_type_name_fallback(self): - mesh = get_mesh(shader_mat=True) - - for source in mesh.shader_materials: - source.header.type_name = 'LoremIpsum' - source.properties = [] - - material = create_shader_material(self, source, 'uv_layer') - actual = retrieve_shader_material(self, material, principled) - source.header.type_name = 'DefaultW3D.fx' - compare_shader_materials(self, source, actual) - - # also not a valid scenario anymore? - def test_shader_material_type_name_upgrade_to_normal_mapped(self): - mesh = get_mesh(shader_mat=True) - - for source in mesh.shader_materials: - source.header.type_name = 'LoremIpsum' - - material = create_shader_material(self, source, 'uv_layer') - actual = retrieve_shader_material(self, material, principled) - source.header.type_name = 'NormalMapped.fx' - compare_shader_materials(self, source, actual) - def test_shader_roundtrip(self): mesh = get_mesh() diff --git a/tests/common/cases/utils/test_mesh_export.py b/tests/common/cases/utils/test_mesh_export.py index 5428256c..26e6907e 100644 --- a/tests/common/cases/utils/test_mesh_export.py +++ b/tests/common/cases/utils/test_mesh_export.py @@ -71,8 +71,7 @@ def test_used_texture_file_ending_is_correct(self): meshes, _ = retrieve_meshes(self, None, None, 'container_name') mesh = meshes[0] - self.assertEqual(mesh.textures[0].file, 'texture.dds') - self.assertEqual(mesh.textures[1].file, 'texture.dds') + self.assertEqual('texture.dds', mesh.textures[0].file) def test_retrieve_meshes_with_meshes_in_edit_mode(self): mesh = get_mesh() diff --git a/tests/common/cases/utils/test_mesh_import.py b/tests/common/cases/utils/test_mesh_import.py index 7fbf3ecb..964e5dad 100644 --- a/tests/common/cases/utils/test_mesh_import.py +++ b/tests/common/cases/utils/test_mesh_import.py @@ -223,14 +223,11 @@ def test_mesh_import_vertex_colors_are_imported_correctly(self): mesh = bpy.data.objects[mesh_name].data - self.assertEqual(6, len(mesh.vertex_colors)) + self.assertEqual(3, len(mesh.vertex_colors)) self.assertEqual('DCG_0', mesh.vertex_colors[0].name) self.assertEqual('DIG_0', mesh.vertex_colors[1].name) self.assertEqual('SCG_0', mesh.vertex_colors[2].name) - self.assertEqual('DCG_1', mesh.vertex_colors[3].name) - self.assertEqual('DIG_1', mesh.vertex_colors[4].name) - self.assertEqual('SCG_1', mesh.vertex_colors[5].name) def test_mesh_import_tx_stage_has_no_tx_coords(self): mesh_name = 'mesh' diff --git a/tests/common/helpers/mesh_structs/shader_material.py b/tests/common/helpers/mesh_structs/shader_material.py index 7ded9b05..9ce81865 100644 --- a/tests/common/helpers/mesh_structs/shader_material.py +++ b/tests/common/helpers/mesh_structs/shader_material.py @@ -19,7 +19,7 @@ def compare_shader_material_headers(self, expected, actual): def get_shader_material_property( - prop_type=1, name='property', tex_name='texture.dds', value=None): + prop_type=1, name='property', tex_name='texture.dds', value=None, rgb_color=False): result = ShaderMaterialProperty( prop_type=prop_type, name=name) @@ -35,7 +35,11 @@ def get_shader_material_property( elif prop_type == VEC3_PROPERTY: result.value = get_vec(x=1.0, y=0.2, z=0.33) elif prop_type == VEC4_PROPERTY: - result.value = get_vec4(x=0.33, y=0.3, z=0.1, w=1.0) + if rgb_color: + result.prop_type = VEC3_PROPERTY + result.value = get_vec(x=1.0, y=0.2, z=0.33) + else: + result.value = get_vec4(x=0.33, y=0.3, z=0.1, w=1.0) elif prop_type == LONG_PROPERTY: result.value = 3 elif prop_type == BOOL_PROPERTY: @@ -64,44 +68,40 @@ def compare_shader_material_properties(self, expected, actual): def get_shader_material_properties(name, rgb_color=False): if name == 'NormalMapped.fx': - ambient = get_shader_material_property(VEC4_PROPERTY, 'AmbientColor') - if rgb_color: - ambient = get_shader_material_property(VEC3_PROPERTY, 'AmbientColor') - return [ - get_shader_material_property(VEC4_PROPERTY, 'DiffuseColor'), + get_shader_material_property(VEC4_PROPERTY, 'DiffuseColor', rgb_color=rgb_color), get_shader_material_property(STRING_PROPERTY, 'DiffuseTexture'), get_shader_material_property(BOOL_PROPERTY, 'AlphaTestEnable', value=False), get_shader_material_property(STRING_PROPERTY, 'NormalMap', 'texture_nrm.dds'), get_shader_material_property(FLOAT_PROPERTY, 'BumpScale'), - ambient, - get_shader_material_property(VEC4_PROPERTY, 'SpecularColor'), + get_shader_material_property(VEC4_PROPERTY, 'AmbientColor', rgb_color=rgb_color), + get_shader_material_property(VEC4_PROPERTY, 'SpecularColor', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'SpecularExponent')] elif name == 'BasicW3D.fx': return [ - get_shader_material_property(VEC4_PROPERTY, 'ColorDiffuse'), + get_shader_material_property(VEC4_PROPERTY, 'ColorDiffuse', rgb_color=rgb_color), get_shader_material_property(STRING_PROPERTY, 'Texture_0'), get_shader_material_property(STRING_PROPERTY, 'Texture_1', 'texture_1.dds'), get_shader_material_property(BOOL_PROPERTY, 'AlphaTestEnable', value=False), - get_shader_material_property(VEC4_PROPERTY, 'ColorAmbient'), - get_shader_material_property(VEC4_PROPERTY, 'ColorSpecular'), + get_shader_material_property(VEC4_PROPERTY, 'ColorAmbient', rgb_color=rgb_color), + get_shader_material_property(VEC4_PROPERTY, 'ColorSpecular', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'Shininess'), - get_shader_material_property(VEC4_PROPERTY, 'ColorEmissive'), + get_shader_material_property(VEC4_PROPERTY, 'ColorEmissive', rgb_color=rgb_color), get_shader_material_property(BOOL_PROPERTY, 'DepthWriteEnable'), get_shader_material_property(BOOL_PROPERTY, 'CullingEnable'), get_shader_material_property(LONG_PROPERTY, 'BlendMode')] elif name == 'DefaultW3D.fx': return [ - get_shader_material_property(VEC4_PROPERTY, 'ColorDiffuse'), + get_shader_material_property(VEC4_PROPERTY, 'ColorDiffuse', rgb_color=rgb_color), get_shader_material_property(STRING_PROPERTY, 'Texture_0'), get_shader_material_property(STRING_PROPERTY, 'Texture_1', 'texture_1.dds'), get_shader_material_property(BOOL_PROPERTY, 'AlphaTestEnable', value=False), - get_shader_material_property(VEC4_PROPERTY, 'ColorAmbient'), - get_shader_material_property(VEC4_PROPERTY, 'ColorSpecular'), + get_shader_material_property(VEC4_PROPERTY, 'ColorAmbient', rgb_color=rgb_color), + get_shader_material_property(VEC4_PROPERTY, 'ColorSpecular', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'Shininess'), - get_shader_material_property(VEC4_PROPERTY, 'ColorEmissive'), + get_shader_material_property(VEC4_PROPERTY, 'ColorEmissive', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'Opacity'), get_shader_material_property(LONG_PROPERTY, 'NumTextures'), get_shader_material_property(BOOL_PROPERTY, 'DepthWriteEnable'), @@ -121,15 +121,15 @@ def get_shader_material_properties(name, rgb_color=False): elif name == 'Infantry.fx': return [ - get_shader_material_property(VEC4_PROPERTY, 'ColorDiffuse'), + get_shader_material_property(VEC4_PROPERTY, 'ColorDiffuse', rgb_color=rgb_color), get_shader_material_property(STRING_PROPERTY, 'Texture_0'), get_shader_material_property(STRING_PROPERTY, 'Texture_1', 'texture_1.dds'), get_shader_material_property(BOOL_PROPERTY, 'AlphaTestEnable', value=False), get_shader_material_property(STRING_PROPERTY, 'RecolorTexture', 'texture_rec.dds'), - get_shader_material_property(VEC4_PROPERTY, 'ColorAmbient'), - get_shader_material_property(VEC4_PROPERTY, 'ColorSpecular'), + get_shader_material_property(VEC4_PROPERTY, 'ColorAmbient', rgb_color=rgb_color), + get_shader_material_property(VEC4_PROPERTY, 'ColorSpecular', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'Shininess'), - get_shader_material_property(VEC4_PROPERTY, 'ColorEmissive'), + get_shader_material_property(VEC4_PROPERTY, 'ColorEmissive', rgb_color=rgb_color), get_shader_material_property(BOOL_PROPERTY, 'DepthWriteEnable'), get_shader_material_property(BOOL_PROPERTY, 'CullingEnable'), get_shader_material_property(LONG_PROPERTY, 'BlendMode')] @@ -137,7 +137,7 @@ def get_shader_material_properties(name, rgb_color=False): elif name == 'MuzzleFlash.fx': return [ get_shader_material_property(STRING_PROPERTY, 'Texture_0'), - get_shader_material_property(VEC4_PROPERTY, 'ColorEmissive'), + get_shader_material_property(VEC4_PROPERTY, 'ColorEmissive', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'TexCoordTransformAngle_0'), get_shader_material_property(FLOAT_PROPERTY, 'TexCoordTransformU_0'), get_shader_material_property(FLOAT_PROPERTY, 'TexCoordTransformV_0'), @@ -148,13 +148,13 @@ def get_shader_material_properties(name, rgb_color=False): elif name == 'ObjectsGDI.fx': return [ - get_shader_material_property(VEC4_PROPERTY, 'DiffuseColor'), + get_shader_material_property(VEC4_PROPERTY, 'DiffuseColor', rgb_color=rgb_color), get_shader_material_property(STRING_PROPERTY, 'DiffuseTexture'), get_shader_material_property(BOOL_PROPERTY, 'AlphaTestEnable', value=False), get_shader_material_property(STRING_PROPERTY, 'NormalMap', 'texture_nrm.dds'), get_shader_material_property(FLOAT_PROPERTY, 'BumpScale'), - get_shader_material_property(VEC4_PROPERTY, 'AmbientColor'), - get_shader_material_property(VEC4_PROPERTY, 'SpecularColor'), + get_shader_material_property(VEC4_PROPERTY, 'AmbientColor', rgb_color=rgb_color), + get_shader_material_property(VEC4_PROPERTY, 'SpecularColor', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'SpecularExponent'), get_shader_material_property(STRING_PROPERTY, 'SpecMap', 'texture_spec.dds'), get_shader_material_property(STRING_PROPERTY, 'RecolorTexture', 'texture_rec.dds'), @@ -162,13 +162,13 @@ def get_shader_material_properties(name, rgb_color=False): elif name == 'ObjectsAlien.fx': return [ - get_shader_material_property(VEC4_PROPERTY, 'DiffuseColor'), + get_shader_material_property(VEC4_PROPERTY, 'DiffuseColor', rgb_color=rgb_color), get_shader_material_property(STRING_PROPERTY, 'DiffuseTexture'), get_shader_material_property(BOOL_PROPERTY, 'AlphaTestEnable', value=False), get_shader_material_property(STRING_PROPERTY, 'NormalMap', 'texture_nrm.dds'), get_shader_material_property(FLOAT_PROPERTY, 'BumpScale'), - get_shader_material_property(VEC4_PROPERTY, 'AmbientColor'), - get_shader_material_property(VEC4_PROPERTY, 'SpecularColor'), + get_shader_material_property(VEC4_PROPERTY, 'AmbientColor', rgb_color=rgb_color), + get_shader_material_property(VEC4_PROPERTY, 'SpecularColor', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'SpecularExponent'), get_shader_material_property(STRING_PROPERTY, 'SpecMap', 'texture_spec.dds'), get_shader_material_property(STRING_PROPERTY, 'RecolorTexture', 'texture_rec.dds'), @@ -177,13 +177,13 @@ def get_shader_material_properties(name, rgb_color=False): elif name == 'ObjectsNOD.fx': return [ - get_shader_material_property(VEC4_PROPERTY, 'DiffuseColor'), + get_shader_material_property(VEC4_PROPERTY, 'DiffuseColor', rgb_color=rgb_color), get_shader_material_property(STRING_PROPERTY, 'DiffuseTexture'), get_shader_material_property(BOOL_PROPERTY, 'AlphaTestEnable', value=False), get_shader_material_property(STRING_PROPERTY, 'NormalMap', 'texture_nrm.dds'), get_shader_material_property(FLOAT_PROPERTY, 'BumpScale'), - get_shader_material_property(VEC4_PROPERTY, 'AmbientColor'), - get_shader_material_property(VEC4_PROPERTY, 'SpecularColor'), + get_shader_material_property(VEC4_PROPERTY, 'AmbientColor', rgb_color=rgb_color), + get_shader_material_property(VEC4_PROPERTY, 'SpecularColor', rgb_color=rgb_color), get_shader_material_property(FLOAT_PROPERTY, 'SpecularExponent'), get_shader_material_property(STRING_PROPERTY, 'SpecMap', 'texture_spec.dds'), get_shader_material_property(STRING_PROPERTY, 'ScrollingMaskTexture', 'texture_scroll.dds'), diff --git a/tests/w3d/cases/test_roundtrip.py b/tests/w3d/cases/test_roundtrip.py index a25a50d8..39ddb423 100644 --- a/tests/w3d/cases/test_roundtrip.py +++ b/tests/w3d/cases/test_roundtrip.py @@ -47,7 +47,7 @@ def test_roundtrip(self): save_data(self, export_settings) # reset scene - bpy.ops.wm.read_homefile(use_empty=True) + self.reset_scene() # import self.filepath = self.outpath() + 'output_skn.w3d' @@ -96,7 +96,7 @@ def test_roundtrip_compressed_animation(self): save_data(self, export_settings) # reset scene - bpy.ops.wm.read_homefile(app_template='') + self.reset_scene() # import self.filepath = self.outpath() + 'output_skn.w3d' @@ -132,7 +132,7 @@ def test_hierarchy_name_is_container_name_on_HAM(self): save_data(self, export_settings) # reset scene - bpy.ops.wm.read_homefile(app_template='') + self.reset_scene() # import self.filepath = self.outpath() + 'output.w3d' @@ -162,7 +162,7 @@ def test_hierarchy_name_is_container_name_on_HM_and_not_use_existing_skeleton(se save_data(self, export_settings) # reset scene - bpy.ops.wm.read_homefile(app_template='') + self.reset_scene() # import self.filepath = self.outpath() + 'output.w3d' @@ -194,7 +194,7 @@ def test_roundtrip_HAM(self): save_data(self, export_settings) # reset scene - bpy.ops.wm.read_homefile(app_template='') + self.reset_scene() # import self.filepath = self.outpath() + 'output.w3d' @@ -231,7 +231,7 @@ def test_roundtrip_HAM_tc_animation(self): save_data(self, export_settings) # reset scene - bpy.ops.wm.read_homefile(app_template='') + self.reset_scene() # import self.filepath = self.outpath() + 'output.w3d' @@ -264,7 +264,7 @@ def test_roundtrip_prelit(self): save_data(self, export_settings) # reset scene - bpy.ops.wm.read_homefile(app_template='') + self.reset_scene() # import self.filepath = self.outpath() + 'output.w3d' diff --git a/tests/w3d/helpers/mesh_structs/prelit.py b/tests/w3d/helpers/mesh_structs/prelit.py index 8972ba36..5689451d 100644 --- a/tests/w3d/helpers/mesh_structs/prelit.py +++ b/tests/w3d/helpers/mesh_structs/prelit.py @@ -25,13 +25,13 @@ def get_prelit(prelit_type=W3D_CHUNK_PRELIT_UNLIT, count=1): texture_count=count) vm_name = 'INVALID_TYPE' - if type == W3D_CHUNK_PRELIT_UNLIT: + if prelit_type == W3D_CHUNK_PRELIT_UNLIT: vm_name = 'W3D_CHUNK_PRELIT_UNLIT' - elif type == W3D_CHUNK_PRELIT_VERTEX: + elif prelit_type == W3D_CHUNK_PRELIT_VERTEX: vm_name = 'W3D_CHUNK_PRELIT_VERTEX' - elif type == W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_PASS: + elif prelit_type == W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_PASS: vm_name = 'W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_PASS' - elif type == W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_TEXTURE: + elif prelit_type == W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_TEXTURE: vm_name = 'W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_TEXTURE' for i in range(count): diff --git a/tests/w3x/cases/test_roundtrip.py b/tests/w3x/cases/test_roundtrip.py index bbf39243..38fa3a13 100644 --- a/tests/w3x/cases/test_roundtrip.py +++ b/tests/w3x/cases/test_roundtrip.py @@ -110,7 +110,7 @@ def test_roundtrip_HAM(self): def test_roundtrip_texture_name_with_dots(self): hierarchy_name = 'testname_skl' hierarchy = get_hierarchy(hierarchy_name) - mesh = get_mesh(name='sword', skin=True, shader_mats=True) + mesh = get_mesh(name='sword', skin=True, shader_mat=True) mesh.textures = [get_texture(name='tex.with.dots.in.name.dds')] meshes = [mesh] hlod = get_hlod(hierarchy_name, hierarchy_name)