Skip to content

Commit

Permalink
Export water map resource
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDesigns committed Dec 23, 2023
1 parent 1f60e04 commit 8afe94f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 17 deletions.
49 changes: 34 additions & 15 deletions Charm/ActivityMapEntityView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ private static void ExtractDataTables(List<FileHash> dataTables, string hash, st
ExporterScene dynamicScene = Exporter.Get().CreateScene($"{hash}_Entities", ExportType.MapResource);
ExporterScene skyScene = Exporter.Get().CreateScene($"{hash}_SkyEnts", ExportType.MapResource);
ExporterScene terrainScene = Exporter.Get().CreateScene($"{hash}_Terrain", ExportType.MapResource);
ExporterScene waterScene = Exporter.Get().CreateScene($"{hash}_Water", ExportType.MapResource); //Idk what to name this besides water

Parallel.ForEach(dataTables, data =>
{
Expand Down Expand Up @@ -406,7 +407,7 @@ private static void ExtractDataTables(List<FileHash> dataTables, string hash, st
case SMapLightResource mapLight:
dynamicScene.AddMapLight(mapLight);
break;
case SMapSpotLightResource spotLight:
case SMapShadowingLightResource spotLight:
if (spotLight.Unk10 is not null)
dynamicScene.AddMapSpotLight(entry, spotLight);
break;
Expand All @@ -429,6 +430,17 @@ private static void ExtractDataTables(List<FileHash> dataTables, string hash, st
case SMapTerrainResource terrain:
terrain.Terrain.LoadIntoExporter(terrainScene, savePath);
break;
case SMapWaterDecal water:
waterScene.AddMapModel(water.Model,
entry.Translation,
entry.Rotation,
new Tiger.Schema.Vector3(entry.Translation.W));
foreach (DynamicMeshPart part in water.Model.Load(ExportDetailLevel.MostDetailed, null))
{
if (part.Material == null) continue;
waterScene.Materials.Add(new ExportMaterial(part.Material, MaterialType.Transparent));
}
break;
default:
break;
}
Expand All @@ -452,23 +464,30 @@ private static void ExportIndividual(List<FileHash> dataTables, string hash, str
SBoxHandler.SaveEntityVMDL($"{savePath}/Entities", entity);
}
if (entry.DataResource.GetValue(dataTable.GetReader()) is SMapSkyEntResource skyResource)
switch(entry.DataResource.GetValue(dataTable.GetReader()))
{
foreach (var element in skyResource.Unk10.TagData.Unk08)
{
if (element.Unk60.TagData.Unk08 is null)
continue;
case SMapSkyEntResource skyResource:
foreach (var element in skyResource.Unk10.TagData.Unk08)
{
if (element.Unk60.TagData.Unk08 is null)
continue;
ExporterScene skyScene = Exporter.Get().CreateScene(element.Unk60.TagData.Unk08.Hash, ExportType.EntityInMap);
skyScene.AddModel(element.Unk60.TagData.Unk08);
ExporterScene skyScene = Exporter.Get().CreateScene(element.Unk60.TagData.Unk08.Hash, ExportType.EntityInMap);
skyScene.AddModel(element.Unk60.TagData.Unk08);
SBoxHandler.SaveEntityVMDL($"{savePath}/Entities", element.Unk60.TagData.Unk08.Hash, element.Unk60.TagData.Unk08.Load(ExportDetailLevel.MostDetailed, null));
}
}
if (entry.DataResource.GetValue(dataTable.GetReader()) is SMapTerrainResource terrainArrangement)
{
ExporterScene staticScene = Exporter.Get().CreateScene($"{terrainArrangement.Terrain.Hash}_Terrain", ExportType.StaticInMap);
terrainArrangement.Terrain.LoadIntoExporter(staticScene, savePath, true);
SBoxHandler.SaveEntityVMDL($"{savePath}/Entities", element.Unk60.TagData.Unk08.Hash, element.Unk60.TagData.Unk08.Load(ExportDetailLevel.MostDetailed, null));
}
break;
case SMapTerrainResource terrainArrangement:
ExporterScene staticScene = Exporter.Get().CreateScene($"{terrainArrangement.Terrain.Hash}_Terrain", ExportType.StaticInMap);
terrainArrangement.Terrain.LoadIntoExporter(staticScene, savePath, true);
break;
case SMapWaterDecal water:
ExporterScene waterScene = Exporter.Get().CreateScene(hash, ExportType.EntityInMap); //Idk what to name this besides water
waterScene.AddModel(water.Model);
SBoxHandler.SaveEntityVMDL($"{savePath}/Entities", water.Model.Hash, water.Model.Load(ExportDetailLevel.MostDetailed, null));
break;
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion Tiger/Exporters/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void AddMapLight(SMapLightResource mapLight) //Point
{
MapLights.Add(mapLight);
}
public void AddMapSpotLight(SMapDataEntry spotLightEntry, SMapSpotLightResource spotLightResource) //Spot
public void AddMapSpotLight(SMapDataEntry spotLightEntry, SMapShadowingLightResource spotLightResource) //Spot
{
if (!MapSpotLights.ContainsKey(spotLightResource.Unk10.Hash))
{
Expand Down
15 changes: 14 additions & 1 deletion Tiger/Schema/Static/StaticMapData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,11 @@ public struct D2Class_BA6C8080
public Vector4 Unk40;
}

/// <summary>
/// A light that casts shadows
/// </summary>
[SchemaStruct("5E6C8080", 0x20)]
public struct SMapSpotLightResource
public struct SMapShadowingLightResource
{
[SchemaField(0x10)]
public Tag<D2Class_716C8080> Unk10; // D2Class_716C8080, might be related to lights for entities?
Expand All @@ -559,6 +562,16 @@ public struct D2Class_716C8080
public Tag<D2Class_A16D8080> UnkEC;
}

/// <summary>
/// Usually a flat plane for screen-space reflected water
/// </summary>
[SchemaStruct(TigerStrategy.DESTINY2_WITCHQUEEN_6307, "D4688080", 0x70)]
public struct SMapWaterDecal
{
[SchemaField(0x10)]
public EntityModel Model;
}

// /// <summary>
// /// Boss entity data resource?
// /// </summary>
Expand Down
7 changes: 7 additions & 0 deletions Tiger/Schema/Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public Vector3(float x, float y, float z)
Z = z;
}

public Vector3(float x)
{
X = x;
Y = x;
Z = x;
}

public static Vector3 Zero
{
get
Expand Down

0 comments on commit 8afe94f

Please sign in to comment.