Compare commits

..

2 Commits

Author SHA1 Message Date
Jarrod Doyle 8aa1c7c4bc
Don't render objects marked not rendered 2024-08-25 13:21:55 +01:00
Jarrod Doyle be937d53fc
Add RenderType property support 2024-08-25 13:21:27 +01:00
3 changed files with 45 additions and 5 deletions

View File

@ -73,3 +73,23 @@ public class PropScale : Property
scale = reader.ReadVec3(); scale = reader.ReadVec3();
} }
} }
public class PropRenderType : Property
{
public enum Mode
{
Normal,
NotRendered,
Unlit,
EditorOnly,
CoronaOnly,
}
public Mode mode;
public override void Read(BinaryReader reader)
{
base.Read(reader);
mode = (Mode)reader.ReadUInt32();
}
}

View File

@ -104,6 +104,7 @@ public class DbFile
"BRLIST" => new BrList(), "BRLIST" => new BrList(),
"P$ModelName" => new PropertyChunk<PropModelName>(), "P$ModelName" => new PropertyChunk<PropModelName>(),
"P$Scale" => new PropertyChunk<PropScale>(), "P$Scale" => new PropertyChunk<PropScale>(),
"P$RenderTyp" => new PropertyChunk<PropRenderType>(),
"LD$MetaProp" => new LinkDataMetaProp(), "LD$MetaProp" => new LinkDataMetaProp(),
_ when entryName.StartsWith("L$") => new LinkChunk(), _ when entryName.StartsWith("L$") => new LinkChunk(),
_ => new GenericChunk(), _ => new GenericChunk(),

View File

@ -97,7 +97,6 @@ public partial class Mission : Node3D
{ {
ClearMap(); ClearMap();
// TODO: This shouldn't be set for things that aren't actually FMs
_textureLoader = new TextureLoader(_campaignName); _textureLoader = new TextureLoader(_campaignName);
_file = new(FileName); _file = new(FileName);
UseChunk<TxList>("TXLIST", LoadTextures); UseChunk<TxList>("TXLIST", LoadTextures);
@ -106,6 +105,7 @@ public partial class Mission : Node3D
_file.Chunks.TryGetValue("BRLIST", out var brListRaw) && _file.Chunks.TryGetValue("BRLIST", out var brListRaw) &&
_file.Chunks.TryGetValue("P$ModelName", out var modelNamesRaw) && _file.Chunks.TryGetValue("P$ModelName", out var modelNamesRaw) &&
_file.Chunks.TryGetValue("P$Scale", out var scalesRaw) && _file.Chunks.TryGetValue("P$Scale", out var scalesRaw) &&
_file.Chunks.TryGetValue("P$RenderTyp", out var renderTypesRaw) &&
_file.Chunks.TryGetValue("L$MetaProp", out var metaPropLinksRaw) && _file.Chunks.TryGetValue("L$MetaProp", out var metaPropLinksRaw) &&
_file.Chunks.TryGetValue("LD$MetaProp", out var metaPropLinkDataRaw) _file.Chunks.TryGetValue("LD$MetaProp", out var metaPropLinkDataRaw)
) )
@ -113,6 +113,7 @@ public partial class Mission : Node3D
var brList = (BrList)brListRaw; var brList = (BrList)brListRaw;
var modelNames = (PropertyChunk<PropModelName>)modelNamesRaw; var modelNames = (PropertyChunk<PropModelName>)modelNamesRaw;
var scales = (PropertyChunk<PropScale>)scalesRaw; var scales = (PropertyChunk<PropScale>)scalesRaw;
var renderTypes = (PropertyChunk<PropRenderType>)renderTypesRaw;
var metaPropLinks = (LinkChunk)metaPropLinksRaw; var metaPropLinks = (LinkChunk)metaPropLinksRaw;
var metaPropLinkData = (LinkDataMetaProp)metaPropLinkDataRaw; var metaPropLinkData = (LinkDataMetaProp)metaPropLinkDataRaw;
@ -133,19 +134,21 @@ public partial class Mission : Node3D
if (gamFile.Chunks.TryGetValue("P$ModelName", out var gamChunk1) && if (gamFile.Chunks.TryGetValue("P$ModelName", out var gamChunk1) &&
gamFile.Chunks.TryGetValue("L$MetaProp", out var gamChunk2) && gamFile.Chunks.TryGetValue("L$MetaProp", out var gamChunk2) &&
gamFile.Chunks.TryGetValue("LD$MetaProp", out var gamChunk3) && gamFile.Chunks.TryGetValue("LD$MetaProp", out var gamChunk3) &&
gamFile.Chunks.TryGetValue("P$Scale", out var gamChunk4)) gamFile.Chunks.TryGetValue("P$Scale", out var gamChunk4) &&
gamFile.Chunks.TryGetValue("P$RenderTyp", out var gamChunk5))
{ {
GD.Print($"Pre-Merged chunks: {modelNames.properties.Count} {metaPropLinks.links.Count} {metaPropLinkData.linkData.Count}"); GD.Print($"Pre-Merged chunks: {modelNames.properties.Count} {metaPropLinks.links.Count} {metaPropLinkData.linkData.Count}");
modelNames.properties.AddRange(((PropertyChunk<PropModelName>)gamChunk1).properties); modelNames.properties.AddRange(((PropertyChunk<PropModelName>)gamChunk1).properties);
metaPropLinks.links.AddRange(((LinkChunk)gamChunk2).links); metaPropLinks.links.AddRange(((LinkChunk)gamChunk2).links);
metaPropLinkData.linkData.AddRange(((LinkDataMetaProp)gamChunk3).linkData); metaPropLinkData.linkData.AddRange(((LinkDataMetaProp)gamChunk3).linkData);
scales.properties.AddRange(((PropertyChunk<PropScale>)gamChunk4).properties); scales.properties.AddRange(((PropertyChunk<PropScale>)gamChunk4).properties);
renderTypes.properties.AddRange(((PropertyChunk<PropRenderType>)gamChunk5).properties);
GD.Print($"Post-Merged chunks: {modelNames.properties.Count} {metaPropLinks.links.Count} {metaPropLinkData.linkData.Count}"); GD.Print($"Post-Merged chunks: {modelNames.properties.Count} {metaPropLinks.links.Count} {metaPropLinkData.linkData.Count}");
} }
} }
} }
PlaceObjects(brList, modelNames, scales, metaPropLinks, metaPropLinkData); PlaceObjects(brList, modelNames, scales, renderTypes, metaPropLinks, metaPropLinkData);
} }
} }
@ -165,6 +168,7 @@ public partial class Mission : Node3D
BrList brList, BrList brList,
PropertyChunk<PropModelName> modelNames, PropertyChunk<PropModelName> modelNames,
PropertyChunk<PropScale> scales, PropertyChunk<PropScale> scales,
PropertyChunk<PropRenderType> renderTypes,
LinkChunk metapropLink, LinkChunk metapropLink,
LinkDataMetaProp metaPropLinkData) LinkDataMetaProp metaPropLinkData)
{ {
@ -182,6 +186,8 @@ public partial class Mission : Node3D
var modelName = ""; var modelName = "";
var scale = Vector3.One; var scale = Vector3.One;
var scaleFound = false; var scaleFound = false;
var renderType = PropRenderType.Mode.Normal;
var renderTypeFound = false;
while (true) while (true)
{ {
// See if there's a modelname property // See if there's a modelname property
@ -210,7 +216,20 @@ public partial class Mission : Node3D
} }
} }
if (modelName != "" && scaleFound) if (!renderTypeFound)
{
foreach (var prop in renderTypes.properties)
{
if (prop.objectId == id)
{
renderType = prop.mode;
renderTypeFound = true;
break;
}
}
}
if (modelName != "" && scaleFound && renderTypeFound)
{ {
break; break;
} }
@ -234,7 +253,7 @@ public partial class Mission : Node3D
break; break;
} }
} }
if (modelName == "") if (modelName == "" || renderType == PropRenderType.Mode.NotRendered)
{ {
continue; continue;
} }