-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Marlamin/master
Early fogs WDT support, chunk list util
- Loading branch information
Showing
8 changed files
with
478 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Warcraft.NET.Attribute; | ||
using Warcraft.NET.Files.Interfaces; | ||
using Warcraft.NET.Files.WDT.Entries.BfA; | ||
|
||
namespace Warcraft.NET.Files.WDT.Chunks | ||
{ | ||
/// <summary> | ||
/// VFOG Chunk | ||
/// </summary> | ||
[AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterLegion, AutoDocChunkVersionHelper.VersionBeforeBfA)] | ||
public class VFOG : IIFFChunk, IBinarySerializable | ||
{ | ||
/// <summary> | ||
/// Holds the binary chunk signature. | ||
/// </summary> | ||
public const string Signature = "VFOG"; | ||
|
||
/// <summary> | ||
/// VFOG Entries | ||
/// </summary> | ||
public List<VFOGEntry> Entries = []; | ||
|
||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MPHD"/> class. | ||
/// </summary> | ||
public VFOG() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MPHD"/> class. | ||
/// </summary> | ||
/// <param name="inData">ExtendedData.</param> | ||
public VFOG(byte[] inData) | ||
{ | ||
LoadBinaryData(inData); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LoadBinaryData(byte[] inData) | ||
{ | ||
using (var ms = new MemoryStream(inData)) | ||
using (var br = new BinaryReader(ms)) | ||
{ | ||
var VFOGCount = br.BaseStream.Length / VFOGEntry.GetSize(); | ||
|
||
for (var i = 0; i < VFOGCount; ++i) | ||
{ | ||
Entries.Add(new VFOGEntry(br.ReadBytes(VFOGEntry.GetSize()))); | ||
} | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string GetSignature() | ||
{ | ||
return Signature; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public uint GetSize() | ||
{ | ||
return (uint)Serialize().Length; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public byte[] Serialize(long offset = 0) | ||
{ | ||
using (var ms = new MemoryStream()) | ||
using (var bw = new BinaryWriter(ms)) | ||
{ | ||
foreach (VFOGEntry entry in Entries) | ||
bw.Write(entry.Serialize()); | ||
|
||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Numerics; | ||
using Warcraft.NET.Attribute; | ||
using Warcraft.NET.Files.Interfaces; | ||
|
||
namespace Warcraft.NET.Files.WDT.Chunks.TWW | ||
{ | ||
/// <summary> | ||
/// VFEX Chunk | ||
/// </summary> | ||
[AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterDF, AutoDocChunkVersionHelper.VersionBeforeTWW)] | ||
public class VFEX : IIFFChunk, IBinarySerializable | ||
{ | ||
/// <summary> | ||
/// Holds the binary chunk signature. | ||
/// </summary> | ||
public const string Signature = "VFEX"; | ||
|
||
public uint Unknown0 { get; set; } | ||
public float[] Unknown1 { get; set; } | ||
|
||
/// <summary> | ||
/// Reference to the ID in the VFOG entry this VFEX belongs to. | ||
/// </summary> | ||
public uint VfogId { get; set; } | ||
|
||
public uint Unknown3 { get; set; } | ||
public uint Unknown4 { get; set; } | ||
public uint Unknown5 { get; set; } | ||
public uint Unknown6 { get; set; } | ||
public uint Unknown7 { get; set; } | ||
public uint Unknown8 { get; set; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="VFEX"/> class. | ||
/// </summary> | ||
public VFEX() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="VFEX"/> class. | ||
/// </summary> | ||
/// <param name="inData">ExtendedData.</param> | ||
public VFEX(byte[] inData) | ||
{ | ||
LoadBinaryData(inData); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LoadBinaryData(byte[] inData) | ||
{ | ||
using (var ms = new MemoryStream(inData)) | ||
using (var br = new BinaryReader(ms)) | ||
{ | ||
Unknown0 = br.ReadUInt32(); | ||
Unknown1 = new float[16]; | ||
for (var i = 0; i < 16; i++) | ||
{ | ||
Unknown1[i] = br.ReadSingle(); | ||
} | ||
|
||
VfogId = br.ReadUInt32(); | ||
Unknown3 = br.ReadUInt32(); | ||
Unknown4 = br.ReadUInt32(); | ||
Unknown5 = br.ReadUInt32(); | ||
Unknown6 = br.ReadUInt32(); | ||
Unknown7 = br.ReadUInt32(); | ||
Unknown8 = br.ReadUInt32(); | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string GetSignature() | ||
{ | ||
return Signature; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public uint GetSize() | ||
{ | ||
return (uint)Serialize().Length; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public byte[] Serialize(long offset = 0) | ||
{ | ||
using (var ms = new MemoryStream()) | ||
using (var bw = new BinaryWriter(ms)) | ||
{ | ||
bw.Write(Unknown0); | ||
for (var i = 0; i < 16; i++) | ||
{ | ||
bw.Write(Unknown1[i]); | ||
} | ||
bw.Write(VfogId); | ||
bw.Write(Unknown3); | ||
bw.Write(Unknown4); | ||
bw.Write(Unknown5); | ||
bw.Write(Unknown6); | ||
bw.Write(Unknown7); | ||
bw.Write(Unknown8); | ||
|
||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
using System.IO; | ||
using System.Numerics; | ||
using Warcraft.NET.Extensions; | ||
|
||
namespace Warcraft.NET.Files.WDT.Entries.BfA | ||
{ | ||
/// <summary> | ||
/// An entry struct containing volume fog information | ||
/// </summary> | ||
public class VFOGEntry | ||
{ | ||
/// <summary> | ||
/// Color. | ||
/// </summary> | ||
public Vector3 Color { get; set; } | ||
|
||
/// <summary> | ||
/// Radius-related intensity. Unconfirmed. | ||
/// </summary> | ||
public float[] RadiusRelatedIntensity { get; set; } | ||
|
||
/// <summary> | ||
/// Unknown 0. | ||
/// </summary> | ||
public float Unknown0 { get; set; } | ||
|
||
/// <summary> | ||
/// Position (server coordinates). | ||
/// </summary> | ||
public Vector3 Position { get; set; } | ||
|
||
/// <summary> | ||
/// Unknown 1. Set to 1.0f on loading. | ||
/// </summary> | ||
public float Unknown1 { get; set; } | ||
|
||
/// <summary> | ||
/// Rotation. | ||
/// </summary> | ||
public Quaternion Rotation { get; set; } | ||
|
||
/// <summary> | ||
/// Fog start radius. Unconfirmed. | ||
/// </summary> | ||
public float[] StartRadius { get; set; } | ||
|
||
/// <summary> | ||
/// Fog levels. Unconfirmed. | ||
/// </summary> | ||
public uint[] FogLevels { get; set; } | ||
|
||
/// <summary> | ||
/// Model FileDataID. | ||
/// </summary> | ||
public uint ModelFileDataID { get; set; } | ||
|
||
/// <summary> | ||
/// Unknown 2. Always 1? | ||
/// </summary> | ||
public uint Unknown2 { get; set; } | ||
|
||
/// <summary> | ||
/// ID. | ||
/// </summary> | ||
public uint ID { get; set; } | ||
|
||
|
||
public VFOGEntry() { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="VFOGEntry"/> class. | ||
/// </summary> | ||
/// <param name="data">ExtendedData.</param> | ||
public VFOGEntry(byte[] data) | ||
{ | ||
using (var ms = new MemoryStream(data)) | ||
{ | ||
using (var br = new BinaryReader(ms)) | ||
{ | ||
Color = br.ReadVector3(Structures.AxisConfiguration.Native); | ||
RadiusRelatedIntensity = [br.ReadSingle(), br.ReadSingle(), br.ReadSingle()]; | ||
Unknown0 = br.ReadSingle(); | ||
Position = br.ReadVector3(Structures.AxisConfiguration.Native); | ||
Unknown1 = br.ReadSingle(); | ||
Rotation = br.ReadQuaternion(); | ||
StartRadius = [br.ReadSingle(), br.ReadSingle(), br.ReadSingle()]; | ||
FogLevels = [br.ReadUInt32(), br.ReadUInt32(), br.ReadUInt32(), br.ReadUInt32(), br.ReadUInt32()]; | ||
ModelFileDataID = br.ReadUInt32(); | ||
Unknown2 = br.ReadUInt32(); | ||
ID = br.ReadUInt32(); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the size of an entry. | ||
/// </summary> | ||
/// <returns>The size.</returns> | ||
public static int GetSize() | ||
{ | ||
return 104; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the size of the data contained in this chunk. | ||
/// </summary> | ||
/// <returns>The size.</returns> | ||
public byte[] Serialize(long offset = 0) | ||
{ | ||
using (var ms = new MemoryStream()) | ||
using (var bw = new BinaryWriter(ms)) | ||
{ | ||
bw.WriteVector3(Color, Structures.AxisConfiguration.Native); | ||
bw.Write(RadiusRelatedIntensity[0]); | ||
bw.Write(RadiusRelatedIntensity[1]); | ||
bw.Write(RadiusRelatedIntensity[2]); | ||
bw.Write(Unknown0); | ||
bw.WriteVector3(Position, Structures.AxisConfiguration.Native); | ||
bw.Write(Unknown1); | ||
bw.WriteQuaternion(Rotation); | ||
bw.Write(StartRadius[0]); | ||
bw.Write(StartRadius[1]); | ||
bw.Write(StartRadius[2]); | ||
bw.Write(FogLevels[0]); | ||
bw.Write(FogLevels[1]); | ||
bw.Write(FogLevels[2]); | ||
bw.Write(FogLevels[3]); | ||
bw.Write(FogLevels[4]); | ||
bw.Write(ModelFileDataID); | ||
bw.Write(Unknown2); | ||
bw.Write(ID); | ||
|
||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.