Esempio n. 1
0
        private void addWmoModel(string modelName, SlimDX.Vector3 pos)
        {
            MODF modf = new MODF();

            modf.flags    = 0;
            modf.lextentX = modf.lextentY = modf.lextentZ = 0;
            modf.padding  = 0;
            modf.Position = new Vector3(pos.X + Utils.Metrics.MidPoint, pos.Z, pos.Y + Utils.Metrics.MidPoint);
            modf.Rotation = Vector3.Zero;
            modf.setIndex = 0;
            modf.uextentX = modf.uextentY = modf.uextentZ = 0;
            modf.uniqueId = 0;
            modf.unknown  = 0;

            modf.idMWID = (uint)mParent.addWmoName(modelName);
            mWmoRefs.Add(mParent.addWmoDefintion(modf));
        }
Esempio n. 2
0
 public uint addWmoDefintion(MODF ddf)
 {
     WMODefinitions.Add(ddf);
     return((uint)(WMODefinitions.Count - 1));
 }
Esempio n. 3
0
        private void LoadAsyncData()
        {
            if (ReadSignature() != "RDHM")
            {
                return;
            }

            uint size = mpqFile.Read <uint>();

            if (size < MHDR.Size)
            {
                mLoadEvent.Set();
                return;
            }

            mHeader          = mpqFile.Read <MHDR>();
            mpqFile.Position = 0x14 + mHeader.ofsMcin;
            if (ReadSignature() != "NICM")
            {
                return;
            }

            size = mpqFile.Read <uint>();
            if (size != 16 * 256)
            {
                return;
            }

            for (uint i = 0; i < 256; ++i)
            {
                mOffsets[i] = mpqFile.Read <MCIN>();
            }

            mpqFile.Position = 0x14 + mHeader.ofsMtex;
            if (ReadSignature() != "XETM")
            {
                return;
            }

            size = mpqFile.Read <uint>();
            byte[] strData = mpqFile.Read(size);
            string str     = Encoding.UTF8.GetString(strData);

            mTextureNames = str.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);

            Game.GameManager.GraphicsThread.CallOnThread(
                () =>
            {
                foreach (var tex in mTextureNames)
                {
                    if (tex.Length > 0)
                    {
                        mTextures.Add(Video.TextureManager.GetTexture(tex));
                    }
                }
            }
                );

            mpqFile.Position = 0x14 + mHeader.ofsMmdx + 0x04;
            size             = mpqFile.Read <uint>();
            byte[] data    = mpqFile.Read((uint)size);
            string fullStr = Encoding.UTF8.GetString(data);

            string[] Names = fullStr.Split('\0');
            var      qry   = (from string n in Names where n != "" select n);
            uint     ofs   = 0;

            foreach (var s in qry)
            {
                var stri = s.Replace(".mdx", ".m2");
                stri = stri.Replace(".MDX", ".M2");
                DoodadNames.Add(ofs, stri);
                ofs += (uint)s.Length + 1;
            }

            mpqFile.Position = 0x14 + mHeader.ofsMddf + 0x04;
            size             = mpqFile.Read <uint>();
            uint ssize            = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(MDDF));
            uint numEntries       = size / ssize;
            var  DoodadPlacements = new MDDF[numEntries];

            mpqFile.Read(DoodadPlacements);

            mpqFile.Position = 0x14 + mHeader.ofsMmid + 0x04;
            size             = mpqFile.Read <uint>();
            numEntries       = size / 4;
            var DoodadIds = new uint[numEntries];

            mpqFile.Read(DoodadIds);

            ModelDefinitions = DoodadPlacements.ToList();
            ModelIdentifiers = DoodadIds.ToList();

            mpqFile.Position = 0x14 + mHeader.ofsMwmo + 0x04;
            size             = mpqFile.Read <uint>();
            data             = mpqFile.Read(size);
            fullStr          = Encoding.UTF8.GetString(data);
            Names            = fullStr.Split('\0');
            qry = from n in Names where n != "" select n;
            ofs = 0;

            foreach (var s in qry)
            {
                WMONames.Add(ofs, s);
                ofs += (uint)s.Length + 1;
            }

            mpqFile.Position = 0x14 + mHeader.ofsModf + 0x04;
            size             = mpqFile.Read <uint>();
            ssize            = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(MODF));
            numEntries       = size / ssize;
            var WmoPlacements = new MODF[numEntries];

            mpqFile.Read(WmoPlacements);

            mpqFile.Position = 0x14 + mHeader.ofsMwid + 0x04;
            size             = mpqFile.Read <uint>();
            numEntries       = size / 4;
            var WmoIds = new uint[numEntries];

            mpqFile.Read(WmoIds);

            WMODefinitions = WmoPlacements.ToList();
            WMOIdentifiers = WmoIds.ToList();

            List <ADTChunk> chunks = new List <ADTChunk>();

            for (uint i = 0; i < 256; ++i)
            {
                ADTChunk chunk = new ADTChunk(this, mpqFile, mOffsets[i]);
                if (chunk.PreLoadChunk())
                {
                    chunks.Add(chunk);
                }
            }

            lock (mChunks) mChunks.AddRange(chunks);
        }
Esempio n. 4
0
        private void addWmoModel(string modelName, SlimDX.Vector3 pos)
        {
            MODF modf = new MODF();
            modf.flags = 0;
            modf.lextentX = modf.lextentY = modf.lextentZ = 0;
            modf.padding = 0;
            modf.Position = new Vector3(pos.X + Utils.Metrics.MidPoint, pos.Z, pos.Y + Utils.Metrics.MidPoint);
            modf.Rotation = Vector3.Zero;
            modf.setIndex = 0;
            modf.uextentX = modf.uextentY = modf.uextentZ = 0;
            modf.uniqueId = 0;
            modf.unknown = 0;

            modf.idMWID = (uint)mParent.addWmoName(modelName);
            mWmoRefs.Add(mParent.addWmoDefintion(modf));
        }
Esempio n. 5
0
        private void LoadAsyncData()
        {
            if (ReadSignature() != "RDHM")
                return;

            uint size = mpqFile.Read<uint>();
            if (size < MHDR.Size)
            {
                mLoadEvent.Set();
                return;
            }

            mHeader = mpqFile.Read<MHDR>();
            mpqFile.Position = 0x14 + mHeader.ofsMcin;
            if (ReadSignature() != "NICM")
            {
                return;
            }

            size = mpqFile.Read<uint>();
            if (size != 16 * 256)
            {
                return;
            }

            for (uint i = 0; i < 256; ++i)
            {
                mOffsets[i] = mpqFile.Read<MCIN>();
            }

            mpqFile.Position = 0x14 + mHeader.ofsMtex;
            if (ReadSignature() != "XETM")
            {
                return;
            }

            size = mpqFile.Read<uint>();
            byte[] strData = mpqFile.Read(size);
            string str = Encoding.UTF8.GetString(strData);
            mTextureNames = str.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);

            Game.GameManager.GraphicsThread.CallOnThread(
                () =>
                {
                    foreach (var tex in mTextureNames)
                    {
                        if (tex.Length > 0)
                            mTextures.Add(Video.TextureManager.GetTexture(tex));
                    }
                }
            );

            mpqFile.Position = 0x14 + mHeader.ofsMmdx + 0x04;
            size = mpqFile.Read<uint>();
            byte[] data = mpqFile.Read((uint)size);
            string fullStr = Encoding.UTF8.GetString(data);
            string[] Names = fullStr.Split('\0');
            var qry = (from string n in Names where n != "" select n);
            uint ofs = 0;
            foreach (var s in qry)
            {
                var stri = s.Replace(".mdx", ".m2");
                stri = stri.Replace(".MDX", ".M2");
                DoodadNames.Add(ofs, stri);
                ofs += (uint)s.Length + 1;
            }

            mpqFile.Position = 0x14 + mHeader.ofsMddf + 0x04;
            size = mpqFile.Read<uint>();
            uint ssize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(MDDF));
            uint numEntries = size / ssize;
            var DoodadPlacements = new MDDF[numEntries];
            mpqFile.Read(DoodadPlacements);

            mpqFile.Position = 0x14 + mHeader.ofsMmid + 0x04;
            size = mpqFile.Read<uint>();
            numEntries = size / 4;
            var DoodadIds = new uint[numEntries];
            mpqFile.Read(DoodadIds);

            ModelDefinitions = DoodadPlacements.ToList();
            ModelIdentifiers = DoodadIds.ToList();

            mpqFile.Position = 0x14 + mHeader.ofsMwmo + 0x04;
            size = mpqFile.Read<uint>();
            data = mpqFile.Read(size);
            fullStr = Encoding.UTF8.GetString(data);
            Names = fullStr.Split('\0');
            qry = from n in Names where n != "" select n;
            ofs = 0;

            foreach (var s in qry)
            {
                WMONames.Add(ofs, s);
                ofs += (uint)s.Length + 1;
            }

            mpqFile.Position = 0x14 + mHeader.ofsModf + 0x04;
            size = mpqFile.Read<uint>();
            ssize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(MODF));
            numEntries = size / ssize;
            var WmoPlacements = new MODF[numEntries];
            mpqFile.Read(WmoPlacements);

            mpqFile.Position = 0x14 + mHeader.ofsMwid + 0x04;
            size = mpqFile.Read<uint>();
            numEntries = size / 4;
            var WmoIds = new uint[numEntries];
            mpqFile.Read(WmoIds);

            WMODefinitions = WmoPlacements.ToList();
            WMOIdentifiers = WmoIds.ToList();

            List<ADTChunk> chunks = new List<ADTChunk>();

            for (uint i = 0; i < 256; ++i)
            {
                ADTChunk chunk = new ADTChunk(this, mpqFile, mOffsets[i]);
                if (chunk.PreLoadChunk())
                {
                    chunks.Add(chunk);
                }
            }

            lock (mChunks) mChunks.AddRange(chunks);
        }
Esempio n. 6
0
 public uint addWmoDefintion(MODF ddf)
 {
     WMODefinitions.Add(ddf);
     return (uint)(WMODefinitions.Count - 1);
 }