private void AsyncLoadProc() { mFile = new Stormlib.MPQFile(FileName); SeekChunk("DHOM"); mFile.Position += 4; mHeader = mFile.Read <MOHD>(); BoundingBox = new SlimDX.BoundingBox(new SlimDX.Vector3(mHeader.MinPosition.X, mHeader.MinPosition.Y, mHeader.MinPosition.Z), new SlimDX.Vector3(mHeader.MaxPosition.X, mHeader.MaxPosition.Y, mHeader.MaxPosition.Z)); SeekChunk("XTOM"); uint numBytes = mFile.Read <uint>(); byte[] texData = mFile.Read(numBytes); var fullStr = Encoding.UTF8.GetString(texData); var textures = fullStr.Split('\0'); uint curPos = 0; foreach (var tex in textures) { if (tex != "") { mTextureNames.Add(curPos, tex); } curPos += (uint)tex.Length + 1; } SeekChunk("TMOM"); mFile.Position += 4; for (uint i = 0; i < mHeader.nMaterials; ++i) { MOMT mat = mFile.Read <MOMT>(); mMaterials.Add(mat); } Game.GameManager.GraphicsThread.CallOnThread( () => { foreach (var mat in mMaterials) { if (mCustomTextureMgr == null) { mTextures.Add(Video.TextureManager.GetTexture(mTextureNames[mat.ofsTexture1])); } else { mTextures.Add(mCustomTextureMgr.LoadTexture(mTextureNames[mat.ofsTexture1])); } } } ); SeekChunk("IGOM"); mFile.Position += 4; for (uint i = 0; i < mHeader.nGroups; ++i) { MOGI mogi = mFile.Read <MOGI>(); mGroupInfos.Add(mogi); WMOGroup group = new WMOGroup(FileName, i, this); if (group.LoadGroup()) { lock (mGroups) mGroups.Add(group); } } isLoadFinished = true; }
public WMOMaterial(MOMT mat) { mMaterial = mat; }