using System.Runtime.InteropServices; namespace SabreTools.Data.Models.BSP { /// /// This lump is simple again and contains an array of binary /// structures, the nodes, which are a major part of the BSP tree. /// /// Every BSPNODE structure represents a node in the BSP tree and /// every node equals more or less a division step of the BSP algorithm. /// Therefore, each node has an index (iPlane) referring to a plane /// in the plane lump which devides the node into its two child nodes. /// The childnodes are also stored as indexes. Contrary to the plane /// index, the node index for the child is signed. If the index is /// larger than 0, the index indicates a child node. If it is equal /// to or smaller than zero (no valid array index), the bitwise /// inversed value of the index gives an index into the leaves lump. /// Additionally two points (nMins, nMaxs) span the bounding box /// (AABB, axis aligned bounding box) delimitting the space of the node. /// Finally firstFace indexes into the face lump and spezifies the /// first of nFaces surfaces contained in this node. /// /// /// [StructLayout(LayoutKind.Sequential)] public class BspNode { /// /// Index into Planes lump /// public uint PlaneIndex; /// /// If > 0, then indices into Nodes. /// Otherwise bitwise inverse indices into Leafs /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public ushort[] Children = new ushort[2]; /// /// Defines bounding box /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public ushort[] Mins = new ushort[3]; /// /// Defines bounding box /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public ushort[] Maxs = new ushort[3]; /// /// Index into Faces /// public ushort FirstFace; /// /// Count of Faces /// public ushort FaceCount; } }