private static void CreateObjFromSelection(ICollection <Sector> sectors, ref WavefrontExportSettings data) { BaseVisualMode mode = new BaseVisualMode(); bool renderingEffectsDisabled = false; if (!General.Settings.EnhancedRenderingEffects) { renderingEffectsDisabled = true; mode.ToggleEnhancedRendering(); } mode.RebuildElementData(); List <BaseVisualSector> visualSectors = new List <BaseVisualSector>(); //create visual geometry foreach (Sector s in sectors) { bool addvs = true; // Check if the sector has, or shares a line with a 3D floor control sector, and ignore it if necessary if (data.ExportForGZDoom && data.IgnoreControlSectors) { foreach (Sidedef sd in s.Sidedefs) { if (sd.Line.Action == 160) { addvs = false; break; } } } if (addvs) { BaseVisualSector bvs = mode.CreateBaseVisualSector(s); if (bvs != null) { visualSectors.Add(bvs); } } } if (visualSectors.Count == 0) { General.ErrorLogger.Add(ErrorType.Error, "OBJ Exporter: no visual sectors to export!"); return; } //sort geometry List <Dictionary <string, List <WorldVertex[]> > > geometryByTexture = SortGeometry(visualSectors, data.SkipTextures, !data.ExportForGZDoom); //restore vm settings if (renderingEffectsDisabled) { mode.ToggleEnhancedRendering(); } mode.Dispose(); //create obj StringBuilder obj = CreateObjGeometry(geometryByTexture, ref data); if (obj.Length == 0) { General.ErrorLogger.Add(ErrorType.Error, "OBJ Exporter: failed to create geometry!"); return; } //add header obj.Insert(0, "o " + General.Map.Options.LevelName + Environment.NewLine); //name obj.Insert(0, "# Created by Ultimate Doom Builder " + Application.ProductVersion + Environment.NewLine + Environment.NewLine); obj.Insert(0, "# " + General.Map.FileTitle + ", map " + General.Map.Options.LevelName + Environment.NewLine); data.Obj = obj.ToString(); string[] textures = new string[geometryByTexture[0].Keys.Count]; geometryByTexture[0].Keys.CopyTo(textures, 0); Array.Sort(textures); data.Textures = textures; string[] flats = new string[geometryByTexture[1].Keys.Count]; geometryByTexture[1].Keys.CopyTo(flats, 0); Array.Sort(flats); data.Flats = flats; data.Valid = true; }
private static void CreateObjFromSelection(ICollection <Sector> sectors, ref WavefrontExportSettings data) { BaseVisualMode mode = new BaseVisualMode(); bool renderingEffectsDisabled = false; if (!General.Settings.GZDoomRenderingEffects) { renderingEffectsDisabled = true; mode.ToggleGZDoomRenderingEffects(); } mode.RebuildElementData(); List <BaseVisualSector> visualSectors = new List <BaseVisualSector>(); //create visual geometry foreach (Sector s in sectors) { BaseVisualSector bvs = mode.CreateBaseVisualSector(s); if (bvs != null) { visualSectors.Add(bvs); } } if (visualSectors.Count == 0) { General.ErrorLogger.Add(ErrorType.Error, "OBJ Exporter: no visual sectors to export!"); return; } //sort geometry List <Dictionary <string, List <WorldVertex[]> > > geometryByTexture = SortGeometry(visualSectors); //restore vm settings if (renderingEffectsDisabled) { mode.ToggleGZDoomRenderingEffects(); } mode.Dispose(); //create obj StringBuilder obj = CreateObjGeometry(geometryByTexture, data); if (obj.Length == 0) { General.ErrorLogger.Add(ErrorType.Error, "OBJ Exporter: failed to create geometry!"); return; } //add header obj.Insert(0, "o " + General.Map.Options.LevelName + Environment.NewLine); //name obj.Insert(0, "# Created by 3DGE Builder " + Application.ProductVersion + Environment.NewLine + Environment.NewLine); obj.Insert(0, "# " + General.Map.FileTitle + ", map " + General.Map.Options.LevelName + Environment.NewLine); data.Obj = obj.ToString(); string[] textures = new string[geometryByTexture[0].Keys.Count]; geometryByTexture[0].Keys.CopyTo(textures, 0); Array.Sort(textures); data.Textures = textures; string[] flats = new string[geometryByTexture[1].Keys.Count]; geometryByTexture[1].Keys.CopyTo(flats, 0); Array.Sort(flats); data.Flats = flats; data.Valid = true; }