public void Test_BatchTileset() { var folder = @"..\..\..\..\testassets\BatchTests"; Assert.True(Directory.Exists(folder), "Input folder does not exist!"); var outputDir = "BatchTests"; var files = Directory.GetFiles(folder); // obj Files are zipped with mtl files foreach (var f in files) { var name = Path.GetFileNameWithoutExtension(f); var dir = Path.Combine(folder, name); Directory.CreateDirectory(dir); ExtractZipFile(f, String.Empty, dir); } var gisPosition = new GisPosition { Longitude = 0, Latitude = 0, TransHeight = 0 }; var objFiles = Directory.GetFiles(folder, "*.obj", SearchOption.AllDirectories); var tasks = new Task <string> [objFiles.Length]; for (var i = 0; i < objFiles.Length; i++) { var objFile = objFiles[i]; var dd = Path.GetDirectoryName(objFile); var name = "Batched" + Path.GetFileNameWithoutExtension(dd); var outFolder = Path.Combine(outputDir, name); Directory.CreateDirectory(outFolder); tasks[i] = Task.Run(() => TilesConverter.WriteTilesetFile(objFile, outFolder, gisPosition)); } Task.WaitAll(tasks); var strs = new List <string>(); var tilesetListFile = Path.Combine(outputDir, "tileset.txt"); foreach (var t in tasks) { var res = t.Result; var name = Path.GetFileNameWithoutExtension(res); var dir = Path.GetDirectoryName(res); var bName = Path.GetFileNameWithoutExtension(dir); strs.Add($"loadTileSet('{bName}', 'BatchedTest/{bName}/tileset.json');"); } using (var sw = new StreamWriter(tilesetListFile, true, System.Text.Encoding.UTF8)) { foreach (var s in strs) { sw.WriteLine(s); } sw.Flush(); sw.Close(); } }
/// <summary> /// /// </summary> /// <param name="objFile">obj文件路径</param> /// <param name="modelName">模型名称</param> /// <param name="outputDir">导出的文件夹路径</param> /// <param name="gisPosition">GIS坐标</param> /// <returns></returns> public static string WriteTileset(string objFile, string modelName, string outputDir, GisPosition gisPosition) { var name = modelName; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } return(TilesConverter.WriteTilesetFile(objFile, outputDir, gisPosition)); }
public void Test_WriteTileset() { CheckObjFiles(); var outputDir = "tileset"; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var gisPosition = new GisPosition(); TilesConverter.WriteTilesetFile(TestObjFile, outputDir, gisPosition); Assert.True(File.Exists(Path.Combine(outputDir, "tileset.json"))); }
public void Test_WriteTileset2() { CheckObjFiles(); var outputDir = "tileset2"; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var objParser = new Obj2Gltf.WaveFront.ObjParser(TestObjFile); var objModel = objParser.GetModel(); var gisPosition = new GisPosition(); TilesConverter.WriteTilesetFile(objModel, Path.GetDirectoryName(TestObjFile), outputDir, gisPosition); Assert.True(File.Exists(Path.Combine(outputDir, "tileset.json"))); }