Apply TxtRepl properties
This commit is contained in:
parent
ab34a78739
commit
4ab115440c
|
@ -232,6 +232,10 @@ public partial class Mission : Node3D
|
||||||
var modelNameProp = objHierarchy.GetProperty<PropModelName>(id, "P$ModelName");
|
var modelNameProp = objHierarchy.GetProperty<PropModelName>(id, "P$ModelName");
|
||||||
var scaleProp = objHierarchy.GetProperty<PropScale>(id, "P$Scale");
|
var scaleProp = objHierarchy.GetProperty<PropScale>(id, "P$Scale");
|
||||||
var renderTypeProp = objHierarchy.GetProperty<PropRenderType>(id, "P$RenderTyp");
|
var renderTypeProp = objHierarchy.GetProperty<PropRenderType>(id, "P$RenderTyp");
|
||||||
|
var txtRepl0 = objHierarchy.GetProperty<PropString>(id, "P$OTxtRepr0");
|
||||||
|
var txtRepl1 = objHierarchy.GetProperty<PropString>(id, "P$OTxtRepr1");
|
||||||
|
var txtRepl2 = objHierarchy.GetProperty<PropString>(id, "P$OTxtRepr2");
|
||||||
|
var txtRepl3 = objHierarchy.GetProperty<PropString>(id, "P$OTxtRepr3");
|
||||||
var renderMode = renderTypeProp == null ? PropRenderType.Mode.Normal : renderTypeProp.mode;
|
var renderMode = renderTypeProp == null ? PropRenderType.Mode.Normal : renderTypeProp.mode;
|
||||||
|
|
||||||
if (modelNameProp == null || renderMode == PropRenderType.Mode.NotRendered)
|
if (modelNameProp == null || renderMode == PropRenderType.Mode.NotRendered)
|
||||||
|
@ -251,6 +255,50 @@ public partial class Mission : Node3D
|
||||||
model.Position = pos;
|
model.Position = pos;
|
||||||
model.RotationDegrees = rot;
|
model.RotationDegrees = rot;
|
||||||
model.Scale = scale;
|
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);
|
AddChild(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue