diff --git a/project/code/TMV/Mission.cs b/project/code/TMV/Mission.cs index 03a0ed3..ec230c5 100644 --- a/project/code/TMV/Mission.cs +++ b/project/code/TMV/Mission.cs @@ -232,6 +232,10 @@ public partial class Mission : Node3D var modelNameProp = objHierarchy.GetProperty(id, "P$ModelName"); var scaleProp = objHierarchy.GetProperty(id, "P$Scale"); var renderTypeProp = objHierarchy.GetProperty(id, "P$RenderTyp"); + var txtRepl0 = objHierarchy.GetProperty(id, "P$OTxtRepr0"); + var txtRepl1 = objHierarchy.GetProperty(id, "P$OTxtRepr1"); + var txtRepl2 = objHierarchy.GetProperty(id, "P$OTxtRepr2"); + var txtRepl3 = objHierarchy.GetProperty(id, "P$OTxtRepr3"); var renderMode = renderTypeProp == null ? PropRenderType.Mode.Normal : renderTypeProp.mode; if (modelNameProp == null || renderMode == PropRenderType.Mode.NotRendered) @@ -251,6 +255,50 @@ public partial class Mission : Node3D model.Position = pos; model.RotationDegrees = rot; model.Scale = scale; + + bool GetTextReplPath(PropString prop, out string path) + { + path = ""; + if (prop == null) + { + return false; + } + + path = prop.value; + if (path.StartsWith("fam", StringComparison.OrdinalIgnoreCase)) + { + path = _installPaths.GetTexturePath(_campaignName, path); + return path != null; + } + + // gonna assume obj lol + path = _installPaths.GetObjectTexturePath(_campaignName, path); + + return path != null; + } + + var repls = new PropString[] { txtRepl0, txtRepl1, txtRepl2, txtRepl3 }; + for (var i = 0; i < 4; i++) + { + if (GetTextReplPath(repls[i], out var path)) + { + var overrideMat = new StandardMaterial3D + { + AlbedoTexture = TextureLoader.LoadTexture(path) + }; + + var surfaceCount = model.Mesh.GetSurfaceCount(); + for (var idx = 0; idx < surfaceCount; idx++) + { + var surfaceMat = model.Mesh.SurfaceGetMaterial(idx); + if (surfaceMat.HasMeta($"TxtRepl{i}")) + { + model.SetSurfaceOverrideMaterial(idx, overrideMat); + } + } + } + } + AddChild(model); } }