public void Test_MergeTilesets2() { var name = "mergetest2"; var objFolder = MOfficeFolder; Assert.True(Directory.Exists(objFolder), "Input Folder does not exist!"); var outputDir = name; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var gisPosition = new GisPosition(); var lod = true; var objModels = new List <Obj2Gltf.WaveFront.ObjModel>(); foreach (var objFile in Directory.GetFiles(objFolder, "*.obj")) { var op = new Obj2Gltf.WaveFront.ObjParser(objFile); var om = op.GetModel(); objModels.Add(om); } var tileConverter = new TilesConverter(objFolder, objModels, gisPosition, new TilesOptions { OutputFolder = outputDir, MergeTileJsonFiles = true }); var tilesetJson = tileConverter.Run(lod); Assert.True(File.Exists(tilesetJson)); }
public void Test_SplitObj2Tilesets() { CheckObjFiles(); var outputDir = "splitobjmerge"; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var objParser = new Obj2Gltf.WaveFront.ObjParser(TestObjFile); var objModel = objParser.GetModel(); var gisPosition = new GisPosition(); var lod = false; var objModels = objModel.Split(2); var objFolder = Path.GetDirectoryName(TestObjFile); var tileConverter = new TilesConverter(objFolder, objModels, gisPosition, new TilesOptions { OutputFolder = outputDir, MergeTileJsonFiles = true }); var tilesetJson = tileConverter.Run(lod); Assert.True(File.Exists(tilesetJson)); }
public static string MergeMTilesets(string objFolder, string outputDir, GisPosition gisPosition, bool lod) { var tileConverter = new TilesConverter(objFolder, outputDir, gisPosition); return(tileConverter.Run(lod)); //var objFiles = Directory.GetFiles(objFolder, "*.obj"); //var tilesetJson = Utility.MergeTilesets(outputDir, gisPosition, true, objFiles); //return tilesetJson; }
public static string WriteMTilesets(string objFolder, string outputDir, GisPosition gisPosition, bool merge = false) { var tileConverter = new TilesConverter(objFolder, outputDir, gisPosition) { MergeTileJsonFiles = merge }; return(tileConverter.Run()); //var objFiles = Directory.GetFiles(objFolder, "*.obj"); //var tilesetJson = Utility.CombineTilesets(outputDir, gisPosition, objFiles); //return tilesetJson; }
public void Test_MergeTilesets() { var name = "mergetest"; var objFolder = MOfficeFolder; Assert.True(Directory.Exists(objFolder), "Input Folder does not exist!"); var outputDir = name; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var gisPosition = new GisPosition(); var lod = true; var tileConverter = new TilesConverter(objFolder, outputDir, gisPosition); var tilesetJson = tileConverter.Run(lod); Assert.True(File.Exists(tilesetJson)); }
public void Test_CombineTilesets() { var name = "test"; var objFolder = MOfficeFolder; Assert.True(Directory.Exists(objFolder), "Input Folder does not exist!"); var outputDir = name; //"mtileset"; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var gisPosition = new GisPosition(); var tileConverter = new TilesConverter(objFolder, outputDir, gisPosition) { MergeTileJsonFiles = false }; var tilesetJson = tileConverter.Run(); Assert.True(File.Exists(tilesetJson)); }
public static string SplitObjAndMergeMTilesetsWithZip(string objZipFile, string outputDir, GisPosition gisPosition, int splitLevel = 2) { var name = Path.GetFileNameWithoutExtension(objZipFile); var unzipDir = Path.Combine(Path.GetDirectoryName(objZipFile), name); if (Directory.Exists(unzipDir)) { Directory.Delete(unzipDir, true); } Directory.CreateDirectory(unzipDir); try { ExtractZipFile(objZipFile, unzipDir); var objFile = Path.Combine(unzipDir, "model.obj"); if (!File.Exists(objFile)) { objFile = Path.Combine(unzipDir, name + ".obj"); } if (!File.Exists(objFile)) { throw new FileNotFoundException("Obj file not found", objFile); } var tilesOpts = new TilesOptions { MergeTileJsonFiles = true, OutputFolder = outputDir, WriteChildTileJson = false }; using (var objParser = new Obj2Gltf.WaveFront.ObjParser(objFile)) { var objModel = objParser.GetModel(); var objModels = objModel.Split(splitLevel); var tilesConverter = new TilesConverter(unzipDir, objModels, gisPosition, tilesOpts); return(tilesConverter.Run()); } } finally { Directory.Delete(unzipDir, true); } }