Esempio n. 1
0
        static public void init()
        {
            if (mDEP == null)
            {
                mDEP = new DEP();
            }
            if (mECF == null)
            {
                mECF = new ECFWriter();
            }

            if (mEPB == null)
            {
                mEPB = new ExportProgressDialog();
            }
            mOutputOverrideDir = null;
        }
Esempio n. 2
0
        static public void destroy()
        {
            mEPB.Close();
            mEPB.Dispose();
            mEPB = null;

            if (mDEP != null)
            {
                mDEP = null;
            }
            if (mECF != null)
            {
                mECF.destroy(); mECF = null;
            }


            checkUnloadRender();
            mOutputOverrideDir = null;
        }
Esempio n. 3
0
        static public bool doExport(String terrainFileName,
                                    String scenarioFileName,
                                    String outputOverrideDir,
                                    ref ExportSettings expSettings, ref ExportResults results,
                                    bool doXTD, bool doXTT, bool doXTH, bool doXSD, bool doLRP, bool doDEP, bool doTAG, bool doXMB)
        {
            //This is now done outside using work topics
            //if (CoreGlobals.UsingPerforce == true)
            //{
            //   if (!checkPerforceFileAlloances(terrainFileName, scenarioFileName,
            //                                 doXTD, doXTT, doXTH, doXSD, doLRP, doDEP, doTAG, doXMB))
            //      return false;
            //}

            init();
            int maxValues = (doXTD?1:0) +
                            (doXTT?1:0) +
                            (doXTH?1:0) +
                            (doXSD?1:0) +
                            (doLRP?1:0) +
                            (doDEP?1:0) +
                            (doTAG?1:0) +
                            (doXMB?1:0) +
                            (expSettings.AmbientOcclusion != AmbientOcclusion.eAOQuality.cAO_Off?1:0)
            ;

            initOverrideDir(outputOverrideDir);


            mEPB.Init(maxValues);
            mEPB.setName(Path.GetFileNameWithoutExtension(terrainFileName));
            mEPB.Show();
            DateTime start = DateTime.Now;


            GC.Collect();
            GC.WaitForPendingFinalizers();


            mECF.clear();
            mDEP.clear();

            bool sofarSoGood = true;



            if (sofarSoGood && doXTT)
            {
                XTTExporter XTTexporter = new XTTExporter();
                sofarSoGood &= XTTexporter.export_XTT(terrainFileName, expSettings, ref results);
                XTTexporter.destroy();
                XTTexporter = null;
                ExportTo360.mECF.clear();
                ExportProgressDialog.Increase();
            }



            //From here on out we don't need textures in memory..
            if (sofarSoGood && (expSettings.AmbientOcclusion != AmbientOcclusion.eAOQuality.cAO_Off || doXTH))
            {
                BRenderDevice.getTextureManager().freeAllD3DTextureHandles();
            }



            if (sofarSoGood && doXTD)
            {
                XTDExporter XTDexporter = new XTDExporter();
                sofarSoGood &= XTDexporter.export_XTD(terrainFileName, expSettings, ref results);
                XTDexporter.destroy();
                XTDexporter = null;
                ExportTo360.mECF.clear();
                ExportProgressDialog.Increase();
            }



            if (sofarSoGood && doXSD)
            {
                XSDExporter XSDexporter = new XSDExporter();
                sofarSoGood &= XSDexporter.export_XSD(scenarioFileName, expSettings, ref results);
                XSDexporter.destroy();
                if (sofarSoGood && doLRP)
                {
                    sofarSoGood &= XSDexporter.CreateLRP(spliceFilenameWithOverride(scenarioFileName));
                }
                XSDexporter = null;
                ExportTo360.mECF.clear();
                ExportProgressDialog.Increase();
            }


            if (sofarSoGood && doXTH)
            {
                XTHExporter XTHexporter = new XTHExporter();
                sofarSoGood &= XTHexporter.export_XTH(terrainFileName, expSettings, ref results);
                XTHexporter.destroy();
                XTHexporter = null;
                ExportTo360.mECF.clear();
                ExportProgressDialog.Increase();
            }


            // OVERRIDE! if ANY terrain files are changed, then generate a .TAG
            if (sofarSoGood && doTAG && (doXTT | doXTD | doXTH | doXSD))
            {
                TAG      mTAG            = new TAG();
                String[] extentions      = new String[] { ".XTD", ".XTT", ".XTH", ".XSD", ".LRP" };
                String   desiredFilename = "";
                for (int i = 0; i < extentions.Length - 1; i++)
                {
                    desiredFilename = spliceFilenameWithOverride(Path.ChangeExtension(terrainFileName, extentions[i]));
                    mTAG.addFile(desiredFilename);
                }

                //XSD
                desiredFilename = spliceFilenameWithOverride(Path.ChangeExtension(scenarioFileName, extentions[extentions.Length - 2]));
                mTAG.addFile(desiredFilename);
                desiredFilename = spliceFilenameWithOverride(Path.ChangeExtension(scenarioFileName, extentions[extentions.Length - 1]));
                mTAG.addFile(desiredFilename);

                mTAG.writeToFile(spliceFilenameWithOverride(Path.ChangeExtension(scenarioFileName, ".TAG")));
                mTAG = null;


                ExportProgressDialog.Increase();
            }



            if (sofarSoGood && doXTT && doDEP) //CLM XTT is the only one that marks dependents currently...
            {
                mDEP.writeToFile(spliceFilenameWithOverride(terrainFileName));
            }



            if (sofarSoGood && doXMB)
            {
                string outputDir = null;
                if (mOutputOverrideDir != null)
                {
                    outputDir = spliceFilenameWithOverride(terrainFileName);
                    outputDir = Path.GetDirectoryName(outputDir);
                }

                if (File.Exists(Path.ChangeExtension(scenarioFileName, ".SCN")))
                {
                    XMBProcessor.CreateXMB(Path.ChangeExtension(scenarioFileName, ".SCN"), outputDir, false);
                }
                if (File.Exists(Path.ChangeExtension(scenarioFileName, ".GLS")))
                {
                    XMBProcessor.CreateXMB(Path.ChangeExtension(scenarioFileName, ".GLS"), outputDir, false);
                }

                if (File.Exists(Path.ChangeExtension(scenarioFileName, ".DEP")))
                {
                    XMBProcessor.CreateXMB(spliceFilenameWithOverride(Path.ChangeExtension(scenarioFileName, ".DEP")), false);
                }
                ExportProgressDialog.Increase();
            }



            TimeSpan ts = DateTime.Now - start;

            results.totalTime = ts.TotalMinutes;

            destroy();

            GC.Collect();
            GC.WaitForPendingFinalizers();

            //if we've cleared the textures, force them to reload..
            if (expSettings.AmbientOcclusion != AmbientOcclusion.eAOQuality.cAO_Off || doXTH)
            {
                BRenderDevice.getTextureManager().reloadTexturesIfNeeded(true);
            }

            mOutputOverrideDir = null;

            return(sofarSoGood);
        }