/// <summary> /// Acquires a new or used alpha texture from the ADTAlphaHandler and then loads the surface with AlphaData /// </summary> private void LoadAlphaTexture() { mAlphaTexture = ADTAlphaHandler.FreeTexture(); if (mAlphaTexture == null) { mAlphaTexture = new SlimDX.Direct3D9.Texture(Game.GameManager.GraphicsThread.GraphicsManager.Device, 64, 64, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); } Surface baseSurf = mAlphaTexture.GetSurfaceLevel(0); System.Drawing.Rectangle rec = System.Drawing.Rectangle.FromLTRB(0, 0, 64, 64); Surface.FromMemory(baseSurf, AlphaData, Filter.Box, 0, Format.A8R8G8B8, 4 * 64, rec); baseSurf.Dispose(); }
///////////////////////////////////////////////////////////////////////////// public void Unload() { if (mMesh != null || mAlphaTexture != null) { Game.GameManager.GraphicsThread.CallOnThread( () => { if (mAlphaTexture != null) { ADTAlphaHandler.AddFreeTexture(mAlphaTexture); } if (mShadowTexture != null) { ADTAlphaHandler.AddFreeShadowTexture(mShadowTexture); } if (mMesh != null) { mMesh.Dispose(); mMesh = null; } }, true ); } foreach (var inst in mDoodadInstances) { foreach (var id in inst.Value) { Game.GameManager.M2ModelManager.RemoveInstance(inst.Key, id); } } foreach (var id in mConfirmedUniqueID) { var name = mParent.DoodadNames[mParent.ModelIdentifiers[(int)mParent.ModelDefinitions[(int)id].idMMID]]; ADTManager.RemoveUniqueMdxId(name, mParent.ModelDefinitions[(int)id].uniqueId); } mParent = null; mFile = null; mLayers.Clear(); mLayers = null; AlphaData = null; AlphaFloats = null; }
private void LoadShadowTexture() { if (mShadowTexture == null) { mShadowTexture = ADTAlphaHandler.FreeShadowTexture(); } if (mShadowTexture == null) { mShadowTexture = new Texture(Game.GameManager.GraphicsThread.GraphicsManager.Device, 64, 64, 1, Usage.None, Format.A8, Pool.Managed); } Surface baseSurf = mShadowTexture.GetSurfaceLevel(0); System.Drawing.Rectangle rec = System.Drawing.Rectangle.FromLTRB(0, 0, 64, 64); Surface.FromMemory(baseSurf, ShadowData, Filter.None, 0, Format.A8, 64, rec); baseSurf.Dispose(); }