예제 #1
0
        private Vector3D[] GetVertices(Stream stream)
        {
            Lump lump = header.lumps[(int)LumpType.LUMP_VERTEXES];

            stream.Position = lump.offset;
            Vector3D[] vertices = new Vector3D[(lump.length / 3) / 4];

            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i]   = new Vector3D();
                vertices[i].X = UtilityReader.ReadFloat(stream);
                vertices[i].Y = UtilityReader.ReadFloat(stream);
                vertices[i].Z = UtilityReader.ReadFloat(stream);
            }

            return(vertices);
        }
예제 #2
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);
        }
예제 #3
0
        private Plane[] GetPlanes(Stream stream)
        {
            Lump lump = header.lumps[(int)LumpType.LUMP_PLANES];

            Plane[] planes = new Plane[lump.length / 20];
            stream.Position = lump.offset;

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

                Vector3D normal = new Vector3D();
                normal.X = UtilityReader.ReadFloat(stream);
                normal.Y = UtilityReader.ReadFloat(stream);
                normal.Z = UtilityReader.ReadFloat(stream);

                planes[i].normal   = normal;
                planes[i].distance = UtilityReader.ReadFloat(stream);
                planes[i].type     = UtilityReader.ReadInt(stream);
            }

            return(planes);
        }