bspdispinfo[] ReadDispInfo() { br.BaseStream.Seek(header.lumps [SourceBSPStructs.LUMP_DISPINFO].fileofs, SeekOrigin.Begin); int dispinfoCount = header.lumps [SourceBSPStructs.LUMP_DISPINFO].filelen / 176; bspdispinfo[] temp = new bspdispinfo[dispinfoCount]; for (int i = 0; i < dispinfoCount; i++) { temp[i].startPosition = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)); temp[i].DispVertStart = br.ReadInt32(); temp[i].DispTriStart = br.ReadInt32(); temp[i].power = br.ReadInt32(); temp[i].minTess = br.ReadInt32(); temp[i].smoothingAngle = br.ReadSingle(); //32 temp[i].contents = br.ReadInt32(); temp[i].MapFace = br.ReadUInt32(); temp[i].LightmapAlphaStart = br.ReadInt32(); temp[i].LightmapSamplePositionStart = br.ReadInt32(); //46b br.BaseStream.Seek(128, SeekOrigin.Current); //temp[i].EdgeNeighbors = ReadDispNeighbor(4);//40b //temp[i].CornerNeighbors = ReadDispCornerNeighbors(4);//36b //br.BaseStream.Seek(40,SeekOrigin.Current);//40b } tempLog += ("Load: " + dispinfoCount + " DispInfos \n"); Debug.Log("Load: " + dispinfoCount + " DispInfos "); return(temp); }
bsptexinfo[] ReadTexInfos() { br.BaseStream.Seek(header.lumps [SourceBSPStructs.LUMP_TEXINFO].fileofs, SeekOrigin.Begin); int numTexinfos = header.lumps [SourceBSPStructs.LUMP_TEXINFO].filelen / 72; bsptexinfo[] temp = new bsptexinfo[numTexinfos]; for (int i = 0; i < numTexinfos; i++) { bsptexinfo texinfo = new bsptexinfo(); texinfo.texvecs = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)); texinfo.texoffs = br.ReadSingle(); texinfo.texvect = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)); texinfo.texofft = br.ReadSingle(); texinfo.lightvecs = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)); texinfo.lightoffs = br.ReadSingle(); texinfo.lightvect = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)); texinfo.lightofft = br.ReadSingle(); texinfo.flags = br.ReadInt32(); texinfo.texdata = br.ReadInt32(); temp[i] = texinfo; } tempLog += ("Load: " + numTexinfos + " TexInfos \n"); return(temp); }
bspStaticPropLump[] ReadStaticProps(bspgamelump gl) { bspStaticPropLump[] temp = new bspStaticPropLump[StaticPropCount]; for (int i = 0; i < StaticPropCount; i++) { bspStaticPropLump prop = new bspStaticPropLump(); if (gl.version >= 4) { //4 prop.Origin = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)) * uSrcSettings.Inst.worldScale; Vector3 ang = ConvertUtils.ReadVector3(br); prop.Angles = new Vector3(-ang.z, -ang.y, -ang.x); prop.PropType = (int)br.ReadUInt16(); /*prop.FirstLeaf=br.ReadUInt16(); * prop.LeafCount=br.ReadUInt16(); * prop.Solid=br.ReadChar(); * prop.Flags=br.ReadChar();*/ br.BaseStream.Seek(6, SeekOrigin.Current); prop.Skin = br.ReadInt32(); prop.FadeMinDist = br.ReadSingle(); prop.FadeMaxDist = br.ReadSingle(); prop.LightingOrigin = ConvertUtils.ReadVector3(br); } if (gl.version >= 5) { prop.ForcedFadeScale = br.ReadSingle(); //br.BaseStream.Seek(12,SeekOrigin.Current); } if (gl.version >= 6 & gl.version < 8) { prop.MinDXLevel = br.ReadUInt16(); prop.MaxDXLevel = br.ReadUInt16(); } if (gl.version >= 8) { prop.minCPULevel = br.ReadByte(); prop.maxCPULevel = br.ReadByte(); prop.minGPULevel = br.ReadByte(); prop.maxGPULevel = br.ReadByte(); prop.diffuseModulation = new Color32(br.ReadByte(), br.ReadByte(), br.ReadByte(), br.ReadByte()); } if (gl.version >= 9) { //prop.DisableX360=br.ReadBoolean(); br.BaseStream.Seek(4, SeekOrigin.Current); } temp[i] = prop; } return(temp); }
Vector3[] ReadVertexes() { br.BaseStream.Seek(header.lumps [SourceBSPStructs.LUMP_VERTEXES].fileofs, SeekOrigin.Begin); int numVerts = header.lumps [SourceBSPStructs.LUMP_VERTEXES].filelen / 12; Vector3[] temp = new Vector3[numVerts]; for (int i = 0; i < numVerts; i++) { temp[i] = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)); } tempLog += ("Load: " + numVerts + " Vertexes \n"); return(temp); }
bspDispVert[] ReadDispVerts() { br.BaseStream.Seek(header.lumps [SourceBSPStructs.LUMP_DISP_VERTS].fileofs, SeekOrigin.Begin); int dispVertCount = header.lumps [SourceBSPStructs.LUMP_DISP_VERTS].filelen / 20; bspDispVert[] temp = new bspDispVert[dispVertCount]; for (int i = 0; i < dispVertCount; i++) { bspDispVert vert = new bspDispVert(); vert.vec = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)); vert.dist = br.ReadSingle(); vert.alpha = br.ReadSingle(); temp[i] = vert; } tempLog += ("Load: " + dispVertCount + " DispVerts \n"); Debug.Log("Load: " + dispVertCount + " DispVerts "); return(temp); }
bspmodel[] ReadModels() { br.BaseStream.Seek(header.lumps [SourceBSPStructs.LUMP_MODELS].fileofs, SeekOrigin.Begin); int modelCount = header.lumps [SourceBSPStructs.LUMP_MODELS].filelen / 48; bspmodel[] temp = new bspmodel[modelCount]; for (int i = 0; i < modelCount; i++) { bspmodel model = new bspmodel(); model.mins = ConvertUtils.ReadVector3(br); model.maxs = ConvertUtils.ReadVector3(br); model.origin = ConvertUtils.FlipVector(ConvertUtils.ReadVector3(br)); model.headnode = br.ReadInt32(); model.firstface = br.ReadInt32(); model.numfaces = br.ReadInt32(); temp[i] = model; } tempLog += ("Load: " + modelCount + " Models \n"); return(temp); }