public void SetWardrobeTexture(Wardrobe thePieceType, string theTexture) { if (string.Compare(theTexture, "none", true) == 0 || string.IsNullOrEmpty(theTexture)) { return; } // gather information about wardrobe if (ModelEntity.GetMesh().NumSubMeshes > 0) { bool needsReload = false; foreach (var subMesh in ModelEntity.GetMesh().GetSubMeshIterator()) { var matPtr = (MaterialPtr)MaterialManager.Singleton.GetByName(subMesh.MaterialName); string suitStr = thePieceType.ToString(); if (subMesh.MaterialName.IndexOf(suitStr, StringComparison.OrdinalIgnoreCase) >= 0) { foreach (var mtrPass in matPtr.GetTechnique(0).GetPassIterator()) { mtrPass.RemoveAllTextureUnitStates(); TextureUnitState baseTex = null; if (WardrobeTextures[(int)Wardrobe.Face] != null) { baseTex = new TextureUnitState(mtrPass, WardrobeTextures[(int)Wardrobe.Face]); } TextureUnitState wardTex = new TextureUnitState(mtrPass, theTexture); wardTex.SetColourOperation(LayerBlendOperation.LBO_ALPHA_BLEND); needsReload = true; if (baseTex != null) { mtrPass.AddTextureUnitState(baseTex); } mtrPass.AddTextureUnitState(wardTex); } WardrobeTextures[(int)thePieceType] = theTexture; break; } if (needsReload) { matPtr.Reload(); } } } }
public void SetWardrobeTexture(Wardrobe thePieceType, string theTexture) { if (string.Compare(theTexture, "none", true) == 0 || string.IsNullOrEmpty(theTexture)) return; // gather information about wardrobe if (ModelEntity.GetMesh().NumSubMeshes > 0) { bool needsReload = false; foreach (var subMesh in ModelEntity.GetMesh().GetSubMeshIterator()) { var matPtr = (MaterialPtr)MaterialManager.Singleton.GetByName(subMesh.MaterialName); string suitStr = thePieceType.ToString(); if (subMesh.MaterialName.IndexOf(suitStr, StringComparison.OrdinalIgnoreCase) >= 0) { foreach (var mtrPass in matPtr.GetTechnique(0).GetPassIterator()) { mtrPass.RemoveAllTextureUnitStates(); TextureUnitState baseTex = null; if (WardrobeTextures[(int)Wardrobe.Face] != null) { baseTex = new TextureUnitState(mtrPass, WardrobeTextures[(int)Wardrobe.Face]); } TextureUnitState wardTex = new TextureUnitState(mtrPass, theTexture); wardTex.SetColourOperation(LayerBlendOperation.LBO_ALPHA_BLEND); needsReload = true; if (baseTex!=null) mtrPass.AddTextureUnitState(baseTex); mtrPass.AddTextureUnitState(wardTex); } WardrobeTextures[(int)thePieceType] = theTexture; break; } if (needsReload) matPtr.Reload(); } } }