Files

64 lines
2.2 KiB
C#
Raw Permalink Normal View History

2025-09-26 10:57:15 -04:00
using System.Runtime.InteropServices;
2025-09-26 13:06:18 -04:00
namespace SabreTools.Data.Models.BSP
2025-09-26 10:57:15 -04:00
{
/// <summary>
/// A model is kind of a mini BSP tree. Its size is determinded
/// by the bounding box spaned by the first to members of this
/// struct. The major difference between a model and the BSP
/// tree holding the scene is that the models use a local
/// coordinate system for their vertexes and just state its
/// origin in world coordinates. During rendering the coordinate
/// system is translated to the origin of the model (glTranslate())
/// and moved back after the models BSP tree has been traversed.
/// Furthermore their are 4 indexes into node arrays. The first
/// one has proofed to index the root node of the mini BSP tree
/// used for rendering. The other three indexes could probably be
/// used for collision detection, meaning they point into the
/// clipnodes, but I am not sure about this. The meaning of the
/// next value is also somehow unclear to me. Finally their are
/// direct indexes into the faces array, not taking the redirecting
2025-10-30 21:21:56 -04:00
/// by the marksurfaces.
2025-09-26 10:57:15 -04:00
/// </summary>
2025-10-30 21:21:56 -04:00
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(GoldSrc)"/>
2025-09-26 10:57:15 -04:00
[StructLayout(LayoutKind.Sequential)]
public sealed class BspModel
{
/// <summary>
/// Defines bounding box
/// </summary>
public Vector3D Mins = new();
2025-09-26 10:57:15 -04:00
/// <summary>
/// Defines bounding box
/// </summary>
public Vector3D Maxs = new();
2025-09-26 10:57:15 -04:00
/// <summary>
/// Coordinates to move the coordinate system
/// </summary>
public Vector3D OriginVector = new();
2025-09-26 10:57:15 -04:00
/// <summary>
/// Index into nodes array
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.MAX_MAP_HULLS)]
2025-10-30 21:21:56 -04:00
public int[] HeadnodesIndex = new int[Constants.MAX_MAP_HULLS];
2025-09-26 10:57:15 -04:00
/// <summary>
/// ???
/// </summary>
public int VisLeafsCount;
/// <summary>
/// Index into faces
/// </summary>
public int FirstFaceIndex;
/// <summary>
/// Count of faces
/// </summary>
public int FacesCount;
}
2025-10-30 21:21:56 -04:00
}