Exemple #1
0
        //----------------------------
        //----------------------------
        #region AO Section Export
        private void exportAOFileList()
        {
            String batchExportLog = outputLog;

            if (batchExportLog == null)
            {
                batchExportLog = Path.Combine(CoreGlobals.getWorkPaths().mLogsDirectory, "batchExportLog." + System.DateTime.Now.ToFileTimeUtc() + ".txt");
            }
            mExportLogStream = new StreamWriter(batchExportLog, true);


            //export settings
            Export360.ExportSettings settings = null;
            if (mUseCustomExportSettings == -1 || mUseCustomExportSettings == 0)
            {
                settings = null;
            }
            else if (mUseCustomExportSettings == 1)
            {
                settings = new Export360.ExportSettings();
                settings.SettingsQuick();
            }
            else if (mUseCustomExportSettings == 2)
            {
                settings = new Export360.ExportSettings();
                settings.SettingsFinal();
            }


            bool createOwnDevice = BRenderDevice.getDevice() == null;

            if (createOwnDevice)
            {
                BRenderDevice.createDevice(this, 640, 480, false);
            }

            GrannyManager2.init();

            for (int fileCount = 0; fileCount < mScenarioFilesToExport.Count; fileCount++)// (string file in ToExportListBox.SelectedItems)
            {
                string scenarioName = mScenarioFilesToExport[fileCount].mFilename;
                string terrainName  = mTerrainFilesToExport[mScenarioFilesToExport[fileCount].mTerrainFileIndex].mFilename;

                bool okExported = TEDIO.TEDtoAOSection(terrainName, scenarioName, outputDir, mAoNumSections, mAoSectionIndex, settings);
            }

            if (createOwnDevice)
            {
                BRenderDevice.destroyDevice();
            }

            mExportLogStream.Close();

            if (mStatusResult == 0)
            {
                File.Delete(batchExportLog);
            }

            clearList();
        }
Exemple #2
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);
        }
Exemple #3
0
        //----------------------------
        private void exportFileList()
        {
            String batchExportLog = outputLog;

            if (batchExportLog == null)
            {
                batchExportLog = Path.Combine(CoreGlobals.getWorkPaths().mLogsDirectory, "batchExportLog." + System.DateTime.Now.ToFileTimeUtc() + ".txt");
            }
            mExportLogStream = new StreamWriter(batchExportLog, true);
            listBox1.Items.Clear();


            DateTime start = DateTime.Now;

            SimTerrainType.loadTerrainTypes();


            Exportbutton.Enabled = false;
            progressBar1.Value   = 0;
            progressBar1.Maximum = mScenarioFilesToExport.Count;// ToExportListBox.SelectedItems.Count;



            //export settings
            Export360.ExportSettings settings = null;
            if (mUseCustomExportSettings == -1)
            {
                settings = null;
            }
            else if (mUseCustomExportSettings == 0)
            {
                ExportDialog mExportDialog = new ExportDialog();
                mExportDialog.mExportSettings = new Export360.ExportSettings();
                mExportDialog.mExportSettings.SettingsQuick();
                mExportDialog.mIsQuickExport = true;
                if (mExportDialog.ShowDialog() == DialogResult.OK)
                {
                    settings = mExportDialog.mExportSettings;
                }
            }
            else if (mUseCustomExportSettings == 1)
            {
                settings = new Export360.ExportSettings();
                settings.SettingsQuick();
            }
            else if (mUseCustomExportSettings == 2)
            {
                settings = new Export360.ExportSettings();
                settings.SettingsFinal();
            }



            bool createOwnDevice = BRenderDevice.getDevice() == null;

            if (createOwnDevice)
            {
                BRenderDevice.createDevice(this, 640, 480, false);
            }

            GrannyManager2.init();

            saveCheckOptions();

            for (int fileCount = 0; fileCount < mScenarioFilesToExport.Count; fileCount++)// (string file in ToExportListBox.SelectedItems)
            {
                string scenarioName = mScenarioFilesToExport[fileCount].mFilename;
                string terrainName  = mTerrainFilesToExport[mScenarioFilesToExport[fileCount].mTerrainFileIndex].mFilename;

                bool terrainAlreadyExported = hasBeenExported(fileCount);

                //if our owner terrain has already been exported, and we're not generating XSD files, bail.
                if (terrainAlreadyExported && !doXSD.Checked)
                {
                    continue;
                }

                bool canEdit = mIgnorePerforce ? true : P4CanEdit(scenarioName, terrainName, mCheckoutFromPerforce);

                if (canEdit)
                {
                    //toggle our check boxes for already exported terrain files
                    doXTD.Checked &= !terrainAlreadyExported;
                    doXTT.Checked &= !terrainAlreadyExported;
                    doXTH.Checked &= !terrainAlreadyExported;

                    bool okExported = TEDIO.TEDto360(terrainName, scenarioName,
                                                     outputDir,
                                                     settings,
                                                     doXTD.Checked,
                                                     doXTT.Checked,
                                                     doXTH.Checked,
                                                     doXSD.Checked,
                                                     doLRP.Checked,
                                                     doDEP.Checked,
                                                     doTAG.Checked,
                                                     doXMB.Checked);



                    if (okExported)
                    {
                        outputMessage(Path.GetFileNameWithoutExtension(scenarioName) + ": EXPORT SUCCEEDED!--------------------");
                    }
                    else
                    {
                        mStatusResult = 2;
                        outputMessage(Path.GetFileNameWithoutExtension(scenarioName) + ": ABORTED! There was a problem exporting the files");
                        P4RevertAllNeededFiles(scenarioName, terrainName);
                    }
                }

                progressBar1.Invoke(updateProgress);
                restoreCheckOptions();
                markScenarioExported(fileCount);
            }



            if (createOwnDevice)
            {
                BRenderDevice.destroyDevice();
            }

            if (!mIgnorePerforce && mCheckinWhenFinished)
            {
                outputMessage("Checking in files");
                P4SubmitChangelist();
            }


            Exportbutton.Enabled = true;

            TimeSpan ts = DateTime.Now - start;

            outputMessage("====Time : " + ts.TotalMinutes + " Minutes");
            outputMessage("====Export Finished====");

            //   GrannyManager2.deinit();

            mExportLogStream.Close();

            if (mStatusResult == 0)
            {
                File.Delete(batchExportLog);
            }

            clearList();
        }
Exemple #4
0
 static public bool doExport(String baseFilename,
                             ref ExportSettings expSettings, ref ExportResults results,
                             bool doXTD, bool doXTT, bool doXTH, bool doXSD, bool doLRP, bool doDEP, bool doTAG, bool doXMB)
 {
     return(doExport(baseFilename, baseFilename, null, ref expSettings, ref results, doXTD, doXTT, doXTH, doXSD, doLRP, doDEP, doTAG, doXMB));
 }
Exemple #5
0
 static public bool doExport(String terrainFileName, string scenarioFileName, ref ExportSettings expSettings, ref ExportResults results)
 {
     return(doExport(terrainFileName, scenarioFileName, null, ref expSettings, ref results, true, true, true, true, true, true, true, false));
 }
Exemple #6
0
 //functions
 static public bool doExport(String baseFilename, ref ExportSettings expSettings, ref ExportResults results)
 {
     return(doExport(baseFilename, baseFilename, null, ref expSettings, ref results, true, true, true, true, true, true, true, false));
 }
Exemple #7
0
        public bool export_XTD(string filename, ExportSettings expSettings, ref ExportResults results)
        {
            DateTime start = DateTime.Now;

            //write the header for the entire XTD file
            XTDVisualHeader header = new XTDVisualHeader();

            header.version    = (int)eFileVersions.cXTDVersion;
            header.numXVerts  = TerrainGlobals.getTerrain().getNumXVerts();
            header.numXChunks = (int)(TerrainGlobals.getTerrain().getNumXVerts() / BTerrainQuadNode.cMaxWidth);
            header.tileScale  = TerrainGlobals.getTerrain().getTileScale();

            BBoundingBox simRepBB  = SimGlobals.getSimMain().getBBoxForDecalObjects();
            Vector3      visRepMin = TerrainGlobals.getTerrain().getQuadNodeRoot().getDesc().m_min - new Vector3(0, header.tileScale, 0);
            Vector3      visRepMax = TerrainGlobals.getTerrain().getQuadNodeRoot().getDesc().m_max + new Vector3(0, header.tileScale, 0);

            if (!CoreGlobals.mbLoadTerrainVisRep)
            {
                visRepMin = simRepBB.min;
                visRepMax = simRepBB.max;
            }


            header.worldMin = visRepMin;
            header.worldMax = visRepMax;
            header.endianSwap();


            //write our header first.
            ECF.ECFChunkHolder chunkHolder = new ECF.ECFChunkHolder();
            chunkHolder.mDataMemStream = new MemoryStream();
            BinaryWriter binWriter = new BinaryWriter(chunkHolder.mDataMemStream);

            binWriter.Write(ExportTo360.StructToByteArray(header));
            ExportTo360.mECF.addChunk((int)eXTD_ChunkID.cXTD_XTDHeader, chunkHolder, (int)chunkHolder.mDataMemStream.Length);
            binWriter.Close();
            binWriter = null;
            chunkHolder.Close();
            chunkHolder = null;

            header.endianSwap();


            generateGridChunks(ref header);

            writeAtlasToMemory(ref results);

            writeAOData(ref results);

            writeAlpha(ref results);

            writeTessData(expSettings.RefineTerrain, expSettings.RefineEpsilon, expSettings.RefineMinorityBias, ref results);

            writeLightData(ref expSettings, ref results);

            bool exportOK = ExportTo360.safeECFFileWrite(filename, ".XTD");


            TimeSpan ts = DateTime.Now - start;

            results.totalTime = ts.TotalMinutes;

            return(exportOK);
        }
Exemple #8
0
        private void writeLightData(ref ExportSettings settings, ref ExportResults results)
        {
            if (!LightManager.hasTerrainLightData())
            {
                return;
            }

            DateTime n      = DateTime.Now;
            int      width  = TerrainGlobals.getTerrain().getNumXVerts();
            int      height = TerrainGlobals.getTerrain().getNumZVerts();

            Vector3 [] lht = new Vector3[width * height];

            //CLM this needs to be changed for batch exporting!
            LightManager.rasterTerrainLightsToExportGrid(lht);

            //convert our data to a DXT1 texture!
            //CLM this is swapped all to shit... WTF!?

            byte[] inData = new byte[width * height * 4];
            int    c      = 0;

            //for (int i = 0; i < lht.Length; i++)

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    //as an encoding step, divide by our overbright (2)
                    //now convert back to srgb
                    int     i = x * width + y;
                    Vector3 v = lht[i];
                    v.X = (float)Math.Sqrt(BMathLib.Clamp((float)(v.X * 0.5), 0, 1));
                    v.Y = (float)Math.Sqrt(BMathLib.Clamp((float)(v.Y * 0.5), 0, 1));
                    v.Z = (float)Math.Sqrt(BMathLib.Clamp((float)(v.Z * 0.5), 0, 1));

                    inData[c++] = (byte)(BMathLib.Clamp(v.Z * 255 + 0.5f, 0, 255));
                    inData[c++] = (byte)(BMathLib.Clamp(v.Y * 255 + 0.5f, 0, 255));
                    inData[c++] = (byte)(BMathLib.Clamp(v.X * 255 + 0.5f, 0, 255));
                    inData[c++] = 0;
                }
            }


            byte[] outDat     = null;
            int    outMemSize = 0;

            ExportTo360.toCompressedFormat(inData, width, height, sizeof(UInt32), BDXTFormat.cDXT1, settings.ExportTextureCompressionQuality, ref outDat, ref outMemSize);


            //endianswap this data...
            int count = outMemSize;

            for (int i = 0; i < count - 1; i += 2)
            {
                byte a = outDat[i];
                outDat[i]     = outDat[i + 1];
                outDat[i + 1] = a;
            }

            //tileswap
            byte[] tempbytearray = new byte[outDat.Length];
            outDat.CopyTo(tempbytearray, 0);
            ExportTo360.tileCopy(ref tempbytearray, tempbytearray, (int)width, (int)height, (int)ExportTo360.eTileCopyFormats.cTCFMT_DXT1);
            tempbytearray.CopyTo(outDat, 0);
            tempbytearray = null;

            //WRITE THE CHUNK
            ECF.ECFChunkHolder chunkHolder = new ECF.ECFChunkHolder();
            chunkHolder.mDataMemStream = new MemoryStream();
            BinaryWriter binWriter = new BinaryWriter(chunkHolder.mDataMemStream);

            //just write the DXT1 texture
            binWriter.Write(Xbox_EndianSwap.endSwapI32(outMemSize));
            binWriter.Write(outDat);

            ExportTo360.mECF.addChunk((int)eXTD_ChunkID.cXTD_LightingChunk, chunkHolder, binWriter.BaseStream.Length);
            binWriter.Close();
            binWriter = null;
            chunkHolder.Close();
            chunkHolder = null;

            results.terrainLightingMemorySize = outMemSize;
            TimeSpan ts = DateTime.Now - n;

            results.terrainLightingTime = ts.TotalMinutes;



            lht    = null;
            inData = null;
            outDat = null;
        }