ScanMetaItems() public method

The scan meta items.
public ScanMetaItems ( bool manual, bool parsed ) : void
manual bool The manual.
parsed bool The parsed.
return void
Ejemplo n.º 1
0
        /// <summary>
        /// The load bsp. The BSP is loaded into memory.
        /// </summary>
        /// <param name="BSPNum">The bsp num.</param>
        /// <remarks></remarks>
        private void loadBSP(int BSPId)
        {
            this.Cursor = Cursors.WaitCursor;
            //// Load the BSP viewer
            Meta meta = new Meta(map);
            meta.TagIndex = BSPId; // load BSP into MemoryStream (MS)
            meta.ScanMetaItems(true, false);
            BSPModel bsp = new BSPModel(ref meta);
            this.Cursor = Cursors.Arrow;
            if (bsp.BspNumber != -1)
            {
                BSPViewer bv = new BSPViewer(bsp, map);
                bv.Dispose();
                bv = null;
            }

            meta.Dispose();
            GC.Collect();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The get meta from tag index.
        /// </summary>
        /// <param name="tag">The tag.</param>
        /// <param name="map">The map.</param>
        /// <param name="manualScan">The manual scan.</param>
        /// <param name="parse">The parse.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static Meta GetMetaFromTagIndex(int tag, Map map, bool manualScan, bool parse)
        {
            map.OpenMap(MapTypes.Internal);

            Meta meta = new Meta(map);

            meta.TagIndex = tag;
            meta.ScanMetaItems(manualScan, parse);

            map.CloseMap();

            meta.SortItemsByOffset();

            return meta;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The h 2 bsp write raw data meta chunk.
        /// </summary>
        /// <param name="chunknumber">The chunknumber.</param>
        /// <param name="bsp">The bsp.</param>
        /// <param name="BSPNum">The bsp num.</param>
        /// <remarks></remarks>
        public void H2BSPWriteRawDataMetaChunk(int chunknumber, ref BSPModel bsp, int BSPNum)
        {
            BSPModel.BSPRawDataMetaChunk bspChunk = bsp.BSPRawDataMetaChunks[chunknumber];

            int BSPId = map.Functions.ForMeta.FindMetaByID(map.BSP.sbsp[BSPNum].ident);

            Meta meta = new Meta(map);
            meta.TagIndex = BSPId; // decides which tag to load into MemoryStream (MS)
            meta.ScanMetaItems(true, false);

            BinaryWriter BW = new BinaryWriter(meta.MS);
            BinaryReader BR = new BinaryReader(meta.MS);
            int temp = 0;

            BW.BaseStream.Position = bsp.BSPRawDataMetaChunksOffset;
            BW.Write(bspChunk.VerticeCount);
            BW.Write(bspChunk.FaceCount);
            BW.BaseStream.Position = bsp.BSPRawDataMetaChunksOffset + 48;
            BW.Write(bspChunk.HeaderSize - 8);

            BW.BaseStream.Position = bsp.BSPRawDataMetaChunksOffset + 52;
            temp = BR.ReadInt32(); // I dunno what this is or what value it is supposed to be! #1232
            BW.BaseStream.Position = bsp.BSPRawDataMetaChunksOffset + 52;
            BW.Write(temp); // I dunno what this is or what value it is supposed to be!

            BW.BaseStream.Position = bsp.BSPRawDataMetaChunksOffset + 56;
            BW.Write(bspChunk.RawDataChunkInfo.Length);

            BW.Write(bspChunk.rawdatainfooffset + meta.magic + meta.offset);

            // SO FAR SO GOOD UP TILL NOW!
            // this.RawDataChunkInfo = new RawDataOffsetChunk[tempc];
            int tempr = bspChunk.rawdatainfooffset;
            for (int x = 0; x < bspChunk.RawDataChunkInfo.Length; x++)
            {
                // this.RawDataChunkInfo[x] = new RawDataOffsetChunk();
                BW.BaseStream.Position = tempr + (x * 16) + 6;
                BW.Write((UInt16)bspChunk.RawDataChunkInfo[x].ChunkSize);
                BW.Write(bspChunk.RawDataChunkInfo[x].Size);

                // I think this may be a safety for a messed up map?
                // if (bspChunk.RawDataChunkInfo[x].ChunkSize == bspChunk.RawDataChunkInfo[x].Size) { bspChunk.RawDataChunkInfo[x].ChunkSize = 0; }
                BW.Write(bspChunk.RawDataChunkInfo[x].Offset);
            }

            BW = map.BW;
            BW.BaseStream.Position = meta.offset;
            BW.Write(meta.MS.GetBuffer(), 0, meta.size);

            if (bspChunk.RawDataChunkInfo.Length == 0)
            {
                return;
            }

            /*
                BW = new BinaryWriter(((RawDataChunk)meta.raw.rawChunks[chunknumber]).MS);
                bspChunk.SubMeshInfo = new ModelSubMeshInfo[bspChunk.RawDataChunkInfo[0].ChunkCount];
                for (int x = 0; x < bspChunk.RawDataChunkInfo[0].ChunkCount; x++)
                {
                    bspChunk.SubMeshInfo[x] = new ModelSubMeshInfo();
                    BR.BaseStream.Position = bspChunk.HeaderSize + bspChunk.RawDataChunkInfo[0].Offset + (x * 72) + 4;
                    bspChunk.SubMeshInfo[x].ShaderNumber = BR.ReadUInt16();
                    bspChunk.SubMeshInfo[x].IndiceStart = BR.ReadUInt16();
                    bspChunk.SubMeshInfo[x].IndiceCount = BR.ReadUInt16();

                }

                BR.BaseStream.Position = 40;
                bspChunk.IndiceCount = BR.ReadUInt16();
                int indicechunk = 0;
                int verticechunk = 0;
                int uvchunk = 0;
                for (int x = 0; x < RawDataChunkInfo.Length; x++)
                {
                    if (RawDataChunkInfo[x].ChunkSize == 2)
                    {
                        indicechunk = x;
                        break;
                    }
                }
                int normalchunk = 0;
                for (int x = indicechunk; x < RawDataChunkInfo.Length; x++)
                {
                    if (RawDataChunkInfo[x].ChunkCount == 1)
                    {
                        verticechunk = x;
                        uvchunk = x + 1;
                        normalchunk = x + 2;
                        break;
                    }
                }
                bspChunk.Indices = new short[bspChunk.RawDataChunkInfo[indicechunk].ChunkCount];
                BR.BaseStream.Position = bspChunk.HeaderSize + bspChunk.RawDataChunkInfo[indicechunk].Offset;
                for (int x = 0; x < bspChunk.IndiceCount; x++)
                {
                    bspChunk.Indices[x] = (short)BR.ReadUInt16();

                }

                bspChunk.RawDataChunkInfo[verticechunk].ChunkSize = bspChunk.RawDataChunkInfo[verticechunk].Size / VerticeCount;
                for (int x = 0; x < bspChunk.VerticeCount; x++)
                {
                    Vector3 vec = new Vector3();
                    BR.BaseStream.Position = bspChunk.HeaderSize + bspChunk.RawDataChunkInfo[verticechunk].Offset + (bspChunk.RawDataChunkInfo[verticechunk].ChunkSize * x);
                    vec.X = BR.ReadSingle();
                    vec.Y = BR.ReadSingle();
                    vec.Z = BR.ReadSingle();
                    Vertices.Add(vec);
                }

                bspChunk.RawDataChunkInfo[uvchunk].ChunkSize = 8;
                for (int x = 0; x < bspChunk.VerticeCount; x++)
                {
                    Vector2 tempuv = new Vector2();
                    BR.BaseStream.Position = bspChunk.HeaderSize + bspChunk.RawDataChunkInfo[uvchunk].Offset + (bspChunk.RawDataChunkInfo[uvchunk].ChunkSize * x);
                    tempuv.X = BR.ReadSingle();
                    tempuv.Y = BR.ReadSingle();
                    bspChunk.UVs.Add(tempuv);
                }

                bspChunk.RawDataChunkInfo[normalchunk].ChunkSize = 12;
                for (int x = 0; x < bspChunk.VerticeCount; x++)
                {
                    Vector2 tempuv = new Vector2();
                    BR.BaseStream.Position = bspChunk.HeaderSize + bspChunk.RawDataChunkInfo[normalchunk].Offset + (bspChunk.RawDataChunkInfo[normalchunk].ChunkSize * x);
                    Vector3 normal = Raw.ParsedModel.DecompressNormal(BR.ReadInt32());
                    bspChunk.Normals.Add(normal);
                    Vector3 binormal = Raw.ParsedModel.DecompressNormal(BR.ReadInt32());
                    bspChunk.Binormals.Add(binormal);
                    Vector3 tangent = Raw.ParsedModel.DecompressNormal(BR.ReadInt32());
                    bspChunk.Tangents.Add(tangent);
                }

                int lightmapuvchunk = -1;
                for (int x = normalchunk + 1; x < RawDataChunkInfo.Length; x++)
                {
                    if (RawDataChunkInfo[x].ChunkSize == 3)
                    {
                        lightmapuvchunk = x;
                        break;
                    }
                }

                if (lightmapuvchunk == -1) return;
                RawDataChunkInfo[lightmapuvchunk].ChunkSize = 4;
                for (int x = 0; x < bspChunk.VerticeCount; x++)
                {
                    Vector2 tempuv = new Vector2();
                    BR.BaseStream.Position = bspChunk.HeaderSize + bspChunk.RawDataChunkInfo[lightmapuvchunk].Offset + (bspChunk.RawDataChunkInfo[lightmapuvchunk].ChunkSize * x);
                    short testx = BR.ReadInt16();
                    float u = DecompressVertice(Convert.ToSingle(testx), -1, 1);
                    testx = BR.ReadInt16();
                    float v = DecompressVertice(Convert.ToSingle(testx), -1, 1);
                     Vector2 uv2 = new Vector2(u, v);
                    bspChunk.LightMapUVs.Add(uv2);
                }
            */
        }