You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
4.6 KiB
174 lines
4.6 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of model_t
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0, CharSet = CharSet.Ansi)]
|
|
public class QModel
|
|
{
|
|
private const int MaxPath = 64; // Should correspond to MAX_QPATH
|
|
private const int MaxMapHulls = 4; // Should correspond to MAX_MAP_HULLS
|
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxPath)] public string name;
|
|
public bool needLoad;
|
|
|
|
public QModelType type;
|
|
public int numFrames;
|
|
public QSyncType syncType;
|
|
|
|
public int flags;
|
|
|
|
// Volume occupied by the model graphics
|
|
public QVec3 mins, maxs;
|
|
public float radius;
|
|
|
|
// Solid volume for clipping
|
|
public bool clipBox;
|
|
public QVec3 clipMins, clipMaxs;
|
|
|
|
// Brush model
|
|
public int firstModelSurface, numModelSurfaces;
|
|
|
|
public int numSubModels;
|
|
public IntPtr subModels; // Array of dmodel_t
|
|
|
|
public int numPlanes;
|
|
public IntPtr planes; // Array of mplane_t
|
|
|
|
public int numLeafs;
|
|
public IntPtr leafs; // Array of mleaf_t
|
|
|
|
public int numVertices;
|
|
public IntPtr vertices; // Array of mvertex_t
|
|
|
|
public int numEdges;
|
|
public IntPtr edges; // Array of medge_t
|
|
|
|
public int numNodes;
|
|
public IntPtr nodes; // Array of mnode_t
|
|
|
|
public int numTexInfo;
|
|
public IntPtr texInfo; // Array of mtexinfo_t
|
|
|
|
public int numSurfaces;
|
|
public IntPtr surfaces; // Array of msurface_t
|
|
|
|
public int numSurfEdges;
|
|
public IntPtr surfEdges; // Array of int
|
|
|
|
public int numClipNodes;
|
|
public IntPtr clipNodes; // Array of dclipnode_t
|
|
|
|
public int numMarkSurfaces;
|
|
public IntPtr markSurfaces; // Array of msurface_t pointers
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxMapHulls)] public QHull[] hulls;
|
|
|
|
public int numTextures;
|
|
public IntPtr textures; // Array of texture_t pointers
|
|
|
|
public IntPtr visData; // Array of bytes
|
|
public IntPtr lightData; // Array of bytes
|
|
[MarshalAs(UnmanagedType.LPStr)] public string entities;
|
|
|
|
public IntPtr userCache;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of aliashdr_t
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0)]
|
|
public class QAliasHeader
|
|
{
|
|
private const int MaxSkins = 32; // Should correspond to MAX_SKINS
|
|
|
|
public int ident;
|
|
public int version;
|
|
public QVec3 scale;
|
|
public QVec3 scaleOrigin;
|
|
public float boundingRadius;
|
|
public QVec3 eyePosition;
|
|
public int numSkins;
|
|
public int skinWidth;
|
|
public int skinHeight;
|
|
public int numVerts;
|
|
public int numTriangles;
|
|
public int numFrames;
|
|
public QSyncType syncType;
|
|
public int flags;
|
|
public float size;
|
|
|
|
public int numPoses;
|
|
public int poseVerts;
|
|
public int poseData;
|
|
public int commands;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSkins)] public QVec4i[] glTextureNum;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSkins)] public int[] texels;
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSkins)] public bool[] skinLuma;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSkins)] public bool[] skinLuma8bit;
|
|
|
|
// Actually variable sized, but we receive an additional pointer to the first element so we can manually marshal the entire array
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public QAliasFrameDesc[] frames;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of modtype_t
|
|
/// </summary>
|
|
public enum QModelType
|
|
{
|
|
Brush,
|
|
Sprite,
|
|
Alias,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of synctype_t
|
|
/// </summary>
|
|
public enum QSyncType
|
|
{
|
|
Sync = 0,
|
|
Rand
|
|
}
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of hull_t
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0)]
|
|
public struct QHull
|
|
{
|
|
public IntPtr clipNodes; // Array of dclipnode_t
|
|
public IntPtr planes; // Array of mplane_t
|
|
public int firstClipNode;
|
|
public int lastClipNode;
|
|
public QVec3 clipMins;
|
|
public QVec3 clipMaxs;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of maliasframedesc_t
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0, CharSet = CharSet.Ansi)]
|
|
public struct QAliasFrameDesc
|
|
{
|
|
public int firstPose;
|
|
public int numPoses;
|
|
public float interval;
|
|
public QTriVertex bboxMin;
|
|
public QTriVertex bboxMax;
|
|
public int frame;
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string name;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Managed equivalent of trivertx_t
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0)]
|
|
public struct QTriVertex
|
|
{
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] v;
|
|
public byte lightNormalIndex;
|
|
}
|