Пример #1
0
        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();
        }
Пример #2
0
        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);
        }
Пример #3
0
        /// <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;
            }
        }
Пример #4
0
 /// <summary>
 /// Find a Joint with the same name as this one in tha passed GMDC, and set it as import Target
 /// </summary>
 /// <param name="gmdc"></param>
 public void FindBestFitJoint(SimPe.Plugin.GeometryDataContainer gmdc)
 {
     FindBestFitJoint(gmdc.Joints);
 }