Esempio n. 1
0
        public void Read()
        {
            foreach (var subChunk in Data.Chunks)
            {
                switch (subChunk.Name)
                {
                case "MOHD":
                    MOHD = new MOHD(subChunk);
                    break;

                case "MOGN":
                    MOGN = new MOGN(subChunk);
                    break;

                case "MOGI":
                    MOGI = new MOGI(subChunk);
                    break;

                case "MODD":
                    MODD = new MODD(subChunk);
                    break;

                case "MODN":
                    MODN = new MODN(subChunk);
                    break;

                case "MODS":
                    MODS = new MODS(subChunk);
                    break;
                }
            }

            ReadGroups();
        }
Esempio n. 2
0
        public MOHD ReadMOHDChunk(BlizzHeader chunk, BinaryReader bin, string filename)
        {
            //Header for the map object. 64 bytes.
            // var MOHDChunk = bin.ReadBytes((int)chunk.Size);
            var header = new MOHD();

            header.nMaterials = bin.ReadUInt32();
            header.nGroups    = bin.ReadUInt32();
            header.nPortals   = bin.ReadUInt32();
            header.nLights    = bin.ReadUInt32();
            header.nModels    = bin.ReadUInt32();

            //Console.WriteLine("         " + nGroups.ToString() + " group(s)");

            return(header);
        }
Esempio n. 3
0
        private MOHD ReadMOHDChunk(BinaryReader bin, string filename)
        {
            //Header for the map object. 64 bytes.
            var header = new MOHD()
            {
                nMaterials   = bin.ReadUInt32(),
                nGroups      = bin.ReadUInt32(),
                nPortals     = bin.ReadUInt32(),
                nLights      = bin.ReadUInt32(),
                nModels      = bin.ReadUInt32(),
                nDoodads     = bin.ReadUInt32(),
                nSets        = bin.ReadUInt32(),
                ambientColor = bin.ReadUInt32(),
                areaTableID  = bin.ReadUInt32()
            };

            return(header);
        }
Esempio n. 4
0
        public void Read(byte[] data)
        {
            // Clear chunks to prevent double data.
            Chunks.Clear();

            using (var stream = new MemoryStream(data))
                using (var reader = new BinaryReader(stream))
                {
                    while (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        var chunkId   = (WMOChunkId)reader.ReadUInt32();
                        var chunkSize = reader.ReadUInt32();

                        var chunkData = new byte[chunkSize];
                        Buffer.BlockCopy(stream.ToArray(), (int)reader.BaseStream.Position, chunkData, 0, (int)chunkSize);

                        IChunk chunk = null;
                        switch (chunkId)
                        {
                        case WMOChunkId.MVER: chunk = new MVER(); break;

                        case WMOChunkId.MOHD: chunk = new MOHD(); break;

                        case WMOChunkId.MOTX: chunk = new MOTX(); break;

                        case WMOChunkId.MOMT: chunk = new MOMT(); break;

                        case WMOChunkId.MOGN: chunk = new MOGN(); break;

                        case WMOChunkId.MOGI: chunk = new MOGI(); break;

                        case WMOChunkId.MOPV: chunk = new MOPV(); break;

                        case WMOChunkId.MOPT: chunk = new MOPT(); break;

                        case WMOChunkId.MOPR: chunk = new MOPR(); break;

                        case WMOChunkId.MOLT: chunk = new MOLT(); break;

                        case WMOChunkId.MODS: chunk = new MODS(); break;

                        case WMOChunkId.MODI: chunk = new MODI(); break;

                        case WMOChunkId.MODD: chunk = new MODD(); break;

                        case WMOChunkId.MFOG: chunk = new MFOG(); break;

                        default: Console.WriteLine($"Skipping {chunkId} (0x{(uint)chunkId:X})"); break;
                        }

                        if (chunk != null)
                        {
                            chunk.Read(chunkData);
                            Chunks.Add(chunk);
                        }

                        reader.BaseStream.Position += chunkSize;
                    }

                    // Add mandatory chunks.
                    Chunks.Add(new MOSB());
                    Chunks.Add(new MOVV());
                    Chunks.Add(new MOVB());

                    // Close the streams so they can be written.
                    reader.Close();
                    stream.Close();
                }
        }