Exemplo n.º 1
0
        private int exportModel(object sender, object argument)
        {
            List <object> arguments = (List <object>)argument;

            IModelExporter     modelExporter = (IModelExporter)arguments[0];
            string             directory     = (String)arguments[1];
            List <string>      fileNames     = (List <string>)arguments[2];
            ModelExportOptions exportOptions = (ModelExportOptions)arguments[3];

            BackgroundWorker backgroundWorker = (BackgroundWorker)sender;

            int result = 0;

            for (int i = 0; i < fileNames.Count; ++i)
            {
                string fileName = fileNames[i];

                MemoryStream memoryStream = AssetManager.Instance.CreateAssetMemoryStreamByName(fileName);

                if (memoryStream == null)
                {
                    continue;
                }

                Model model = Model.LoadFromStream(fileName, memoryStream);

                if (model == null)
                {
                    continue;
                }

                modelExporter.ExportModelToDirectoryWithExportOptions(model, directory, exportOptions);

                int percent = (int)(((Single)i / (Single)fileNames.Count) * 100);

                backgroundWorker.ReportProgress(percent, fileName);

                ++result;
            }

            return(result);
        }