From 7e1adb2023a5922a4a3d98968255741b1f0a4459 Mon Sep 17 00:00:00 2001 From: Steven Garcia Date: Fri, 11 Oct 2024 23:09:56 -0500 Subject: [PATCH] Fix circular reference and disable autosmooth after import fixup --- io_scene_halo/file_qua/__init__.py | 1 + .../build_scene/generate_h1_scenario.py | 33 +- .../build_scene/generate_h2_scenario.py | 69 +-- .../h1/file_scenario/upgrade_scenario.py | 5 +- .../file_shader_environment/upgrade_shader.py | 13 +- .../h1/file_shader_model/upgrade_shader.py | 13 +- .../file_tag/h2/file_bitmap/build_asset.py | 2 +- .../file_tag/h2/file_bitmap/format.py | 7 +- .../file_tag/h2/file_bitmap/process_file.py | 2 +- .../file_scenario/mesh_helper/build_mesh.py | 2 +- .../global_functions/global_functions.py | 5 +- io_scene_halo/global_functions/parse_tags.py | 397 ++++++++++++++++++ .../shader_generation/shader_environment.py | 17 +- .../shader_generation/shader_model.py | 11 +- .../global_functions/shader_processing.py | 43 +- io_scene_halo/global_functions/tag_format.py | 368 ---------------- io_scene_halo/misc/import_fixup.py | 5 + io_scene_halo/misc/lightmap_baking.py | 11 +- 18 files changed, 525 insertions(+), 479 deletions(-) create mode 100644 io_scene_halo/global_functions/parse_tags.py diff --git a/io_scene_halo/file_qua/__init__.py b/io_scene_halo/file_qua/__init__.py index 9b842f727..d06fc6d23 100644 --- a/io_scene_halo/file_qua/__init__.py +++ b/io_scene_halo/file_qua/__init__.py @@ -34,6 +34,7 @@ PointerProperty, IntProperty ) + from bpy.types import ( Panel, Operator, diff --git a/io_scene_halo/file_tag/build_scene/generate_h1_scenario.py b/io_scene_halo/file_tag/build_scene/generate_h1_scenario.py index 8548d0c0b..711da773f 100644 --- a/io_scene_halo/file_tag/build_scene/generate_h1_scenario.py +++ b/io_scene_halo/file_tag/build_scene/generate_h1_scenario.py @@ -34,6 +34,7 @@ from mathutils import Euler, Matrix from . import build_bsp as build_scene_level from ...global_functions import global_functions +from ...global_functions.parse_tags import parse_tag from ..h1.file_scenario.mesh_helper.build_mesh import get_object from ..h1.file_scenario.format import DataTypesEnum, ObjectFlags, UnitFlags, VehicleFlags @@ -44,7 +45,7 @@ def generate_skies(context, level_root, tag_block, report): context.scene.collection.children.link(asset_collection) for element_idx, element in enumerate(tag_block): - ASSET = element.parse_tag(report, "halo1", "retail") + ASSET = parse_tag(element, report, "halo1", "retail") if not ASSET == None: for light_idx, light in enumerate(ASSET.lights): tag_name = os.path.basename(element.name) @@ -203,42 +204,42 @@ def generate_object_elements(level_root, collection_name, palette, tag_block, co for palette_idx, palette_element in enumerate(palette): ob = None object_name = "temp_%s_%s" % (os.path.basename(palette_element.name), palette_idx) - ASSET = palette_element.parse_tag(report, "halo1", "retail") + ASSET = parse_tag(palette_element, report, "halo1", "retail") if not ASSET == None: if collection_name == "Scenery": - MODEL = ASSET.scenery_body.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.scenery_body.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif collection_name == "Biped": - MODEL = ASSET.biped_body.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.biped_body.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif collection_name == "Vehicle": - MODEL = ASSET.vehicle_body.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.vehicle_body.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif collection_name == "Equipment": - MODEL = ASSET.equipment_body.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.equipment_body.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif collection_name == "Weapons": - MODEL = ASSET.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif collection_name == "Machines": - MODEL = ASSET.machine_body.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.machine_body.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif collection_name == "Controls": - MODEL = ASSET.control_body.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.control_body.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif collection_name == "Light Fixtures": - MODEL = ASSET.light_fixture.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.light_fixture.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif collection_name == "Sound Scenery": - MODEL = ASSET.sound_scenery_body.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ASSET.sound_scenery_body.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) @@ -293,17 +294,17 @@ def generate_netgame_equipment_elements(level_root, tag_block, context, game_ver for element_idx, element in enumerate(tag_block): ob = None object_name = "%s_%s" % (os.path.basename(element.item_collection.name), element_idx) - ASSET = element.item_collection.parse_tag(report, "halo1", "retail") + ASSET = parse_tag(element.item_collection, report, "halo1", "retail") if not ASSET == None: if len(ASSET.item_permutations) > 0: item_perutation_element = ASSET.item_permutations[0] - ITEM = item_perutation_element.item.parse_tag(report, "halo1", "retail") + ITEM = parse_tag(item_perutation_element.item, report, "halo1", "retail") if item_perutation_element.item.tag_group == "eqip": - MODEL = ITEM.equipment_body.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ITEM.equipment_body.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) elif item_perutation_element.item.tag_group == "weap": - MODEL = ITEM.model.parse_tag(report, "halo1", "retail") + MODEL = parse_tag(ITEM.model, report, "halo1", "retail") if not MODEL == None: ob = get_object(asset_collection, MODEL, game_version, object_name, random_color_gen, report) @@ -424,7 +425,7 @@ def generate_scenario_scene(context, H1_ASSET, game_version, game_title, file_ve context.scene.collection.children.link(levels_collection) for bsp_idx, bsp in enumerate(H1_ASSET.structure_bsps): - ASSET = bsp.parse_tag(report, "halo1", "retail") + ASSET = parse_tag(bsp, report, "halo1", "retail") if not ASSET == None: level_collection = bpy.data.collections.get("%s_%s" % (os.path.basename(bsp.name), bsp_idx)) if level_collection == None: diff --git a/io_scene_halo/file_tag/build_scene/generate_h2_scenario.py b/io_scene_halo/file_tag/build_scene/generate_h2_scenario.py index 30d601c4a..eb43adae5 100644 --- a/io_scene_halo/file_tag/build_scene/generate_h2_scenario.py +++ b/io_scene_halo/file_tag/build_scene/generate_h2_scenario.py @@ -33,6 +33,7 @@ from mathutils import Euler, Matrix from . import build_bsp as build_scene_level from ...global_functions import global_functions +from ...global_functions.parse_tags import parse_tag from ..h2.file_scenario.format import DataTypesEnum, ObjectFlags, ClassificationEnum from . import build_lightmap as build_scene_lightmap from ..h2.file_scenario.mesh_helper.build_mesh import get_object @@ -44,7 +45,7 @@ def generate_skies(context, level_root, tag_block, report): context.scene.collection.children.link(asset_collection) for element_idx, element in enumerate(tag_block): - ASSET = element.parse_tag(report, "halo2", "retail") + ASSET = parse_tag(element, report, "halo2", "retail") if not ASSET == None: for light_idx, light in enumerate(ASSET.lights): radiosity_color = (1.0, 1.0, 1.0) @@ -164,66 +165,66 @@ def generate_object_elements(level_root, collection_name, palette, tag_block, co for palette_idx, palette_element in enumerate(palette): ob = None object_name = "temp_%s_%s" % (os.path.basename(palette_element.name), palette_idx) - ASSET = palette_element.parse_tag(report, "halo2", "retail") + ASSET = parse_tag(palette_element, report, "halo2", "retail") if not ASSET == None: if collection_name == "Scenery": - MODEL = ASSET.scenery_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.scenery_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Biped": - MODEL = ASSET.biped_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.biped_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Vehicle": - MODEL = ASSET.vehicle_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.vehicle_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Equipment": - MODEL = ASSET.equipment_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.equipment_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Weapons": - MODEL = ASSET.weapon_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.weapon_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Machines": - MODEL = ASSET.machine_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.machine_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Controls": - MODEL = ASSET.control_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.control_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Light Fixtures": - MODEL = ASSET.light_fixture.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.light_fixture.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Sound Scenery": - MODEL = ASSET.sound_scenery_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.sound_scenery_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif collection_name == "Crates": - MODEL = ASSET.crate_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ASSET.crate_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) @@ -285,33 +286,33 @@ def generate_netgame_equipment_elements(level_root, tag_block, context, game_ver else: object_name = "%s_%s" % (os.path.basename(element.item_vehicle_collection.name), element_idx) - COLLECTION = element.item_vehicle_collection.parse_tag(report, "halo2", "retail") + COLLECTION = parse_tag(element.item_vehicle_collection, report, "halo2", "retail") if not COLLECTION == None: if len(COLLECTION.permutations) > 0: perutation_element = COLLECTION.permutations[0] if element.item_vehicle_collection.tag_group == "itmc": perutation_element = COLLECTION.permutations[0] - ITEM = perutation_element.item.parse_tag(report, "halo2", "retail") + ITEM = parse_tag(perutation_element.item, report, "halo2", "retail") if not ITEM == None: if perutation_element.item.tag_group == "eqip": - MODEL = ITEM.equipment_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ITEM.equipment_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif perutation_element.item.tag_group == "weap": - MODEL = ITEM.weapon_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(ITEM.weapon_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) elif element.item_vehicle_collection.tag_group == "vehc": - VEHICLE = perutation_element.item.parse_tag(report, "halo2", "retail") + VEHICLE = parse_tag(perutation_element.item, report, "halo2", "retail") if not VEHICLE == None: - MODEL = VEHICLE.vehicle_body.model.parse_tag(report, "halo2", "retail") + MODEL = parse_tag(VEHICLE.vehicle_body.model, report, "halo2", "retail") if not MODEL == None: - RENDER = MODEL.model_body.render_model.parse_tag(report, "halo2", "retail") + RENDER = parse_tag(MODEL.model_body.render_model, report, "halo2", "retail") if not RENDER == None: ob = get_object(asset_collection, RENDER, game_version, object_name, random_color_gen, report) @@ -445,8 +446,8 @@ def generate_scenario_scene(context, H2_ASSET, game_version, game_title, file_ve for bsp_idx, bsp_element in enumerate(H2_ASSET.structure_bsps): bsp = bsp_element.structure_bsp lightmap = bsp_element.structure_lightmap - SBSP_ASSET = bsp.parse_tag(report, "halo2", "retail") - LTMP_ASSET = lightmap.parse_tag(report, "halo2", "retail") + SBSP_ASSET = parse_tag(bsp, report, "halo2", "retail") + LTMP_ASSET = parse_tag(lightmap, report, "halo2", "retail") bsp_name = os.path.basename(bsp.name) collection_name = "%s_%s" % (bsp_name, bsp_idx) @@ -493,7 +494,7 @@ def generate_scenario_scene(context, H2_ASSET, game_version, game_title, file_ve scenery_palette = H2_ASSET.scenery_palette scenery = H2_ASSET.scenery if scenery_resource: - SCENERY_RESOURCE_ASSET = scenery_resource.parse_tag(report, "halo2", "retail") + SCENERY_RESOURCE_ASSET = parse_tag(scenery_resource, report, "halo2", "retail") if not SCENERY_RESOURCE_ASSET == None: scenery_palette = SCENERY_RESOURCE_ASSET.scenery_palette scenery = SCENERY_RESOURCE_ASSET.scenery diff --git a/io_scene_halo/file_tag/h1/file_scenario/upgrade_scenario.py b/io_scene_halo/file_tag/h1/file_scenario/upgrade_scenario.py index 70162a549..73ae0a879 100644 --- a/io_scene_halo/file_tag/h1/file_scenario/upgrade_scenario.py +++ b/io_scene_halo/file_tag/h1/file_scenario/upgrade_scenario.py @@ -32,6 +32,7 @@ from .... import config from math import radians +from ....global_functions.parse_tags import parse_tag from ....global_functions import tag_format, global_functions from ....file_tag.h2.file_scenario.process_file import process_file as process_h2_scenario from .format import ( @@ -1012,7 +1013,7 @@ def generate_h2_squads(H1_ASSET, TAG, SCENARIO, report): character_tag_paths.append(weapon_tag_path) for actor in actors_palette_tag_block: - actor_tag = actor.parse_tag(report, "halo1", "retail") + actor_tag = parse_tag(actor, report, "halo1", "retail") if not actor_tag == None: actor_weapon_tag = actor_tag.actor_variant_body.weapon actor_weapon_name = actor_weapon_tag.name @@ -2075,7 +2076,7 @@ def merge_encounters(base_encounters, donor_encounters, base_palette, donor_pale def merge_child_scenarios(TAG, SCENARIO, report): for child_scenario_element in SCENARIO.child_scenarios: - CHILD = child_scenario_element.parse_tag(report, "halo1", "retail") + CHILD = parse_tag(child_scenario_element, report, "halo1", "retail") merge_by_name(SCENARIO.skies, CHILD.skies) merge_by_name(SCENARIO.object_names, CHILD.object_names, 2) diff --git a/io_scene_halo/file_tag/h1/file_shader_environment/upgrade_shader.py b/io_scene_halo/file_tag/h1/file_shader_environment/upgrade_shader.py index d02539bed..17fae203d 100644 --- a/io_scene_halo/file_tag/h1/file_shader_environment/upgrade_shader.py +++ b/io_scene_halo/file_tag/h1/file_shader_environment/upgrade_shader.py @@ -27,6 +27,7 @@ import os import copy +from ....global_functions.parse_tags import parse_tag from ....global_functions import tag_format, shader_processing from .format import ( ShaderAsset as H1ShaderAsset, @@ -63,10 +64,10 @@ def generate_base_map_parameters(H1_ASSET, TAG, SHADER, template, permutation_in return TAG.TagBlock(parameter_count) def generate_detail_map_parameters(H1_ASSET, TAG, SHADER, template, permutation_index): - base_bitmap = H1_ASSET.shader_body.base_map.parse_tag(print, "halo1", "retail") - primary_detail_bitmap = H1_ASSET.shader_body.primary_detail_map.parse_tag(print, "halo1", "retail") - secondary_detail_bitmap = H1_ASSET.shader_body.secondary_detail_map.parse_tag(print, "halo1", "retail") - micro_detail_bitmap = H1_ASSET.shader_body.micro_detail_map.parse_tag(print, "halo1", "retail") + base_bitmap = parse_tag(H1_ASSET.shader_body.base_map, print, "halo1", "retail") + primary_detail_bitmap = parse_tag(H1_ASSET.shader_body.primary_detail_map, print, "halo1", "retail") + secondary_detail_bitmap = parse_tag(H1_ASSET.shader_body.secondary_detail_map, print, "halo1", "retail") + micro_detail_bitmap = parse_tag(H1_ASSET.shader_body.micro_detail_map, print, "halo1", "retail") base_bitmap_count = 0 primary_detail_bitmap_count = 0 @@ -186,8 +187,8 @@ def generate_detail_map_parameters(H1_ASSET, TAG, SHADER, template, permutation_ SHADER.parameters.append(parameter) def generate_bump_parameters(H1_ASSET, TAG, SHADER, template, permutation_index): - base_bitmap = H1_ASSET.shader_body.base_map.parse_tag(print, "halo1", "retail") - bump_bitmap = H1_ASSET.shader_body.bump_map.parse_tag(print, "halo1", "retail") + base_bitmap = parse_tag(H1_ASSET.shader_body.base_map, print, "halo1", "retail") + bump_bitmap = parse_tag(H1_ASSET.shader_body.bump_map, print, "halo1", "retail") base_bitmap_count = 0 bump_bitmap_count = 0 diff --git a/io_scene_halo/file_tag/h1/file_shader_model/upgrade_shader.py b/io_scene_halo/file_tag/h1/file_shader_model/upgrade_shader.py index f95d5a3a4..e473da90f 100644 --- a/io_scene_halo/file_tag/h1/file_shader_model/upgrade_shader.py +++ b/io_scene_halo/file_tag/h1/file_shader_model/upgrade_shader.py @@ -27,6 +27,7 @@ import os import copy +from ....global_functions.parse_tags import parse_tag from ....global_functions import tag_format, shader_processing from .format import ( ShaderAsset as H1ShaderAsset, @@ -60,10 +61,10 @@ def generate_base_map_parameters(H1_ASSET, TAG, SHADER, template, permutation_in return TAG.TagBlock(parameter_count) def generate_detail_map_parameters(H1_ASSET, TAG, SHADER, template, permutation_index): - base_bitmap = H1_ASSET.shader_body.base_map.parse_tag(print, "halo1", "retail") - primary_detail_bitmap = H1_ASSET.shader_body.primary_detail_map.parse_tag(print, "halo1", "retail") - secondary_detail_bitmap = H1_ASSET.shader_body.secondary_detail_map.parse_tag(print, "halo1", "retail") - micro_detail_bitmap = H1_ASSET.shader_body.micro_detail_map.parse_tag(print, "halo1", "retail") + base_bitmap = parse_tag(H1_ASSET.shader_body.base_map, print, "halo1", "retail") + primary_detail_bitmap = parse_tag(H1_ASSET.shader_body.primary_detail_map, print, "halo1", "retail") + secondary_detail_bitmap = parse_tag(H1_ASSET.shader_body.secondary_detail_map, print, "halo1", "retail") + micro_detail_bitmap = parse_tag(H1_ASSET.shader_body.micro_detail_map, print, "halo1", "retail") base_bitmap_count = 0 primary_detail_bitmap_count = 0 @@ -183,8 +184,8 @@ def generate_detail_map_parameters(H1_ASSET, TAG, SHADER, template, permutation_ SHADER.parameters.append(parameter) def generate_bump_parameters(H1_ASSET, TAG, SHADER, template, permutation_index): - base_bitmap = H1_ASSET.shader_body.base_map.parse_tag(print, "halo1", "retail") - bump_bitmap = H1_ASSET.shader_body.bump_map.parse_tag(print, "halo1", "retail") + base_bitmap = parse_tag(H1_ASSET.shader_body.base_map, print, "halo1", "retail") + bump_bitmap = parse_tag(H1_ASSET.shader_body.bump_map, print, "halo1", "retail") base_bitmap_count = 0 bump_bitmap_count = 0 diff --git a/io_scene_halo/file_tag/h2/file_bitmap/build_asset.py b/io_scene_halo/file_tag/h2/file_bitmap/build_asset.py index 82f6b0577..fd08c3be6 100644 --- a/io_scene_halo/file_tag/h2/file_bitmap/build_asset.py +++ b/io_scene_halo/file_tag/h2/file_bitmap/build_asset.py @@ -91,7 +91,7 @@ def write_bitmaps_1(output_stream, BITMAP, TAG): output_stream.write(struct.pack(' 0: first_map, first_map_name = get_bitmap(shader.maps[0].map, texture_root) - first_map_bitmap = shader.maps[0].map.parse_tag(report, "halo1", "retail") + first_map_bitmap = parse_tag(shader.maps[0].map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -175,7 +176,7 @@ def generate_shader_transparent_chicago_extended_simple(mat, shader, report): first_map_name = "White" if len(shader._4_stage_maps) > 0: first_map, first_map_name = get_bitmap(shader._4_stage_maps[0].map, texture_root) - first_map_bitmap = shader._4_stage_maps[0].map.parse_tag(report, "halo1", "retail") + first_map_bitmap = parse_tag(shader._4_stage_maps[0].map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -199,7 +200,7 @@ def generate_shader_transparent_generic_simple(mat, shader, report): first_map_name = "White" if len(shader.maps) > 0: first_map, first_map_name = get_bitmap(shader.maps[0].map, texture_root) - first_map_bitmap = shader.maps[0].map.parse_tag(report, "halo1", "retail") + first_map_bitmap = parse_tag(shader.maps[0].map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -219,7 +220,7 @@ def generate_shader_transparent_glass_simple(mat, shader, report): texture_root = config.HALO_1_DATA_PATH diffuse_map, diffuse_map_name = get_bitmap(shader.shader_body.diffuse_map, texture_root) - diffuse_bitmap = shader.shader_body.diffuse_map.parse_tag(report, "halo1", "retail") + diffuse_bitmap = parse_tag(shader.shader_body.diffuse_map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -241,7 +242,7 @@ def generate_shader_transparent_meter_simple(mat, shader, report): texture_root = config.HALO_1_DATA_PATH meter_map, meter_map_name = get_bitmap(shader.shader_body.meter_map, texture_root) - meter_bitmap = shader.shader_body.meter_map.parse_tag(report, "halo1", "retail") + meter_bitmap = parse_tag(shader.shader_body.meter_map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -263,7 +264,7 @@ def generate_shader_transparent_plasma_simple(mat, shader, report): texture_root = config.HALO_1_DATA_PATH primary_noise_map, primary_noise_map_name = get_bitmap(shader.shader_body.primary_noise_map, texture_root) - primary_noise_bitmap = shader.shader_body.primary_noise_map.parse_tag(report, "halo1", "retail") + primary_noise_bitmap = parse_tag(shader.shader_body.primary_noise_map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -283,7 +284,7 @@ def generate_shader_transparent_water_simple(mat, shader, report): texture_root = config.HALO_1_DATA_PATH base_map, base_map_name = get_bitmap(shader.shader_body.base_map, texture_root) - base_bitmap = shader.shader_body.base_map.parse_tag(report, "halo1", "retail") + base_bitmap = parse_tag(shader.shader_body.base_map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -303,7 +304,7 @@ def generate_shader_transparent_meter(mat, shader, report): texture_root = config.HALO_1_DATA_PATH meter_map, meter_map_name = get_bitmap(shader.shader_body.meter_map, texture_root) - meter_bitmap = shader.shader_body.meter_map.parse_tag(report, "halo1", "retail") + meter_bitmap = parse_tag(shader.shader_body.meter_map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -356,13 +357,13 @@ def generate_shader_transparent_glass(mat, shader, report): specular_map, specular_map_name = get_bitmap(shader.shader_body.specular_map, texture_root) specular_detail_map, specular_detail_map_name = get_bitmap(shader.shader_body.specular_detail_map, texture_root) - background_tint_bitmap = shader.shader_body.background_tint_map.parse_tag(report, "halo1", "retail") - reflection_bitmap = shader.shader_body.reflection_map.parse_tag(report, "halo1", "retail") - bump_bitmap = shader.shader_body.bump_map.parse_tag(report, "halo1", "retail") - diffuse_bitmap = shader.shader_body.diffuse_map.parse_tag(report, "halo1", "retail") - diffuse_detail_bitmap = shader.shader_body.diffuse_detail_map.parse_tag(report, "halo1", "retail") - specular_bitmap = shader.shader_body.specular_map.parse_tag(report, "halo1", "retail") - specular_detail_bitmap = shader.shader_body.specular_detail_map.parse_tag(report, "halo1", "retail") + background_tint_bitmap = parse_tag(shader.shader_body.background_tint_map, report, "halo1", "retail") + reflection_bitmap = parse_tag(shader.shader_body.reflection_map, report, "halo1", "retail") + bump_bitmap = parse_tag(shader.shader_body.bump_map, report, "halo1", "retail") + diffuse_bitmap = parse_tag(shader.shader_body.diffuse_map, report, "halo1", "retail") + diffuse_detail_bitmap = parse_tag(shader.shader_body.diffuse_detail_map, report, "halo1", "retail") + specular_bitmap = parse_tag(shader.shader_body.specular_map, report, "halo1", "retail") + specular_detail_bitmap = parse_tag(shader.shader_body.specular_detail_map, report, "halo1", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -513,7 +514,7 @@ def generate_h1_shader(mat, tag_ref, shader_permutation_index, report): # 1 = Simple shader generation. Only the base map is generated # 2 = Full Shader generation if not config.SHADER_GEN == 0: - shader = tag_ref.parse_tag(report, "halo1", "retail") + shader = parse_tag(tag_ref, report, "halo1", "retail") if not shader == None: if shader.header.tag_group == "senv": if config.SHADER_GEN == 1: @@ -593,7 +594,7 @@ def generate_shader_simple(mat, shader, report): base_bitmap = None if base_parameter: base_map, base_map_name = get_bitmap(base_parameter.bitmap, texture_root) - base_bitmap = base_parameter.bitmap.parse_tag(report, "halo2", "retail") + base_bitmap = parse_tag(base_parameter.bitmap, report, "halo2", "retail") output_material_node = get_output_material_node(mat) output_material_node.location = Vector((0.0, 0.0)) @@ -617,7 +618,7 @@ def generate_h2_shader(mat, tag_ref, report): # 1 = Simple shader generation. Only the base map is generated # 2 = Full Shader generation if not config.SHADER_GEN == 0: - shader = tag_ref.parse_tag(report, "halo2", "retail") + shader = parse_tag(tag_ref, report, "halo2", "retail") if not shader == None: if shader.header.tag_group == "shad": if config.SHADER_GEN == 1: diff --git a/io_scene_halo/global_functions/tag_format.py b/io_scene_halo/global_functions/tag_format.py index bdc4e3162..d89fcb852 100644 --- a/io_scene_halo/global_functions/tag_format.py +++ b/io_scene_halo/global_functions/tag_format.py @@ -32,54 +32,6 @@ from math import degrees, sqrt, radians from mathutils import Vector, Quaternion, Euler -from ..file_tag.h1.file_scenario.process_file import process_file as process_h1_scenario -from ..file_tag.h1.file_scenario_structure_bsp.process_file import process_file as process_h1_structure_bsp -from ..file_tag.h1.file_actor_variant.process_file import process_file as process_actor_variant -from ..file_tag.h1.file_model.process_file import process_file as process_mode -from ..file_tag.h1.file_gbxmodel.process_file import process_file as process_mod2 -from ..file_tag.h1.file_scenery.process_file import process_file as process_h1_scenery -from ..file_tag.h1.file_biped.process_file import process_file as process_biped -from ..file_tag.h1.file_vehicle.process_file import process_file as process_vehicle -from ..file_tag.h1.file_equipment.process_file import process_file as process_equipment -from ..file_tag.h1.file_device_machine.process_file import process_file as process_machine -from ..file_tag.h1.file_device_control.process_file import process_file as process_control -from ..file_tag.h1.file_sound_scenery.process_file import process_file as process_sound_scenery -from ..file_tag.h1.file_device_light_fixture.process_file import process_file as process_light_fixture -from ..file_tag.h1.file_bitmap.process_file import process_file as process_bitmap -from ..file_tag.h1.file_weapon.process_file import process_file as process_weapon -from ..file_tag.h1.file_item_collection.process_file import process_file as process_item_collection -from ..file_tag.h1.file_sky.process_file import process_file as process_sky - -from ..file_tag.h1.file_shader_environment.process_file import process_file as process_shader_environment -from ..file_tag.h1.file_shader_model.process_file import process_file as process_shader_model -from ..file_tag.h1.file_shader_transparent_chicago.process_file import process_file as process_shader_transparent_chicago -from ..file_tag.h1.file_shader_transparent_chicago_extended.process_file import process_file as process_shader_transparent_chicago_extended -from ..file_tag.h1.file_shader_transparent_generic.process_file import process_file as process_shader_transparent_generic -from ..file_tag.h1.file_shader_transparent_glass.process_file import process_file as process_shader_transparent_glass -from ..file_tag.h1.file_shader_transparent_meter.process_file import process_file as process_shader_transparent_meter -from ..file_tag.h1.file_shader_transparent_plasma.process_file import process_file as process_shader_transparent_plasma -from ..file_tag.h1.file_shader_transparent_water.process_file import process_file as process_shader_transparent_water - -from ..file_tag.h2.file_sky.process_file import process_file as process_h2_sky -from ..file_tag.h2.file_scenario_structure_bsp.process_file import process_file as process_h2_structure_bsp -from ..file_tag.h2.file_scenario_structure_lightmap.process_file import process_file as process_h2_structure_lightmap -from ..file_tag.h2.file_bitmap.process_file import process_file as process_h2_bitmap -from ..file_tag.h2.file_shader.process_file import process_file as process_h2_shader -from ..file_tag.h2.file_model.process_file import process_file as process_h2_model -from ..file_tag.h2.file_render_model.process_file import process_file as process_h2_render -from ..file_tag.h2.file_scenery.process_file import process_file as process_h2_scenery -from ..file_tag.h2.file_crate.process_file import process_file as process_h2_crate -from ..file_tag.h2.file_biped.process_file import process_file as process_h2_biped -from ..file_tag.h2.file_vehicle.process_file import process_file as process_h2_vehicle -from ..file_tag.h2.file_equipment.process_file import process_file as process_h2_equipment -from ..file_tag.h2.file_weapon.process_file import process_file as process_h2_weapon -from ..file_tag.h2.file_machine.process_file import process_file as process_h2_machine -from ..file_tag.h2.file_control.process_file import process_file as process_h2_control -from ..file_tag.h2.file_sound_scenery.process_file import process_file as process_h2_sound_scenery -from ..file_tag.h2.file_item_collection.process_file import process_file as process_h2_item_collection -from ..file_tag.h2.file_vehicle_collection.process_file import process_file as process_h2_vehicle_collection -from ..file_tag.h2.file_scenario_scenery_resource.process_file import process_file as process_h2_scenario_scenery_resource - class XMLData: def __init__(self, xml_node=None, element_name="", enum_class=None, block_count=0, block_name=""): self.xml_node = xml_node @@ -795,326 +747,6 @@ def create_xml_node(self, xml_data): if not xml_data == None: xml_data.xml_node.appendChild(create_xml_node("tag_reference", [("name", xml_data.element_name), ("type", self.tag_group)], self.name)) - def parse_tag(self, report, game_title, game_version): - ASSET = None - if game_title == "halo1": - if self.tag_group == "actv": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.actor_variant" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_actor_variant(input_stream, report) - input_stream.close() - - elif self.tag_group == "sky ": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.sky" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_sky(input_stream, report) - input_stream.close() - - elif self.tag_group == "bitm": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.bitmap" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_bitmap(input_stream, report) - input_stream.close() - - elif self.tag_group == "scen": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.scenery" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h1_scenery(input_stream, report) - input_stream.close() - - elif self.tag_group == "bipd": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.biped" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_biped(input_stream, report) - input_stream.close() - - elif self.tag_group == "vehi": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.vehicle" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_vehicle(input_stream, report) - input_stream.close() - - elif self.tag_group == "mach": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.device_machine" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_machine(input_stream, report) - input_stream.close() - - elif self.tag_group == "ctrl": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.device_control" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_control(input_stream, report) - input_stream.close() - - elif self.tag_group == "lifi": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.device_light_fixture" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_light_fixture(input_stream, report) - input_stream.close() - - elif self.tag_group == "ssce": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.sound_scenery" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_sound_scenery(input_stream, report) - input_stream.close() - - elif self.tag_group == "eqip": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.equipment" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_equipment(input_stream, report) - input_stream.close() - - elif self.tag_group == "weap": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.weapon" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_weapon(input_stream, report) - input_stream.close() - - elif self.tag_group == "itmc": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.item_collection" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_item_collection(input_stream, report) - input_stream.close() - - elif self.tag_group == "mod2" or self.tag_group == "mode": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.gbxmodel" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_mod2(input_stream, report) - input_stream.close() - else: - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.model" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_mode(input_stream, report) - input_stream.close() - - elif self.tag_group == "sbsp": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.scenario_structure_bsp" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h1_structure_bsp(input_stream, report) - input_stream.close() - - elif self.tag_group == "senv": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_environment" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_environment(input_stream, report) - input_stream.close() - - elif self.tag_group == "soso": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_model" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_model(input_stream, report) - input_stream.close() - - elif self.tag_group == "schi": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_transparent_chicago" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_transparent_chicago(input_stream, report) - input_stream.close() - - elif self.tag_group == "scex": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_transparent_chicago_extended" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_transparent_chicago_extended(input_stream, report) - input_stream.close() - - elif self.tag_group == "sotr": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_transparent_generic" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_transparent_generic(input_stream, report) - input_stream.close() - - elif self.tag_group == "sgla": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_transparent_glass" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_transparent_glass(input_stream, report) - input_stream.close() - - elif self.tag_group == "smet": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_transparent_meter" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_transparent_meter(input_stream, report) - input_stream.close() - - elif self.tag_group == "spla": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_transparent_plasma" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_transparent_plasma(input_stream, report) - input_stream.close() - - elif self.tag_group == "swat": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.shader_transparent_water" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_shader_transparent_water(input_stream, report) - input_stream.close() - - elif self.tag_group == "scnr": - input_file = os.path.join(config.HALO_1_TAG_PATH, "%s.scenario" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h1_scenario(input_stream, report) - input_stream.close() - - elif game_title == "halo2": - if self.tag_group == "sky ": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.sky" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_sky(input_stream, report) - input_stream.close() - - elif self.tag_group == "sbsp": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.scenario_structure_bsp" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_structure_bsp(input_stream, report) - input_stream.close() - - elif self.tag_group == "ltmp": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.scenario_structure_lightmap" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_structure_lightmap(input_stream, report) - input_stream.close() - - elif self.tag_group == "bitm": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.bitmap" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_bitmap(input_stream, report) - input_stream.close() - - elif self.tag_group == "shad": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.shader" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_shader(input_stream, report) - input_stream.close() - - elif self.tag_group == "hlmt": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.model" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_model(input_stream, report) - input_stream.close() - - elif self.tag_group == "mode": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.render_model" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_render(input_stream, report) - input_stream.close() - - elif self.tag_group == "scen": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.scenery" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_scenery(input_stream, report) - input_stream.close() - - elif self.tag_group == "bloc": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.crate" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_crate(input_stream, report) - input_stream.close() - - elif self.tag_group == "bipd": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.biped" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_biped(input_stream, report) - input_stream.close() - - elif self.tag_group == "vehi": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.vehicle" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_vehicle(input_stream, report) - input_stream.close() - - elif self.tag_group == "eqip": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.equipment" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_equipment(input_stream, report) - input_stream.close() - - elif self.tag_group == "weap": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.weapon" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_weapon(input_stream, report) - input_stream.close() - - elif self.tag_group == "mach": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.device_machine" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_machine(input_stream, report) - input_stream.close() - - elif self.tag_group == "ctrl": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.device_control" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_control(input_stream, report) - input_stream.close() - - elif self.tag_group == "ssce": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.sound_scenery" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_sound_scenery(input_stream, report) - input_stream.close() - - elif self.tag_group == "itmc": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.item_collection" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_item_collection(input_stream, report) - input_stream.close() - - elif self.tag_group == "vehc": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.vehicle_collection" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_vehicle_collection(input_stream, report) - input_stream.close() - - elif self.tag_group == "*cen": - input_file = os.path.join(config.HALO_2_TAG_PATH, "%s.scenario_scenery_resource" % self.name) - if os.path.exists(input_file): - input_stream = open(input_file, 'rb') - ASSET = process_h2_scenario_scenery_resource(input_stream, report) - input_stream.close() - - return ASSET - def get_patched_tag_ref(self, upgrade_patches): if not upgrade_patches == None and self.tag_group: for patch in upgrade_patches: diff --git a/io_scene_halo/misc/import_fixup.py b/io_scene_halo/misc/import_fixup.py index 953e8f6cb..694fccc6c 100644 --- a/io_scene_halo/misc/import_fixup.py +++ b/io_scene_halo/misc/import_fixup.py @@ -103,6 +103,11 @@ def model_fixup(context, threshold): bpy.ops.mesh.customdata_custom_splitnormals_clear() bpy.ops.object.mode_set(mode = 'OBJECT') mesh_processing.deselect_objects(context) + + try: + obj.data.use_auto_smooth = False + except: + print() return {'FINISHED'} diff --git a/io_scene_halo/misc/lightmap_baking.py b/io_scene_halo/misc/lightmap_baking.py index 5b4866749..0fea7d1e4 100644 --- a/io_scene_halo/misc/lightmap_baking.py +++ b/io_scene_halo/misc/lightmap_baking.py @@ -30,6 +30,7 @@ from .. import config from mathutils import Vector from ..global_functions import tag_format +from ..global_functions.parse_tags import parse_tag from ..file_tag.h1.file_bitmap.build_asset import build_asset as build_h1_bitmap from ..file_tag.h2.file_bitmap.build_asset import build_asset as build_h2_bitmap from ..file_tag.h1.file_bitmap.format import ( @@ -72,8 +73,8 @@ def bake_clusters(context, game_title, scenario_path, image_multiplier, report, for bsp_idx, bsp_collection in enumerate(levels_collection.children): bsp_element = SCNR_ASSET.structure_bsps[bsp_idx] - BSP_ASSET = bsp_element.parse_tag(report, game_title, "retail") - BITMAP_ASSET = BSP_ASSET.level_body.lightmap_bitmaps_tag_ref.parse_tag(report, game_title, "retail") + BSP_ASSET = parse_tag(bsp_element, report, game_title, "retail") + BITMAP_ASSET = parse_tag(BSP_ASSET.level_body.lightmap_bitmaps_tag_ref, report, game_title, "retail") bitmap_path = os.path.join(config.HALO_1_TAG_PATH, "%s.bitmap" % BSP_ASSET.level_body.lightmap_bitmaps_tag_ref.name) @@ -215,9 +216,9 @@ def bake_clusters(context, game_title, scenario_path, image_multiplier, report, lightmap_name = "%s_lightmaps" % bsp_name lightmap_collection = bpy.data.collections.get(lightmap_name) if not lightmap_collection == None: - BSP_ASSET = bsp_element.structure_bsp.parse_tag(report, game_title, "retail") - LTMP_ASSET = bsp_element.structure_lightmap.parse_tag(report, game_title, "retail") - BITMAP_ASSET = LTMP_ASSET.lightmap_groups[0].bitmap_group_tag_ref.parse_tag(report, game_title, "retail") + BSP_ASSET = parse_tag(bsp_element.structure_bsp, report, game_title, "retail") + LTMP_ASSET = parse_tag(bsp_element.structure_lightmap, report, game_title, "retail") + BITMAP_ASSET = parse_tag(LTMP_ASSET.lightmap_groups[0].bitmap_group_tag_ref, report, game_title, "retail") bitmap_path = os.path.join(config.HALO_2_TAG_PATH, "%s.bitmap" % LTMP_ASSET.lightmap_groups[0].bitmap_group_tag_ref.name)