Пример #1
0
        private Leaf[] GetLeafs(Stream stream)
        {
            Lump lump = _header.lumps[(int)LumpType.LumpLeafs];

            Leaf[] leafData = new Leaf[lump.Length / 56];
            stream.Position = lump.Offset;

            for (int i = 0; i < leafData.Length; i++)
            {
                leafData[i] = new Leaf
                {
                    contents = (ContentsFlag)UtilityReader.ReadInt(stream),
                    cluster  = UtilityReader.ReadShort(stream),
                    area     = UtilityReader.ReadShort(stream),
                    flags    = UtilityReader.ReadShort(stream),
                    mins     = new short[3]
                };
                leafData[i].mins[0]         = UtilityReader.ReadShort(stream);
                leafData[i].mins[1]         = UtilityReader.ReadShort(stream);
                leafData[i].mins[2]         = UtilityReader.ReadShort(stream);
                leafData[i].maxs            = new short[3];
                leafData[i].maxs[0]         = UtilityReader.ReadShort(stream);
                leafData[i].maxs[1]         = UtilityReader.ReadShort(stream);
                leafData[i].maxs[2]         = UtilityReader.ReadShort(stream);
                leafData[i].firstleafface   = UtilityReader.ReadUShort(stream);
                leafData[i].numleaffaces    = UtilityReader.ReadUShort(stream);
                leafData[i].firstleafbrush  = UtilityReader.ReadUShort(stream);
                leafData[i].numleafbrushes  = UtilityReader.ReadUShort(stream);
                leafData[i].leafWaterDataID = UtilityReader.ReadShort(stream);
            }

            return(leafData);
        }
Пример #2
0
        private Node[] GetNodes(Stream stream)
        {
            Lump lump = _header.lumps[(int)LumpType.LumpNodes];

            Node[] nodesData = new Node[lump.Length / 32];
            stream.Position = lump.Offset;

            for (int i = 0; i < nodesData.Length; i++)
            {
                nodesData[i] = new Node
                {
                    planenum = UtilityReader.ReadInt(stream),
                    children = new int[2]
                };
                nodesData[i].children[0] = UtilityReader.ReadInt(stream);
                nodesData[i].children[1] = UtilityReader.ReadInt(stream);
                nodesData[i].mins        = new short[3];
                nodesData[i].mins[0]     = UtilityReader.ReadShort(stream);
                nodesData[i].mins[1]     = UtilityReader.ReadShort(stream);
                nodesData[i].mins[2]     = UtilityReader.ReadShort(stream);
                nodesData[i].maxs        = new short[3];
                nodesData[i].maxs[0]     = UtilityReader.ReadShort(stream);
                nodesData[i].maxs[1]     = UtilityReader.ReadShort(stream);
                nodesData[i].maxs[2]     = UtilityReader.ReadShort(stream);
                nodesData[i].firstface   = UtilityReader.ReadUShort(stream);
                nodesData[i].numfaces    = UtilityReader.ReadUShort(stream);
                nodesData[i].area        = UtilityReader.ReadShort(stream);
                nodesData[i].paddding    = UtilityReader.ReadShort(stream);
            }

            return(nodesData);
        }
Пример #3
0
        private Brushside[] GetBrushsides(Stream stream)
        {
            Lump lump = _header.lumps[(int)LumpType.LumpBrushes];

            Brushside[] brushsides = new Brushside[lump.Length / 8];
            stream.Position = lump.Offset;

            for (int i = 0; i < brushsides.Length; i++)
            {
                brushsides[i] = new Brushside
                {
                    planenum = UtilityReader.ReadUShort(stream),
                    texinfo  = UtilityReader.ReadShort(stream),
                    dispinfo = UtilityReader.ReadShort(stream),
                    bevel    = UtilityReader.ReadShort(stream)
                };
            }

            return(brushsides);
        }
Пример #4
0
        private Face[] GetFaces(Stream stream)
        {
            Lump lump = _header.lumps[(int)LumpType.LumpFaces];

            stream.Position = lump.Offset;
            Face[] faces = new Face[lump.Length / 56];

            for (int i = 0; i < faces.Length; i++)
            {
                faces[i] = new Face
                {
                    planeNumber        = UtilityReader.ReadUShort(stream),
                    side               = UtilityReader.ReadByte(stream),
                    onNode             = UtilityReader.ReadByte(stream),
                    firstEdge          = UtilityReader.ReadInt(stream),
                    numEdges           = UtilityReader.ReadShort(stream),
                    texinfo            = UtilityReader.ReadShort(stream),
                    dispinfo           = UtilityReader.ReadShort(stream),
                    surfaceFogVolumeID = UtilityReader.ReadShort(stream),
                    styles             = new byte[4]
                };
                faces[i].styles[0]   = UtilityReader.ReadByte(stream);
                faces[i].styles[1]   = UtilityReader.ReadByte(stream);
                faces[i].styles[2]   = UtilityReader.ReadByte(stream);
                faces[i].styles[3]   = UtilityReader.ReadByte(stream);
                faces[i].lightOffset = UtilityReader.ReadInt(stream);
                faces[i].area        = UtilityReader.ReadFloat(stream);
                faces[i].LightmapTextureMinsInLuxels    = new int[2];
                faces[i].LightmapTextureMinsInLuxels[0] = UtilityReader.ReadInt(stream);
                faces[i].LightmapTextureMinsInLuxels[1] = UtilityReader.ReadInt(stream);
                faces[i].LightmapTextureSizeInLuxels    = new int[2];
                faces[i].LightmapTextureSizeInLuxels[0] = UtilityReader.ReadInt(stream);
                faces[i].LightmapTextureSizeInLuxels[1] = UtilityReader.ReadInt(stream);
                faces[i].originalFace    = UtilityReader.ReadInt(stream);
                faces[i].numPrims        = UtilityReader.ReadUShort(stream);
                faces[i].firstPrimID     = UtilityReader.ReadUShort(stream);
                faces[i].smoothingGroups = UtilityReader.ReadUInt(stream);
            }

            return(faces);
        }