protected void PostponedRender(object sender, EventArgs e) { Wait.SubStart(); Wait.Message = "Building Preview"; PackageInfo nfo = sender as PackageInfo; object[] data = nfo.RenderData as object[]; tmppkg = SimPe.Packages.GeneratableFile.LoadFromFile(data[1].ToString()); if (tmppkg == null) { return; } SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii = SimPe.Plugin.DownloadsToolFactory.TeleportFileIndex.AddNewChild(); SimPe.Plugin.MmatWrapper mmat = data[0] as SimPe.Plugin.MmatWrapper; mmat.ProcessData(mmat.FileDescriptor, tmppkg); if (mmat != null) { fii.AddIndexFromPackage(mmat.Package, true); try { Ambertation.Scenes.Scene scn = SimPe.Plugin.PreviewForm.RenderScene(mmat); nfo.RenderedImage = Downloads.DefaultTypeHandler.Get3dPreview(scn); scn.Dispose(); mmat.Dispose(); } catch {} } fii.CloseAssignedPackages(); SimPe.Plugin.DownloadsToolFactory.TeleportFileIndex.RemoveChild(fii); this.DisposeTmpPkg(); Wait.SubStop(); }
/// <summary> /// This takes care of the MMAT Resources /// </summary> /// <param name="map"></param> /// <param name="uniquefamily"></param> /// <param name="grouphash"></param> void FixMMAT(Hashtable map, bool uniquefamily, string grouphash) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Updating Material Overrides"); } Interfaces.Files.IPackedFileDescriptor[] mpfds = package.FindFiles(Data.MetaData.MMAT); //MMAT Hashtable familymap = new Hashtable(); uint mininst = 0x5000; foreach (Interfaces.Files.IPackedFileDescriptor pfd in mpfds) { SimPe.Plugin.MmatWrapper mmat = new SimPe.Plugin.MmatWrapper(); mmat.ProcessData(pfd, package); //make the MMAT Instance number unique pfd.Instance = mininst++; //get unique family value if (uniquefamily) { string family = mmat.GetSaveItem("family").StringValue; string nfamily = (string)familymap[family]; if (nfamily == null) { nfamily = System.Guid.NewGuid().ToString(); familymap[family] = nfamily; } mmat.Family = nfamily; } string newref = (string)map[Hashes.StripHashFromName(mmat.GetSaveItem("name").StringValue.Trim().ToLower()) + "_txmt"]; if (newref != null) { newref = Hashes.StripHashFromName(newref); newref = newref.Substring(0, newref.Length - 5); mmat.Name = grouphash + newref; } else { mmat.Name = grouphash + Hashes.StripHashFromName(mmat.GetSaveItem("name").StringValue); } newref = (string)map[Hashes.StripHashFromName(mmat.ModelName.Trim().ToLower())]; if (newref != null) { newref = Hashes.StripHashFromName(newref); mmat.ModelName = newref; } else { mmat.ModelName = Hashes.StripHashFromName(mmat.ModelName); } if (ver == FixVersion.UniversityReady) { SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(mmat.ModelName, Data.MetaData.CRES, Data.MetaData.GLOBAL_GROUP, true); bool addfl = true; if (item != null) { if (item.FileDescriptor.Group == Data.MetaData.GLOBAL_GROUP) { addfl = false; } } if (addfl) { mmat.ModelName = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + mmat.ModelName; } } //mmat.FileDescriptor.Group = Data.MetaData.LOCAL_GROUP; mmat.SynchronizeUserData(); } }