Esempio n. 1
0
        /// <summary>
        /// Called when a new File is started
        /// </summary>
        /// <remarks>
        /// you should use this to write Header Informations.
        /// Use the writer member to write to the File
        /// </remarks>
        protected override void InitFile()
        {
            string name = System.IO.Path.GetFileNameWithoutExtension(this.FileName);
            string path = System.IO.Path.GetDirectoryName(this.FileName);

            path = System.IO.Path.Combine(path, name + ".IMG");


            GeometryDataContainerExt gext = new GeometryDataContainerExt(Gmdc);

            Ambertation.Scenes.Scene scn = gext.GetScene(this.Groups, path, name + ".IMG", this.Component);

            Ambertation.XSI.IO.AsciiFile xsi = Ambertation.XSI.IO.AsciiFile.FromScene(scn, FileName);
            xsi.SaveToStream(this.writer);
        }
Esempio n. 2
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;
            }
        }