mirror of
https://github.com/SabreTools/SabreTools.Models.git
synced 2026-09-23 23:25:35 +00:00
Update WAD3 models
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.WAD
|
||||
{
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/WADFile.h"/>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public sealed class Lump
|
||||
{
|
||||
public uint Offset;
|
||||
|
||||
public uint DiskLength;
|
||||
|
||||
public uint Length;
|
||||
|
||||
public byte Type;
|
||||
|
||||
public byte Compression;
|
||||
|
||||
public byte Padding0;
|
||||
|
||||
public byte Padding1;
|
||||
|
||||
/// <remarks>16 bytes</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
|
||||
public string? Name;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.WAD
|
||||
{
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/WADFile.h"/>
|
||||
public sealed class LumpInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Type 0x42 has no name, type 0x43 does
|
||||
/// </summary>
|
||||
/// <remarks>16 bytes</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
|
||||
public string? Name;
|
||||
|
||||
public uint Width;
|
||||
|
||||
public uint Height;
|
||||
|
||||
public uint PixelOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Unknown data
|
||||
/// </summary>
|
||||
/// <remarks>12 bytes</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
||||
public byte[]? UnknownData;
|
||||
|
||||
/// <remarks>Width * Height bytes located at PixelOffset</remarks>
|
||||
public byte[]? PixelData { get; set; }
|
||||
|
||||
// TODO: Determine what mipmap data looks like
|
||||
|
||||
public uint PaletteSize { get; set; }
|
||||
|
||||
/// <remarks>PaletteSize * 3 bytes</remarks>
|
||||
public byte[]? PaletteData { get; set; }
|
||||
}
|
||||
}
|
||||
13
SabreTools.Models/WAD3/CharInfo.cs
Normal file
13
SabreTools.Models/WAD3/CharInfo.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public sealed class CharInfo
|
||||
{
|
||||
public ushort StartOffset;
|
||||
|
||||
public ushort CharWidth;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace SabreTools.Models.WAD
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
48
SabreTools.Models/WAD3/DirEntry.cs
Normal file
48
SabreTools.Models/WAD3/DirEntry.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/WADFile.h"/>
|
||||
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public sealed class DirEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Offset from the beginning of the WAD3 data
|
||||
/// </summary>
|
||||
public uint Offset;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's size in the archive in bytes
|
||||
/// </summary>
|
||||
public uint DiskLength;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's uncompressed size
|
||||
/// </summary>
|
||||
public uint Length;
|
||||
|
||||
/// <summary>
|
||||
/// File type of the entry
|
||||
/// </summary>
|
||||
public FileType Type;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the file was compressed
|
||||
/// </summary>
|
||||
/// <remarks>Actually a boolean value</remarks>
|
||||
public byte Compression;
|
||||
|
||||
/// <summary>
|
||||
/// Padding
|
||||
/// </summary>
|
||||
public ushort Padding;
|
||||
|
||||
/// <summary>
|
||||
/// Null-terminated texture name
|
||||
/// </summary>
|
||||
/// <remarks>16 bytes</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
|
||||
public string? Name;
|
||||
}
|
||||
}
|
||||
28
SabreTools.Models/WAD3/Enums.cs
Normal file
28
SabreTools.Models/WAD3/Enums.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
|
||||
public enum FileType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// spraydecal (0x40): Same as <see cref="Miptex"/>.
|
||||
/// Only found in entry LOGO (or {LOGO) in tempdecal.wad
|
||||
/// </summary>
|
||||
Spraydecal = 0x40,
|
||||
|
||||
/// <summary>
|
||||
/// qpic (0x42): A simple image of any size.
|
||||
/// </summary>
|
||||
Qpic = 0x42,
|
||||
|
||||
/// <summary>
|
||||
/// miptex (0x43): World texture with dimensions that are multiple-of-16
|
||||
/// and 4 mipmaps. This is the typical entry type.
|
||||
/// </summary>
|
||||
Miptex = 0x43,
|
||||
|
||||
/// <summary>
|
||||
/// font (0x46): Fixed-height font for 256 ASCII characters.
|
||||
/// </summary>
|
||||
Font = 0x46,
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace SabreTools.Models.WAD
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <summary>
|
||||
/// Half-Life Texture Package File
|
||||
@@ -12,13 +12,13 @@ namespace SabreTools.Models.WAD
|
||||
public Header? Header { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Deserialized lumps data
|
||||
/// Deserialized dir entry data
|
||||
/// </summary>
|
||||
public Lump?[]? Lumps { get; set; }
|
||||
public DirEntry?[]? DirEntries { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Deserialized lump infos data
|
||||
/// Deserialized file entry data
|
||||
/// </summary>
|
||||
public LumpInfo?[]? LumpInfos { get; set; }
|
||||
public FileEntry?[]? FileEntries { get; set; }
|
||||
}
|
||||
}
|
||||
11
SabreTools.Models/WAD3/FileEntry.cs
Normal file
11
SabreTools.Models/WAD3/FileEntry.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <summary>
|
||||
/// qlumpy always align entries to the DWORD (=4 bytes) boundary
|
||||
/// (i.e. next integer multiples of 4 offset from start of file)
|
||||
/// </summary>
|
||||
public abstract class FileEntry
|
||||
{
|
||||
// No shared fields between types
|
||||
}
|
||||
}
|
||||
40
SabreTools.Models/WAD3/Font.cs
Normal file
40
SabreTools.Models/WAD3/Font.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public sealed class Font : FileEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Dimensions of the texture (must be divisible by 16)
|
||||
/// </summary>
|
||||
public uint Width;
|
||||
|
||||
/// <summary>
|
||||
/// Dimensions of the texture (must be divisible by 16)
|
||||
/// </summary>
|
||||
public uint Height;
|
||||
|
||||
public uint RowCount;
|
||||
|
||||
public uint RowHeight;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
|
||||
public CharInfo[] FontInfo = new CharInfo[256];
|
||||
|
||||
/// <remarks>[width][height]</remarks>
|
||||
public byte[,]? Data;
|
||||
|
||||
/// <summary>
|
||||
/// Number of colors used in the palette (always 256 for GoldSrc)
|
||||
/// </summary>
|
||||
public ushort ColorsUsed;
|
||||
|
||||
/// <summary>
|
||||
/// The color palette for the mipmaps (always 256 * 3 = 768 for GoldSrc)
|
||||
/// </summary>
|
||||
/// <remarks>[ColorsUsed][3]</remarks>
|
||||
public byte[,]? Palette { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.WAD
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/WADFile.h"/>
|
||||
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public sealed class Header
|
||||
{
|
||||
@@ -14,13 +15,13 @@ namespace SabreTools.Models.WAD
|
||||
public string? Signature;
|
||||
|
||||
/// <summary>
|
||||
/// Number of lumps in the file
|
||||
/// Number of Directory entries
|
||||
/// </summary>
|
||||
public uint LumpCount;
|
||||
public uint NumDirs;
|
||||
|
||||
/// <summary>
|
||||
/// Offset where lumps are stored
|
||||
/// Offset from the WAD3 data's beginning for first Directory entry
|
||||
/// </summary>
|
||||
public uint LumpOffset;
|
||||
public uint DirOffset;
|
||||
}
|
||||
}
|
||||
14
SabreTools.Models/WAD3/MipMap.cs
Normal file
14
SabreTools.Models/WAD3/MipMap.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
|
||||
public sealed class MipMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Raw image data. Each byte points to an index in the palette
|
||||
/// </summary>
|
||||
/// <remarks>[width][height]</remarks>
|
||||
public byte[,]? Data { get; set; }
|
||||
}
|
||||
}
|
||||
48
SabreTools.Models/WAD3/MipTex.cs
Normal file
48
SabreTools.Models/WAD3/MipTex.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
|
||||
public sealed class MipTex : FileEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Null-terminated texture name
|
||||
/// </summary>
|
||||
/// <remarks>16 bytes</remarks>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
|
||||
public string? Name;
|
||||
|
||||
/// <summary>
|
||||
/// Dimensions of the texture (must be divisible by 16)
|
||||
/// </summary>
|
||||
public uint Width;
|
||||
|
||||
/// <summary>
|
||||
/// Dimensions of the texture (must be divisible by 16)
|
||||
/// </summary>
|
||||
public uint Height;
|
||||
|
||||
/// <summary>
|
||||
/// Offset from start of this struct to each mipmap level's image
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public uint[] MipOffsets = new uint[4];
|
||||
|
||||
/// <summary>
|
||||
/// One MipMap for each mipmap level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public MipMap[] MipImages = new MipMap[4];
|
||||
|
||||
/// <summary>
|
||||
/// Number of colors used in the palette (always 256 for GoldSrc)
|
||||
/// </summary>
|
||||
public ushort ColorsUsed;
|
||||
|
||||
/// <summary>
|
||||
/// The color palette for the mipmaps (always 256 * 3 = 768 for GoldSrc)
|
||||
/// </summary>
|
||||
/// <remarks>[ColorsUsed][3]</remarks>
|
||||
public byte[,]? Palette { get; set; }
|
||||
}
|
||||
}
|
||||
33
SabreTools.Models/WAD3/QpicImage.cs
Normal file
33
SabreTools.Models/WAD3/QpicImage.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace SabreTools.Models.WAD3
|
||||
{
|
||||
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
|
||||
public sealed class QpicImage : FileEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Dimensions of the texture (must be divisible by 16)
|
||||
/// </summary>
|
||||
public uint Width;
|
||||
|
||||
/// <summary>
|
||||
/// Dimensions of the texture (must be divisible by 16)
|
||||
/// </summary>
|
||||
public uint Height;
|
||||
|
||||
/// <summary>
|
||||
/// Raw image data. Each byte points to an index in the palette
|
||||
/// </summary>
|
||||
/// <remarks>[height][width]</remarks>
|
||||
public byte[,]? Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of colors used in the palette (always 256 for GoldSrc)
|
||||
/// </summary>
|
||||
public ushort ColorsUsed;
|
||||
|
||||
/// <summary>
|
||||
/// The color palette for the mipmaps (always 256 * 3 = 768 for GoldSrc)
|
||||
/// </summary>
|
||||
/// <remarks>[ColorsUsed][3]</remarks>
|
||||
public byte[,]? Palette { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user