Пример #1
0
 public dheader_t()
 {
     for (int kk = 0; kk < HEADER_LUMPS; kk++)
     {
         lumps[kk] = new lump_t();
     }
 }
Пример #2
0
        public virtual void Mod_LoadSubmodels(lump_t l)
        {
            qfiles.dmodel_t in_renamed;
            mmodel_t[]      out_renamed;
            Int32           i, j, count;

            if ((l.filelen % qfiles.dmodel_t.SIZE) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count                  = l.filelen / qfiles.dmodel_t.SIZE;
            out_renamed            = new mmodel_t[count];
            loadmodel.submodels    = out_renamed;
            loadmodel.numsubmodels = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order = ByteOrder.LittleEndian;
            for (i = 0; i < count; i++)
            {
                in_renamed     = new dmodel_t(bb);
                out_renamed[i] = new mmodel_t();
                for (j = 0; j < 3; j++)
                {
                    out_renamed[i].mins[j]   = in_renamed.mins[j] - 1;
                    out_renamed[i].maxs[j]   = in_renamed.maxs[j] + 1;
                    out_renamed[i].origin[j] = in_renamed.origin[j];
                }

                out_renamed[i].radius    = RadiusFromBounds(out_renamed[i].mins, out_renamed[i].maxs);
                out_renamed[i].headnode  = in_renamed.headnode;
                out_renamed[i].firstface = in_renamed.firstface;
                out_renamed[i].numfaces  = in_renamed.numfaces;
            }
        }
Пример #3
0
        public virtual void Mod_LoadLeafs(lump_t l)
        {
            qfiles.dleaf_t in_renamed;
            mleaf_t[]      out_renamed;
            Int32          i, j, count;

            if ((l.filelen % qfiles.dleaf_t.SIZE) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count              = l.filelen / qfiles.dleaf_t.SIZE;
            out_renamed        = new mleaf_t[count];
            loadmodel.leafs    = out_renamed;
            loadmodel.numleafs = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order = ByteOrder.LittleEndian;
            for (i = 0; i < count; i++)
            {
                in_renamed     = new dleaf_t(bb);
                out_renamed[i] = new mleaf_t();
                for (j = 0; j < 3; j++)
                {
                    out_renamed[i].mins[j] = in_renamed.mins[j];
                    out_renamed[i].maxs[j] = in_renamed.maxs[j];
                }

                out_renamed[i].contents = in_renamed.contents;
                out_renamed[i].cluster  = in_renamed.cluster;
                out_renamed[i].area     = in_renamed.area;
                out_renamed[i].SetMarkSurface(in_renamed.firstleafface, loadmodel.marksurfaces);
                out_renamed[i].nummarksurfaces = in_renamed.numleaffaces;
            }
        }
Пример #4
0
    public ddispinfo_t[] GetDispInfo()
    {
        lump_t lump = lumps[26];

        ddispinfo_t[] displacementInfo = new ddispinfo_t[lump.filelen / 86];
        stream.Position = lump.fileofs;

        for (int i = 0; i < displacementInfo.Length; i++)
        {
            displacementInfo[i].startPosition               = new Vector3(FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream));
            displacementInfo[i].DispVertStart               = FileReader.readInt(stream);
            displacementInfo[i].DispTriStart                = FileReader.readInt(stream);
            displacementInfo[i].power                       = FileReader.readInt(stream);
            displacementInfo[i].minTess                     = FileReader.readInt(stream);
            displacementInfo[i].smoothingAngle              = FileReader.readFloat(stream);
            displacementInfo[i].contents                    = FileReader.readInt(stream);
            displacementInfo[i].MapFace                     = FileReader.readUShort(stream);
            displacementInfo[i].LightmapAlphaStart          = FileReader.readInt(stream);
            displacementInfo[i].LightmapSamplePositionStart = FileReader.readInt(stream);
            stream.Position += 90;
            displacementInfo[i].AllowedVerts = new uint[10] {
                FileReader.readUInt(stream), FileReader.readUInt(stream), FileReader.readUInt(stream), FileReader.readUInt(stream), FileReader.readUInt(stream), FileReader.readUInt(stream), FileReader.readUInt(stream), FileReader.readUInt(stream), FileReader.readUInt(stream), FileReader.readUInt(stream)
            };
        }

        lumpData[26] = displacementInfo;
        return(displacementInfo);
    }
Пример #5
0
        public virtual void Mod_LoadMarksurfaces(lump_t l)
        {
            Int32 i, j, count;

            msurface_t[] out_renamed;
            if ((l.filelen % Defines.SIZE_OF_SHORT) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count                     = l.filelen / Defines.SIZE_OF_SHORT;
            out_renamed               = new msurface_t[count];
            loadmodel.marksurfaces    = out_renamed;
            loadmodel.nummarksurfaces = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order = ByteOrder.LittleEndian;
            for (i = 0; i < count; i++)
            {
                j = bb.GetInt16();
                if (j < 0 || j >= loadmodel.numsurfaces)
                {
                    Com.Error(Defines.ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
                }
                out_renamed[i] = loadmodel.surfaces[j];
            }
        }
Пример #6
0
    public texinfo_t[] GetTextureInfo()
    {
        lump_t lump = lumps[6];

        texinfo_t[] textureInfo = new texinfo_t[lump.filelen / 72];
        stream.Position = lump.fileofs;

        for (int i = 0; i < textureInfo.Length; i++)
        {
            textureInfo[i].textureVecs    = new float[2][];
            textureInfo[i].textureVecs[0] = new float[4] {
                FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream)
            };
            textureInfo[i].textureVecs[1] = new float[4] {
                FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream)
            };
            textureInfo[i].lightmapVecs    = new float[2][];
            textureInfo[i].lightmapVecs[0] = new float[4] {
                FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream)
            };
            textureInfo[i].lightmapVecs[1] = new float[4] {
                FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream)
            };
            textureInfo[i].flags   = FileReader.readInt(stream);
            textureInfo[i].texdata = FileReader.readInt(stream);
        }

        lumpData[6] = textureInfo;
        return(textureInfo);
    }
Пример #7
0
        public virtual void Mod_LoadSurfedges(lump_t l)
        {
            Int32 i, count;

            Int32[] offsets;
            if ((l.filelen % Defines.SIZE_OF_INT) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count = l.filelen / Defines.SIZE_OF_INT;
            if (count < 1 || count >= Defines.MAX_MAP_SURFEDGES)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: bad surfedges count in " + loadmodel.name + ": " + count);
            }
            offsets                = new Int32[count];
            loadmodel.surfedges    = offsets;
            loadmodel.numsurfedges = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order = ByteOrder.LittleEndian;
            for (i = 0; i < count; i++)
            {
                offsets[i] = bb.GetInt32();
            }
        }
Пример #8
0
        public virtual void Mod_LoadTexinfo(lump_t l)
        {
            texinfo_t in_renamed;

            mtexinfo_t[] out_renamed;
            mtexinfo_t   step;
            Int32        i, count;
            Int32        next;
            String       name;

            if ((l.filelen % texinfo_t.SIZE) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count       = l.filelen / texinfo_t.SIZE;
            out_renamed = new mtexinfo_t[count];
            for (i = 0; i < count; i++)
            {
                out_renamed[i] = new mtexinfo_t();
            }

            loadmodel.texinfo    = out_renamed;
            loadmodel.numtexinfo = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order = ByteOrder.LittleEndian;
            for (i = 0; i < count; i++)
            {
                in_renamed           = new texinfo_t(bb);
                out_renamed[i].vecs  = in_renamed.vecs;
                out_renamed[i].flags = in_renamed.flags;
                next = in_renamed.nexttexinfo;
                if (next > 0)
                {
                    out_renamed[i].next = loadmodel.texinfo[next];
                }
                else
                {
                    out_renamed[i].next = null;
                }
                name = "textures/" + in_renamed.texture + ".wal";
                out_renamed[i].image = GL_FindImage(name, it_wall);
                if (out_renamed[i].image == null)
                {
                    VID.Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\\');
                    out_renamed[i].image = r_notexture;
                }
            }

            for (i = 0; i < count; i++)
            {
                out_renamed[i].numframes = 1;
                for (step = out_renamed[i].next; (step != null) && (step != out_renamed[i]); step = step.next)
                {
                    out_renamed[i].numframes++;
                }
            }
        }
Пример #9
0
            public int mapRevision;             // the map's revision (iteration, version) number

            public dheader_t(BinaryReader br)
            {
                ident   = br.ReadInt32();
                version = br.ReadInt32();
                lumps   = new lump_t[HEADER_LUMPS];
                for (int i = 0; i < HEADER_LUMPS; i++)
                {
                    lumps[i] = new lump_t(br);
                }
                mapRevision = br.ReadInt32();
            }
Пример #10
0
        public virtual void Mod_LoadLighting(lump_t l)
        {
            if (l.filelen == 0)
            {
                loadmodel.lightdata = null;
                return;
            }

            loadmodel.lightdata = new Byte[l.filelen];
            System.Array.Copy(mod_base, l.fileofs, loadmodel.lightdata, 0, l.filelen);
        }
Пример #11
0
 private void LoadLumps()
 {
     for (int i = 0; i < lumps.Length; i++)
     {
         lump_t lump = new lump_t();
         lump.fileofs = FileReader.readInt(stream);
         lump.filelen = FileReader.readInt(stream);
         lump.version = FileReader.readInt(stream);
         lump.fourCC  = FileReader.readInt(stream);
         lumps[i]     = lump;
     }
 }
Пример #12
0
        public virtual void Mod_LoadNodes(lump_t l)
        {
            Int32 i, j, count, p;

            qfiles.dnode_t in_renamed;
            mnode_t[]      out_renamed;
            if ((l.filelen % qfiles.dnode_t.SIZE) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count              = l.filelen / qfiles.dnode_t.SIZE;
            out_renamed        = new mnode_t[count];
            loadmodel.nodes    = out_renamed;
            loadmodel.numnodes = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order = ByteOrder.LittleEndian;
            for (i = 0; i < count; i++)
            {
                out_renamed[i] = new mnode_t();
            }
            for (i = 0; i < count; i++)
            {
                in_renamed = new dnode_t(bb);
                for (j = 0; j < 3; j++)
                {
                    out_renamed[i].mins[j] = in_renamed.mins[j];
                    out_renamed[i].maxs[j] = in_renamed.maxs[j];
                }

                p = in_renamed.planenum;
                out_renamed[i].plane        = loadmodel.planes[p];
                out_renamed[i].firstsurface = in_renamed.firstface;
                out_renamed[i].numsurfaces  = in_renamed.numfaces;
                out_renamed[i].contents     = -1;
                for (j = 0; j < 2; j++)
                {
                    p = in_renamed.children[j];
                    if (p >= 0)
                    {
                        out_renamed[i].children[j] = loadmodel.nodes[p];
                    }
                    else
                    {
                        out_renamed[i].children[j] = loadmodel.leafs[-1 - p];
                    }
                }
            }

            Mod_SetParent(loadmodel.nodes[0], null);
        }
Пример #13
0
    public int[] GetTextureStringTable()
    {
        lump_t lump = lumps[44];

        int[] textureStringTable = new int[lump.filelen / 4];
        stream.Position = lump.fileofs;

        for (int i = 0; i < textureStringTable.Length; i++)
        {
            textureStringTable[i] = FileReader.readInt(stream);
        }

        return(textureStringTable);
    }
Пример #14
0
        public virtual void Mod_LoadVisibility(lump_t l)
        {
            if (l.filelen == 0)
            {
                loadmodel.vis = null;
                return;
            }

            System.Array.Copy(mod_base, l.fileofs, model_visibility, 0, l.filelen);
            ByteBuffer bb = ByteBuffer.Wrap(model_visibility, 0, l.filelen);

            bb.Order      = ByteOrder.LittleEndian;
            loadmodel.vis = new dvis_t(bb);
        }
Пример #15
0
    public string GetEntities()
    {
        lump_t lump        = lumps[0];
        string allEntities = "";

        stream.Position = lump.fileofs;

        for (int i = 0; i < lump.filelen; i++)
        {
            char nextChar = FileReader.readChar(stream);
            allEntities += nextChar;
        }

        return(allEntities);
    }
Пример #16
0
    public Vector3[] GetVertices()
    {
        lump_t lump = lumps[3];

        Vector3[] vertices = new Vector3[lump.filelen / 12];
        stream.Position = lump.fileofs;

        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i] = new Vector3(FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream));
        }

        lumpData[3] = vertices;
        return(vertices);
    }
Пример #17
0
    public int[] GetSurfedges()
    {
        lump_t lump = lumps[13];

        int[] surfedges = new int[lump.filelen / 4];
        stream.Position = lump.fileofs;

        for (int i = 0; i < lump.filelen / 4; i++)
        {
            surfedges[i] = FileReader.readInt(stream);
        }

        lumpData[13] = surfedges;
        return(surfedges);
    }
Пример #18
0
    public dplane_t[] GetPlanes()
    {
        lump_t lump = lumps[1];

        dplane_t[] planes = new dplane_t[lump.filelen / 20];
        stream.Position = lump.fileofs;

        for (int i = 0; i < planes.Length; i++)
        {
            planes[i].normal = new Vector3(FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream));
            planes[i].dist   = FileReader.readFloat(stream);
            planes[i].type   = FileReader.readInt(stream);
        }

        lumpData[1] = planes;
        return(planes);
    }
Пример #19
0
    public dbrush_t[] GetBrushes()
    {
        lump_t lump = lumps[18];

        dbrush_t[] brushes = new dbrush_t[lump.filelen / 12];
        stream.Position = lump.fileofs;

        for (int i = 0; i < brushes.Length; i++)
        {
            brushes[i].firstside = FileReader.readInt(stream);
            brushes[i].numsides  = FileReader.readInt(stream);
            brushes[i].contents  = FileReader.readInt(stream);
        }

        lumpData[18] = brushes;
        return(brushes);
    }
Пример #20
0
    public dedge_t[] GetEdges()
    {
        lump_t lump = lumps[12];

        dedge_t[] edges = new dedge_t[lump.filelen / 4];
        stream.Position = lump.fileofs;

        for (int i = 0; i < edges.Length; i++)
        {
            edges[i].v    = new ushort[2];
            edges[i].v[0] = FileReader.readUShort(stream);
            edges[i].v[1] = FileReader.readUShort(stream);
        }

        lumpData[12] = edges;
        return(edges);
    }
Пример #21
0
    public dDispVert[] GetDispVerts()
    {
        lump_t lump = lumps[33];

        dDispVert[] displacementVertices = new dDispVert[lump.filelen / 20];
        stream.Position = lump.fileofs;

        for (int i = 0; i < displacementVertices.Length; i++)
        {
            displacementVertices[i].vec   = new Vector3(FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream));
            displacementVertices[i].dist  = FileReader.readFloat(stream);
            displacementVertices[i].alpha = FileReader.readFloat(stream);
        }

        lumpData[33] = displacementVertices;
        return(displacementVertices);
    }
Пример #22
0
    public dbrushside_t[] GetBrushSides()
    {
        lump_t lump = lumps[19];

        dbrushside_t[] brushSides = new dbrushside_t[lump.filelen / 8];
        stream.Position = lump.fileofs;

        for (int i = 0; i < brushSides.Length; i++)
        {
            brushSides[i].planenum = FileReader.readUShort(stream);
            brushSides[i].texinfo  = FileReader.readShort(stream);
            brushSides[i].dispinfo = FileReader.readShort(stream);
            brushSides[i].bevel    = FileReader.readShort(stream);
        }

        lumpData[19] = brushSides;
        return(brushSides);
    }
Пример #23
0
        public virtual void Mod_LoadPlanes(lump_t l)
        {
            Int32 i, j;

            cplane_t[]      out_renamed;
            qfiles.dplane_t in_renamed;
            Int32           count;
            Int32           bits;

            if ((l.filelen % qfiles.dplane_t.SIZE) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count       = l.filelen / qfiles.dplane_t.SIZE;
            out_renamed = new cplane_t[count * 2];
            for (i = 0; i < count; i++)
            {
                out_renamed[i] = new cplane_t();
            }

            loadmodel.planes    = out_renamed;
            loadmodel.numplanes = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order = ByteOrder.LittleEndian;
            for (i = 0; i < count; i++)
            {
                bits       = 0;
                in_renamed = new dplane_t(bb);
                for (j = 0; j < 3; j++)
                {
                    out_renamed[i].normal[j] = in_renamed.normal[j];
                    if (out_renamed[i].normal[j] < 0)
                    {
                        bits |= (1 << j);
                    }
                }

                out_renamed[i].dist     = in_renamed.dist;
                out_renamed[i].type     = ( Byte )in_renamed.type;
                out_renamed[i].signbits = ( Byte )bits;
            }
        }
Пример #24
0
        public virtual void Mod_LoadEdges(lump_t l)
        {
            medge_t[] edges;
            Int32     i, count;

            if ((l.filelen % medge_t.DISK_SIZE) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count              = l.filelen / medge_t.DISK_SIZE;
            edges              = new medge_t[count + 1];
            loadmodel.edges    = edges;
            loadmodel.numedges = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order = ByteOrder.LittleEndian;
            for (i = 0; i < count; i++)
            {
                edges[i] = new medge_t(bb);
            }
        }
Пример #25
0
    public dtexdata_t[] GetTextureData()
    {
        lump_t lump = lumps[2];

        dtexdata_t[] textureData = new dtexdata_t[lump.filelen / 32];
        stream.Position = lump.fileofs;

        for (int i = 0; i < textureData.Length; i++)
        {
            Vector3 reflectivity = new Vector3(FileReader.readFloat(stream), FileReader.readFloat(stream), FileReader.readFloat(stream));
            textureData[i].reflectivity      = reflectivity;
            textureData[i].nameStringTableID = FileReader.readInt(stream);
            textureData[i].width             = FileReader.readInt(stream);
            textureData[i].height            = FileReader.readInt(stream);
            textureData[i].view_width        = FileReader.readInt(stream);
            textureData[i].view_height       = FileReader.readInt(stream);
        }

        lumpData[2] = textureData;
        return(textureData);
    }
Пример #26
0
    private void LoadGameLumps()
    {
        lump_t lump = lumps[35];

        stream.Position = lump.fileofs;

        //gameLumpHeader = new dgamelumpheader_t();
        gameLumpHeader.lumpCount = FileReader.readInt(stream);
        gameLumpHeader.gamelump  = new dgamelump_t[gameLumpHeader.lumpCount];

        for (int i = 0; i < gameLumpHeader.gamelump.Length; i++)
        {
            gameLumpHeader.gamelump[i]         = new dgamelump_t();
            gameLumpHeader.gamelump[i].id      = FileReader.readInt(stream);
            gameLumpHeader.gamelump[i].flags   = FileReader.readUShort(stream);
            gameLumpHeader.gamelump[i].version = FileReader.readUShort(stream);
            gameLumpHeader.gamelump[i].fileofs = FileReader.readInt(stream);
            gameLumpHeader.gamelump[i].filelen = FileReader.readInt(stream);
        }

        lumpData[35] = gameLumpHeader.gamelump;
    }
Пример #27
0
    public string GetTextureStringData()
    {
        lump_t lump = lumps[43];

        stream.Position = lump.fileofs;

        string textureStringData = "";

        for (int i = 0; i < lump.filelen; i++)
        {
            char nextChar = FileReader.readChar(stream);

            if (nextChar != '\0')
            {
                textureStringData += nextChar;
            }
            else
            {
                textureStringData += TEXTURE_STRING_DATA_SPLITTER;
            }
        }
        return(textureStringData);
    }
Пример #28
0
    void ReadHeader(DataStream ds)
    {
        var h = ds.readStruct <dheader_t>();

        if (h.version != 29)
        {
            throw new Exception("ERROR: BSP version " + this.header.version + " is currently unsupported.");
        }

        object boxed = h;

        // set count for marked lumps
        Type headerType = h.GetType();
        var  fields     = headerType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

        foreach (var field in fields)
        {
            if (field.FieldType != typeof(lump_t))
            {
                continue;
            }

            var targetAttribute = field.GetCustomAttribute <LumpTargetAttribute>();
            if (targetAttribute == null)
            {
                continue;
            }

            Type targetType = targetAttribute.target;

            lump_t lump = (lump_t)field.GetValue(boxed);
            lump.count = lump.filelen / SizeOf(targetType);
            field.SetValue(boxed, lump);
        }

        this.header = (dheader_t)boxed;
    }
Пример #29
0
    public dface_t[] GetFaces()
    {
        lump_t lump = lumps[7];

        dface_t[] faces = new dface_t[lump.filelen / 56];
        stream.Position = lump.fileofs;

        for (int i = 0; i < faces.Length; i++)
        {
            faces[i].planenum           = FileReader.readUShort(stream);
            faces[i].side               = FileReader.readByte(stream);
            faces[i].onNode             = FileReader.readByte(stream);
            faces[i].firstedge          = FileReader.readInt(stream);
            faces[i].numedges           = FileReader.readShort(stream);
            faces[i].texinfo            = FileReader.readShort(stream);
            faces[i].dispinfo           = FileReader.readShort(stream);
            faces[i].surfaceFogVolumeID = FileReader.readShort(stream);
            faces[i].styles             = new byte[4] {
                FileReader.readByte(stream), FileReader.readByte(stream), FileReader.readByte(stream), FileReader.readByte(stream)
            };
            faces[i].lightofs = FileReader.readInt(stream);
            faces[i].area     = FileReader.readFloat(stream);
            faces[i].LightmapTextureMinsInLuxels = new int[2] {
                FileReader.readInt(stream), FileReader.readInt(stream)
            };
            faces[i].LightmapTextureSizeInLuxels = new int[2] {
                FileReader.readInt(stream), FileReader.readInt(stream)
            };
            faces[i].origFace        = FileReader.readInt(stream);
            faces[i].numPrims        = FileReader.readUShort(stream);
            faces[i].firstPrimID     = FileReader.readUShort(stream);
            faces[i].smoothingGroups = FileReader.readUInt(stream);
        }

        lumpData[7] = faces;
        return(faces);
    }
Пример #30
0
 public dheader_t()
 {
     for (int kk = 0; kk < HEADER_LUMPS; kk++)
         lumps[kk] = new lump_t();
 }
Пример #31
0
 private void LoadLumps()
 {
     for (int i = 0; i < lumps.Length; i++)
     {
         lump_t lump = new lump_t();
         lump.fileofs = FileReader.readInt(stream);
         lump.filelen = FileReader.readInt(stream);
         lump.version = FileReader.readInt(stream);
         lump.fourCC = FileReader.readInt(stream);
         lumps[i] = lump;
     }
 }
Пример #32
0
        public virtual void Mod_LoadFaces(lump_t l)
        {
            qfiles.dface_t in_renamed;
            msurface_t[]   out_renamed;
            Int32          i, count, surfnum;
            Int32          planenum, side;
            Int32          ti;

            if ((l.filelen % qfiles.dface_t.SIZE) != 0)
            {
                Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            }
            count                 = l.filelen / qfiles.dface_t.SIZE;
            out_renamed           = new msurface_t[count];
            loadmodel.surfaces    = out_renamed;
            loadmodel.numsurfaces = count;
            ByteBuffer bb = ByteBuffer.Wrap(mod_base, l.fileofs, l.filelen);

            bb.Order     = ByteOrder.LittleEndian;
            currentmodel = loadmodel;
            GL_BeginBuildingLightmaps(loadmodel);
            for (surfnum = 0; surfnum < count; surfnum++)
            {
                in_renamed                     = new dface_t(bb);
                out_renamed[surfnum]           = new msurface_t();
                out_renamed[surfnum].firstedge = in_renamed.firstedge;
                out_renamed[surfnum].numedges  = in_renamed.numedges;
                out_renamed[surfnum].flags     = 0;
                out_renamed[surfnum].polys     = null;
                planenum = in_renamed.planenum;
                side     = in_renamed.side;
                if (side != 0)
                {
                    out_renamed[surfnum].flags |= Defines.SURF_PLANEBACK;
                }
                out_renamed[surfnum].plane = loadmodel.planes[planenum];
                ti = in_renamed.texinfo;
                if (ti < 0 || ti >= loadmodel.numtexinfo)
                {
                    Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: bad texinfo number");
                }
                out_renamed[surfnum].texinfo = loadmodel.texinfo[ti];
                CalcSurfaceExtents(out_renamed[surfnum]);
                for (i = 0; i < Defines.MAXLIGHTMAPS; i++)
                {
                    out_renamed[surfnum].styles[i] = in_renamed.styles[i];
                }
                i = in_renamed.lightofs;
                if (i == -1)
                {
                    out_renamed[surfnum].samples = null;
                }
                else
                {
                    ByteBuffer pointer = ByteBuffer.Wrap(loadmodel.lightdata);
                    pointer.Position = i;
                    pointer          = pointer.Slice();
                    pointer.Mark();
                    out_renamed[surfnum].samples = pointer;
                }

                if ((out_renamed[surfnum].texinfo.flags & Defines.SURF_WARP) != 0)
                {
                    out_renamed[surfnum].flags |= Defines.SURF_DRAWTURB;
                    for (i = 0; i < 2; i++)
                    {
                        out_renamed[surfnum].extents[i]     = 16384;
                        out_renamed[surfnum].texturemins[i] = -8192;
                    }

                    GL_SubdivideSurface(out_renamed[surfnum]);
                }

                if ((out_renamed[surfnum].texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) == 0)
                {
                    GL_CreateSurfaceLightmap(out_renamed[surfnum]);
                }
                if ((out_renamed[surfnum].texinfo.flags & Defines.SURF_WARP) == 0)
                {
                    GL_BuildPolygonFromSurface(out_renamed[surfnum]);
                }
            }

            GL_EndBuildingLightmaps();
        }
Пример #33
0
            public int mapRevision; // the map's revision (iteration, version) number

            #region Constructors

            public dheader_t(BinaryReader br)
            {
                ident=br.ReadInt32();
                version=br.ReadInt32();
                lumps = new lump_t[HEADER_LUMPS];
                for(int i=0 ; i<HEADER_LUMPS ; i++) {
                    lumps[i]=new lump_t(br);
                }
                mapRevision=br.ReadInt32();
            }