Controllers/AbstractExportController.cs
/// <summary>
/// Export an entire dream to a 3D format with textures.
/// </summary>
/// <param name="dream">The dream we're exporting.</param>
/// <param name="combineChunks">Whether or not chunks should be combined into a single mesh.</param>
/// <param name="exportFormat">The mesh format to export the level mesh in.</param>
/// <param name="exportDirectory">The directory we're exporting meshes to.</param>
Export an entire dream to a 3D format with textures.
Export an entire dream to a 3D format with textures .
public void ExportDream(Dream dream, bool combineChunks, MeshExportFormat exportFormat, string exportDirectory)
        {
            Log.Information($"Exporting dream to: {exportDirectory}");
            Log.Information($"Dream width: {dream.LevelWidth}");
            Directory.CreateDirectory(exportDirectory);
            List<IRenderable> chunkRenderables = new List<IRenderable>();
            for (int i = 0; i < dream.Chunks.Count; i++)
            {
                Log.Information($"Processing dream chunk {i + 1}/{dream.Chunks.Count}...");
                var lbdChunk = dream.Chunks[i];
                var chunkRenderable = HeadlessMesh.CombineMeshes(lbdChunk.TileLayout.ToArray());
                if (dream.LevelWidth > 0)
                {
                    int xPos = i % dream.LevelWidth;
                    int yPos = i / dream.LevelWidth;
                    int xMod = 0;
                    if (yPos % 2 == 1)
                    {
                        xMod = Dream.CHUNK_DIMENSION / 2; 
                    }
                    chunkRenderable.Transform.Position = new Vector3(xPos * Dream.CHUNK_DIMENSION - xMod, 0,
                        yPos * Dream.CHUNK_DIMENSION);
                }
                chunkRenderables.Add(chunkRenderable);
            }
            string pathToLevel = Path.Combine(exportDirectory, "dream");
            if (combineChunks)
            {
                IRenderable dreamRenderable = HeadlessMesh.CombineMeshes(chunkRenderables.ToArray());
                ExportMesh(dreamRenderable, pathToLevel, exportFormat);
            }
            else
            {
                ExportMeshes(chunkRenderables, pathToLevel, exportFormat);
            }
            string pathToTextureSet = Path.Combine(exportDirectory, "textureset");
            string[] textureSetNames = { "-normal.png", "-kanji.png", "-downer.png", "-upper.png" };
            for (int i = 0; i < 4; i++)
            {
                Log.Information($"Exporting texture set {i + 1}/4...");
                var textureSetTix = dream.TextureSets[i].Document;
                string exportPath = pathToTextureSet + textureSetNames[i];
                ExportImages(textureSetTix, exportPath, separate: false, ImageFormat.Png);
            }
            Log.Information("Dream export complete");
        }
public void ExportDream ( Dream dream , bool combineChunks , MeshExportFormat exportFormat , string exportDirectory ) { Log . Information ( $" Exporting dream to:  { exportDirectory } " ) ; Log . Information ( $" Dream width:  { dream . LevelWidth } " ) ; Directory . CreateDirectory ( exportDirectory ) ; List < IRenderable > chunkRenderables = new List < IRenderable > ( ) ; for ( int i = 0 ; i < dream . Chunks . Count ; i ++ ) { Log . Information ( $" Processing dream chunk  { i + 1 } / { dream . Chunks . Count } ... " ) ; var lbdChunk = dream . Chunks [ i ] ; var chunkRenderable = HeadlessMesh . CombineMeshes ( lbdChunk . TileLayout . ToArray ( ) ) ; if ( dream . LevelWidth > 0 ) { int xPos = i % dream . LevelWidth ; int yPos = i / dream . LevelWidth ; int xMod = 0 ; if ( yPos % 2 == 1 ) { xMod = Dream . CHUNK_DIMENSION / 2 ; } chunkRenderable . Transform . Position = new Vector3 ( xPos * Dream . CHUNK_DIMENSION - xMod , 0 , yPos * Dream . CHUNK_DIMENSION ) ; } chunkRenderables . Add ( chunkRenderable ) ; } string pathToLevel = Path . Combine ( exportDirectory , " " ) ; if ( combineChunks ) { IRenderable dreamRenderable = HeadlessMesh . CombineMeshes ( chunkRenderables . ToArray ( ) ) ; ExportMesh ( dreamRenderable , pathToLevel , exportFormat ) ; } else { ExportMeshes ( chunkRenderables , pathToLevel , exportFormat ) ; } string pathToTextureSet = Path . Combine ( exportDirectory , " " ) ; string [ ] textureSetNames = { " " , " " , " " , " " } ; for ( int i = 0 ; i < 4 ; i ++ ) { Log . Information ( $" Exporting texture set  { i + 1 } /4... " ) ; var textureSetTix = dream . TextureSets [ i ] . Document ; string exportPath = pathToTextureSet + textureSetNames [ i ] ; ExportImages ( textureSetTix , exportPath , separate : false , ImageFormat . Png ) ; } Log . Information ( " " ) ; }
Export an entire dream to a 3D format with textures.
Export an entire dream to a 3D format with textures .
// create the directory // combine tilelayouts of each LBDDocument into single renderables // position the LBD chunk based on tiling (if we're tiling) // handle staggered tiling, every other row // stagger by half the width of a chunk // if we're combining chunks, we now need to combine everything into a single renderable // otherwise we can export the list of chunk renderables // now, export each TIXDocument texture set as a combined VRAM export
dream
Dream
The dream we're exporting.
The dream we ' re exporting .
combineChunks
bool
Whether or not chunks should be combined into a single mesh.
Whether or not chunks should be combined into a single mesh .
exportFormat
MeshExportFormat
The mesh format to export the level mesh in.
The mesh format to export the level mesh in .
exportDirectory
string
The directory we're exporting meshes to.
The directory we ' re exporting meshes to .