public static void SetTextureForAnimation(string diffuseMapName, string newMapName) { List <RenderWareModelFile> models = new List <RenderWareModelFile>(); foreach (IAssetWithModel awm in ArchiveEditorFunctions.renderingDictionary.Values) { if (awm is AssetMODL MODL && MODL.HasRenderWareModelFile()) { models.Add(MODL.GetRenderWareModelFile()); } } foreach (IRenderableAsset awm in ArchiveEditorFunctions.renderableAssetSetJSP) { if (awm is AssetJSP JSP && JSP.HasRenderWareModelFile()) { models.Add(JSP.GetRenderWareModelFile()); } } foreach (RenderWareModelFile m in models) { foreach (SharpMesh mesh in m.meshList) { foreach (SharpSubSet sub in mesh.SubSets) { if (sub.DiffuseMapName == diffuseMapName) { sub.DiffuseMap = Textures[newMapName]; } } } } }
public static void ReapplyTextures() { List <RenderWareModelFile> models = new List <RenderWareModelFile>(); foreach (IAssetWithModel awm in ArchiveEditorFunctions.renderingDictionary.Values) { if (awm is AssetMODL MODL && MODL.HasRenderWareModelFile()) { models.Add(MODL.GetRenderWareModelFile()); } } foreach (IRenderableAsset awm in ArchiveEditorFunctions.renderableAssetSetJSP) { if (awm is AssetJSP JSP && JSP.HasRenderWareModelFile()) { models.Add(JSP.GetRenderWareModelFile()); } } foreach (RenderWareModelFile m in models) { foreach (SharpMesh mesh in m.meshList) { foreach (SharpSubSet sub in mesh.SubSets) { if (Textures.ContainsKey(sub.DiffuseMapName)) { if (sub.DiffuseMap != Textures[sub.DiffuseMapName]) { if (sub.DiffuseMap != null) { if (!sub.DiffuseMap.IsDisposed) { if (sub.DiffuseMap != SharpRenderer.whiteDefault) { sub.DiffuseMap.Dispose(); } } } sub.DiffuseMap = Textures[sub.DiffuseMapName]; } } else { if (sub.DiffuseMap != null) { if (!sub.DiffuseMap.IsDisposed) { if (sub.DiffuseMap != SharpRenderer.whiteDefault) { sub.DiffuseMap.Dispose(); } } } sub.DiffuseMap = SharpRenderer.whiteDefault; } } } } }