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

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

            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i]   = new Vector3();
                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();

                Vector3 normal = new Vector3();
                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);
        }