""" Two-sided twins of the Kazah Tender's materials (module of the import runner, see import_assets.py). Milestone M3. Why: the Kazah model is a single-sided shell. Seen from the pilot's eye (DESIGN_UE.md section 4.6) every hull and canopy-frame face is a back face and is culled, so the cockpit view showed no canopy frame at all. A flying Tender (AKazahTender::InitFleet) swaps each material of its body, canopy lid, canopy glass, hatch lid and cockpit interior for the twin made here. Makes, under /Game/Vehicles/Kazah/Materials, for every MI_ made by assets_10_kazah_materials.py: MI__2S an instance whose PARENT is MI_ (so colours and every later change follow it), with the base property override "two sided" switched on. Runs after assets_10 (module order is by file name). Safe to re-run: the twins are rebuilt every time (cheap). """ import unreal MAT_DIR = "/Game/Vehicles/Kazah/Materials" SUFFIX = "_2S" def run(ctx): MEL, EAL = ctx.mel, ctx.eal if not EAL.does_directory_exist(MAT_DIR): raise RuntimeError("no %s - assets_10_kazah_materials.py has to run first" % MAT_DIR) made = 0 for path in sorted(EAL.list_assets(MAT_DIR, recursive=False, include_folder=False)): name = path.split("/")[-1].split(".")[0] if not name.startswith("MI_") or name.endswith(SUFFIX): continue parent = EAL.load_asset(MAT_DIR + "/" + name) if not isinstance(parent, unreal.MaterialInstanceConstant): continue twin = ctx.get_or_create(MAT_DIR, name + SUFFIX, unreal.MaterialInstanceConstant, unreal.MaterialInstanceConstantFactoryNew()) twin.set_editor_property("parent", parent) overrides = twin.get_editor_property("base_property_overrides") overrides.set_editor_property("override_two_sided", True) overrides.set_editor_property("two_sided", True) twin.set_editor_property("base_property_overrides", overrides) MEL.update_material_instance(twin) EAL.save_loaded_asset(twin) made += 1 ctx.log("two-sided twin %s%s" % (name, SUFFIX)) if made == 0: raise RuntimeError("no MI_* instances in %s" % MAT_DIR) ctx.log("%d two-sided Kazah material twins" % made)