public GenericRcol FindUsedGMDC(GenericRcol cres) { if (cres == null) { return(null); } SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = cres.FindReferencedType(Data.MetaData.SHPE); if (item != null) { GenericRcol rcol = new GenericRcol(); rcol.ProcessData(item); item = rcol.FindReferencedType(Data.MetaData.GMND); if (item != null) { rcol.ProcessData(item); item = rcol.FindReferencedType(Data.MetaData.GMDC); if (item != null) { rcol.ProcessData(item); return(rcol); } } } return(null); }
protected GenericRcol FindDefiningCRES(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile pkg) { GenericRcol rcol = new GenericRcol(); rcol.ProcessData(pfd, pkg); ResourceNode rn = (ResourceNode)rcol.Blocks[0]; foreach (int i in rn.ChildBlocks) { SimPe.Interfaces.Scenegraph.ICresChildren icc = rn.GetBlock(i); if (icc != null) { if (icc.StoredTransformNode != null) { if (icc.StoredTransformNode.ObjectGraphNode.FileName == this.Name) { return(rcol); } } } } return(null); }
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 override void SearchPackage(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { bool found = false; if (type == 0) { foreach (uint tt in SimPe.Data.MetaData.RcolList) { if (tt == pfd.Type) { found = true; break; } } } else { found = type == pfd.Type; } if (!found) { return; } SimPe.Plugin.GenericRcol rcol = new GenericRcol(null, true); rcol.ProcessData(pfd, pkg); found = false; string n = rcol.FileName.Trim().ToLower(); if (compareType == CompareType.Equal) { found = n == name; } else if (compareType == CompareType.Start) { found = n.StartsWith(name); } else if (compareType == CompareType.End) { found = n.EndsWith(name); } else if (compareType == CompareType.Contain) { found = n.IndexOf(name) > -1; } else if (compareType == CompareType.RegExp && reg != null) { found = reg.IsMatch(n); } //we have a match, so add the result item if (found) { ResultGui.AddResult(pkg, pfd); } }
void AddToGMND(SimPe.Events.ResourceContainer rc) { SimPe.Plugin.GenericRcol rcol = new GenericRcol(); rcol.ProcessData(rc.Resource); RemoveFromGMND(rcol); GeometryNode gn = (GeometryNode)rcol.Blocks[0]; DataListExtension dle = new DataListExtension(rcol); dle.Extension.VarName = "copyright"; dle.Extension.Items = new ExtensionItem[4]; dle.Extension.Items[0] = new ExtensionItem(); dle.Extension.Items[0].Typecode = ExtensionItem.ItemTypes.String; dle.Extension.Items[0].Name = "created by"; dle.Extension.Items[0].String = form.tbCreator.Text; dle.Extension.Items[1] = new ExtensionItem(); dle.Extension.Items[1].Typecode = ExtensionItem.ItemTypes.String; dle.Extension.Items[1].Name = "license"; dle.Extension.Items[1].String = form.tbLicense.Text; dle.Extension.Items[2] = new ExtensionItem(); dle.Extension.Items[2].Typecode = ExtensionItem.ItemTypes.String; dle.Extension.Items[2].Name = "release date"; dle.Extension.Items[2].String = form.tbDate.Text; dle.Extension.Items[3] = new ExtensionItem(); dle.Extension.Items[3].Typecode = ExtensionItem.ItemTypes.String; dle.Extension.Items[3].Name = "version"; dle.Extension.Items[3].String = form.tbVersion.Text; rcol.Blocks = (SimPe.Interfaces.Scenegraph.IRcolBlock[])Helper.Add(rcol.Blocks, dle, typeof(SimPe.Interfaces.Scenegraph.IRcolBlock)); ObjectGraphNodeItem ogni = new ObjectGraphNodeItem(); ogni.Index = (uint)(rcol.Blocks.Length - 1); ogni.Enabled = 0x01; ogni.Dependant = 0x00; gn.ObjectGraphNode.Items = (ObjectGraphNodeItem[])Helper.Add(gn.ObjectGraphNode.Items, ogni); rcol.SynchronizeUserData(true, true); }
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(); }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { ps.Data = new uint[1]; ps.State = TriState.True; ps.Data[0] = (uint)HealthState.Ok; if (si.Package.Header.Version != 0x100000001) { ps.Data[0] = (uint)HealthState.UnknownVersion; } else { if (si.Package.FileListFile != null) { foreach (SimPe.PackedFiles.Wrapper.ClstItem item in si.Package.FileListFile.Items) { SimPe.Interfaces.Files.IPackedFileDescriptor p = si.Package.FindFile(item.Type, item.SubType, item.Group, item.Instance); if (p == null) { ps.Data[0] = (uint)HealthState.WrongDirectory; break; } } if (ps.Data[0] == (uint)HealthState.Ok) { foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in si.Package.Index) { SimPe.Interfaces.Files.IPackedFile fl = si.Package.Read(pfd); if (pfd.Type == Data.MetaData.OBJD_FILE) { SimPe.PackedFiles.Wrapper.ExtObjd obj = new ExtObjd(); obj.ProcessData(pfd, si.Package); if (obj.Ok != SimPe.PackedFiles.Wrapper.ObjdHealth.Ok) { ps.Data[0] = (uint)HealthState.NonDefaultObjd; } if (obj.Ok == SimPe.PackedFiles.Wrapper.ObjdHealth.UnmatchingFilenames && Helper.WindowsRegistry.HiddenMode) { ps.Data[0] = (uint)HealthState.FaultyNamedObjd; } if (obj.Ok == ObjdHealth.OverLength) { ps.Data[0] = (uint)HealthState.FaultySizedObjd; } } if (pfd.Type == Data.MetaData.GMDC) { SimPe.Plugin.GenericRcol rcol = new GenericRcol(); rcol.ProcessData(pfd, si.Package); SimPe.Plugin.GeometryDataContainer gmdc = (SimPe.Plugin.GeometryDataContainer)rcol.Blocks[0]; foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups) { if (g.FaceCount > SimPe.Plugin.Gmdc.AbstractGmdcImporter.CRITICAL_FACE_AMOUNT) { ps.Data[0] = (uint)HealthState.BigMeshGeometry; } else if (g.UsedVertexCount > SimPe.Plugin.Gmdc.AbstractGmdcImporter.CRITICAL_VERTEX_AMOUNT) { ps.Data[0] = (uint)HealthState.BigMeshGeometry; } } } if (!fl.IsCompressed) { continue; } int pos = si.Package.FileListFile.FindFile(pfd); if (pos == -1) { ps.Data[0] = (uint)HealthState.IncompleteDirectory; break; } SimPe.PackedFiles.Wrapper.ClstItem item = si.Package.FileListFile.Items[pos]; if (fl.UncompressedSize != item.UncompressedSize) { ps.Data[0] = (uint)HealthState.WrongCompressionSize; break; } } } } if (ps.Data[0] != (uint)HealthState.Ok) { ps.State = TriState.False; } } UpdateState(si, ps, lvi); }
/// <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); }