public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.GMDC); //ArrayList list = new ArrayList(); ps.State = TriState.True; uint fct = 0; uint vct = 0; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.Rcol rcol = new GenericRcol(); rcol.ProcessData(pfd, si.Package, true); SimPe.Plugin.GeometryDataContainer gmdc = rcol.Blocks[0] as SimPe.Plugin.GeometryDataContainer; foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups) { fct += (uint)g.FaceCount; vct += (uint)g.UsedVertexCount; } rcol.Dispose(); } ps.Data = new uint[] { vct, fct }; UpdateState(si, ps, lvi); }
public virtual void SetFromPackage(SimPe.Interfaces.Files.IPackageFile pkg) { if (pkg == null) { objd = null; ClearScreen(); return; } SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(Data.MetaData.OBJD_FILE, 0, 0x41A7); if (pfds.Length > 0) { objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(pfds[0], pkg); } int fct = 0; int vct = 0; pfds = pkg.FindFiles(Data.MetaData.GMDC); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.Rcol rcol = new GenericRcol(); rcol.ProcessData(pfd, pkg, true); SimPe.Plugin.GeometryDataContainer gmdc = rcol.Blocks[0] as SimPe.Plugin.GeometryDataContainer; foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups) { fct += g.FaceCount; vct += g.UsedVertexCount; } rcol.Dispose(); } lbVert.Text = vct.ToString() + " (" + fct.ToString() + " Faces)"; UpdateScreen(); }
/// <summary> /// Renders the Preview form the GMDC and loads the vertex and face Count for an Object /// </summary> /// <param name="pkg"></param> protected void RenderGmdcPreview(SimPe.Interfaces.Files.IPackageFile pkg) { int fct = 0; int vct = 0; if (this.countvert) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.GMDC); bool first = !nfo.HasThumbnail; Wait.SubStart(); System.Windows.Forms.Application.DoEvents(); Wait.Message = "Counting Vertices"; System.Windows.Forms.Application.DoEvents(); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.Rcol rcol = new GenericRcol(); rcol.ProcessData(pfd, pkg, true); SimPe.Plugin.GeometryDataContainer gmdc = rcol.Blocks[0] as SimPe.Plugin.GeometryDataContainer; bool hasmesh = false; foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups) { if (g.Opacity == 0xFFFFFFFF) { hasmesh = true; } fct += g.FaceCount; vct += g.UsedVertexCount; } bool dispose = true; if (SimPe.Plugin.DownloadsToolFactory.Settings.BuildPreviewForObjects) { if (first && hasmesh && rendergmdc) { first = false; SimPe.Plugin.GeometryDataContainerExt ext = new GeometryDataContainerExt(gmdc); nfo.RenderData = ext; nfo.PostponedRenderer = new EventHandler(PostponedRender); dispose = false; } } if (dispose) { gmdc.Dispose(); rcol.Dispose(); } } Wait.SubStop(); pfds = null; } nfo.VertexCount = vct; nfo.FaceCount = fct; if (!nfo.HasThumbnail && !SimPe.Plugin.DownloadsToolFactory.Settings.BuildPreviewForObjects) { nfo.Image = Downloads.WallpaperTypeHandler.SetFromTxtr(pkg); nfo.KnockoutThumbnail = false; } }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { System.Drawing.Size sz = AbstractScanner.ThumbnailSize; if (si.PackageCacheItem.Type == PackageType.Object || si.PackageCacheItem.Type == PackageType.MaxisObject || si.PackageCacheItem.Type == PackageType.Recolor) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.OBJD_FILE); uint group = 0; if (pfds.Length > 0) { group = pfds[0].Group; } if (group == Data.MetaData.LOCAL_GROUP) { SimPe.Interfaces.Wrapper.IGroupCacheItem gci = FileTable.GroupCache.GetItem(si.FileName); if (gci != null) { group = gci.LocalGroup; } } string[] modelnames = SimPe.Plugin.Scenegraph.FindModelNames(si.Package); foreach (string modelname in modelnames) { System.Drawing.Image img = SimPe.Plugin.Workshop.GetThumbnail(group, modelname); if (img != null) { si.PackageCacheItem.Thumbnail = img; ps.State = TriState.True; break; } } } //no Thumbnail, do we have a Image File? if (ps.State == TriState.Null) { SimPe.PackedFiles.Wrapper.Picture pic = new Picture(); uint[] types = pic.AssignableTypes; foreach (uint type in types) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(type); if (pfds.Length > 0) { //get image with smallest Instance SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in pfds) { if (p.Instance < pfd.Instance) { pfd = p; } } pic.ProcessData(pfd, si.Package, false); si.PackageCacheItem.Thumbnail = pic.Image; if (si.PackageCacheItem.Thumbnail != null) { si.PackageCacheItem.Thumbnail = ImageLoader.Preview(si.PackageCacheItem.Thumbnail, sz); ps.State = TriState.True; } break; } } //foreach } //no Thumbnail generated by the Game? if (ps.State == TriState.Null) { //load the Texture Image SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.TXTR); if (pfds.Length > 0) { SimPe.Plugin.GenericRcol rcol = new GenericRcol(null, false); //get biggest texture SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in pfds) { if (p.Size > pfd.Size) { pfd = p; } } rcol.ProcessData(pfd, si.Package, false); SimPe.Plugin.ImageData id = (SimPe.Plugin.ImageData)rcol.Blocks[0]; SimPe.Plugin.MipMap mm = id.GetLargestTexture(sz); if (mm.Texture != null) { si.PackageCacheItem.Thumbnail = ImageLoader.Preview(mm.Texture, sz); ps.State = TriState.True; } rcol.Dispose(); } } if (si.PackageCacheItem.Thumbnail != null) { if (WaitingScreen.Running) { WaitingScreen.UpdateImage(si.PackageCacheItem.Thumbnail); } } UpdateState(si, ps, lvi); }