Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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")));
        }
Example #4
0
        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);
            }
        }