public void LoadBSP(BinaryReader br) { int cnt; this.header = new dheader_t(br); //Loading planes cnt = (this.header.lumps [(int)lumpTypes.LUMP_PLANES].filelen) / STRUCT_PLANE_SIZE; planes = new dplane_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_PLANES].fileofs, SeekOrigin.Begin); for (int i = 0; i < cnt; i++) { planes [i] = new dplane_t(br); } //Loading BSP nodes cnt = (this.header.lumps [(int)lumpTypes.LUMP_NODES].filelen) / STRUCT_BSPNODE_SIZE; bspnodes = new dnode_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_NODES].fileofs, SeekOrigin.Begin); for (int i = 0; i < cnt; i++) { bspnodes [i] = new dnode_t(br); } //Loading BSP leaves cnt = (this.header.lumps [(int)lumpTypes.LUMP_LEAFS].filelen) / STRUCT_BSPLEAF_SIZE; bspleaves = new dleaf_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_LEAFS].fileofs, SeekOrigin.Begin); for (int i = 0; i < cnt; i++) { bspleaves [i] = new dleaf_t(br); } //Loading texinfo cnt = (this.header.lumps [(int)lumpTypes.LUMP_TEXINFO].filelen) / STRUCT_TEXINFO_SIZE; texinfos = new texinfo_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_TEXINFO].fileofs, SeekOrigin.Begin); for (int i = 0; i < cnt; i++) { texinfos [i] = new texinfo_t(br); } //Loading texdata cnt = (this.header.lumps [(int)lumpTypes.LUMP_TEXDATA].filelen) / STRUCT_TEXDATA_SIZE; texdata = new dtexdata_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_TEXDATA].fileofs, SeekOrigin.Begin); for (int i = 0; i < cnt; i++) { texdata [i] = new dtexdata_t(br); } //Loading TexdataStringTable cnt = (this.header.lumps [(int)lumpTypes.LUMP_TEXDATA_STRING_TABLE].filelen) / 4; TexdataStringTable = new int[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_TEXDATA_STRING_TABLE].fileofs, SeekOrigin.Begin); for (int i = 0; i < cnt; i++) { TexdataStringTable [i] = br.ReadInt32(); } //Loading TexdataStringData cnt = (this.header.lumps [(int)lumpTypes.LUMP_TEXDATA_STRING_DATA].filelen) / 1; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_TEXDATA_STRING_DATA].fileofs, SeekOrigin.Begin); TexdataStringData = br.ReadChars(cnt); }
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); }
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; } }
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; }
public void LoadBSP(BinaryReader br) { int cnt; this.header = new dheader_t (br); //Loading planes cnt = (this.header.lumps [(int)lumpTypes.LUMP_PLANES].filelen) / STRUCT_PLANE_SIZE; planes=new dplane_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_PLANES].fileofs, SeekOrigin.Begin); for(int i=0 ; i<cnt ; i++) { planes [i] = new dplane_t (br); } //Loading BSP nodes cnt = (this.header.lumps [(int)lumpTypes.LUMP_NODES].filelen) / STRUCT_BSPNODE_SIZE; bspnodes=new dnode_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_NODES].fileofs, SeekOrigin.Begin); for(int i=0 ; i<cnt ; i++) { bspnodes [i] = new dnode_t (br); } //Loading BSP leaves cnt = (this.header.lumps [(int)lumpTypes.LUMP_LEAFS].filelen) / STRUCT_BSPLEAF_SIZE; bspleaves=new dleaf_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_LEAFS].fileofs, SeekOrigin.Begin); for(int i=0 ; i<cnt ; i++) { bspleaves [i] = new dleaf_t (br); } //Loading texinfo cnt = (this.header.lumps [(int)lumpTypes.LUMP_TEXINFO].filelen) / STRUCT_TEXINFO_SIZE; texinfos=new texinfo_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_TEXINFO].fileofs, SeekOrigin.Begin); for(int i=0 ; i<cnt ; i++) { texinfos [i] = new texinfo_t (br); } //Loading texdata cnt = (this.header.lumps [(int)lumpTypes.LUMP_TEXDATA].filelen) / STRUCT_TEXDATA_SIZE; texdata=new dtexdata_t[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_TEXDATA].fileofs, SeekOrigin.Begin); for(int i=0 ; i<cnt ; i++) { texdata [i] = new dtexdata_t (br); } //Loading TexdataStringTable cnt = (this.header.lumps [(int)lumpTypes.LUMP_TEXDATA_STRING_TABLE].filelen) / 4; TexdataStringTable=new int[cnt]; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_TEXDATA_STRING_TABLE].fileofs, SeekOrigin.Begin); for(int i=0 ; i<cnt ; i++) { TexdataStringTable [i] = br.ReadInt32(); } //Loading TexdataStringData cnt = (this.header.lumps [(int)lumpTypes.LUMP_TEXDATA_STRING_DATA].filelen) / 1; br.BaseStream.Seek(this.header.lumps [(int)lumpTypes.LUMP_TEXDATA_STRING_DATA].fileofs, SeekOrigin.Begin); TexdataStringData=br.ReadChars(cnt); }