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

            Leaf[] leafData = new Leaf[lump.length / 56];
            stream.Position = lump.offset;

            for (int i = 0; i < leafData.Length; i++)
            {
                leafData[i] = new Leaf();

                leafData[i].contents = (ContentsFlag)UtilityReader.ReadInt(stream);
                leafData[i].cluster  = UtilityReader.ReadShort(stream);
                leafData[i].area     = UtilityReader.ReadShort(stream);
                leafData[i].flags    = UtilityReader.ReadShort(stream);

                leafData[i].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.LUMP_NODES];

            Node[] nodesData = new Node[lump.length / 32];
            stream.Position = lump.offset;

            for (int i = 0; i < nodesData.Length; i++)
            {
                nodesData[i] = new Node();

                nodesData[i].planenum = UtilityReader.ReadInt(stream);

                nodesData[i].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.LUMP_BRUSHES];

            Brushside[] brushsides = new Brushside[lump.length / 8];
            stream.Position = lump.offset;

            for (int i = 0; i < brushsides.Length; i++)
            {
                brushsides[i] = new Brushside();

                brushsides[i].planenum = UtilityReader.ReadUShort(stream);
                brushsides[i].texinfo  = UtilityReader.ReadShort(stream);
                brushsides[i].dispinfo = UtilityReader.ReadShort(stream);
                brushsides[i].bevel    = UtilityReader.ReadShort(stream);
            }

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

            stream.Position = lump.offset;
            Face[] faces = new Face[lump.length / 56];

            for (int i = 0; i < faces.Length; i++)
            {
                faces[i]                                = new Face();
                faces[i].planeNumber                    = UtilityReader.ReadUShort(stream);
                faces[i].side                           = UtilityReader.ReadByte(stream);
                faces[i].onNode                         = UtilityReader.ReadByte(stream);
                faces[i].firstEdge                      = UtilityReader.ReadInt(stream);
                faces[i].numEdges                       = UtilityReader.ReadShort(stream);
                faces[i].texinfo                        = UtilityReader.ReadShort(stream);
                faces[i].dispinfo                       = UtilityReader.ReadShort(stream);
                faces[i].surfaceFogVolumeID             = UtilityReader.ReadShort(stream);
                faces[i].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);
        }