diff --git a/README.md b/README.md index f863e68..bcaeffc 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,10 @@ Tool parameters: --use_i3dm (optional - default false) Use I3dm format - only first model will be processed (false creates Cmpt) --boundingvolume_heights (option - default: 0,10) - Tile boundingVolume heights (min, max) in meters. The heights will be added to the z_min and z_max values of the input geometries. + +--tileset_version (optional - default "") - Tileset version ``` + # Docker See https://hub.docker.com/r/geodan/i3dm.export diff --git a/src/Options.cs b/src/Options.cs index 8b8bc7e..c6d1212 100644 --- a/src/Options.cs +++ b/src/Options.cs @@ -39,6 +39,10 @@ public class Options [Option("boundingvolume_heights", Required = false, Default = "0,10", HelpText = "Tile boundingVolume heights (min, max) in meters")] public string BoundingVolumeHeights { get; set; } + + [Option("tileset_version", Required = false, Default = "", HelpText = "Tileset version")] + public string TilesetVersion { get; set; } + } diff --git a/src/Program.cs b/src/Program.cs index df059d5..f246147 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -31,12 +31,17 @@ static void Main(string[] args) SqlMapper.AddTypeHandler(new JArrayTypeHandler()); var version = Assembly.GetExecutingAssembly().GetName().Version; + var tilesetVersion = o.TilesetVersion; var stopWatch = new Stopwatch(); stopWatch.Start(); Console.WriteLine("Tool: I3dm.export"); Console.WriteLine("Version: " + version); + if (!tilesetVersion.Equals(string.Empty)) + { + Console.WriteLine($"Tileset version: {tilesetVersion}"); + } Console.WriteLine($"Exporting instances from {o.Table}..."); Console.WriteLine($"Use GPU instancing: {o.UseGpuInstancing}"); @@ -133,7 +138,7 @@ static void Main(string[] args) var subtreeLevels = subtreeFiles.Count > 1 ? ((Tile)subtreeFiles.ElementAt(1).Key).Z : 2; var availableLevels = tiles.Max(t => t.Z) + 1; - var tilesetjson = TreeSerializer.ToImplicitTileset(rootBoundingVolumeRegion, o.GeometricError, availableLevels, subtreeLevels, version, (bool)o.UseGpuInstancing, (bool)o.UseI3dm); + var tilesetjson = TreeSerializer.ToImplicitTileset(rootBoundingVolumeRegion, o.GeometricError, availableLevels, subtreeLevels, version, (bool)o.UseGpuInstancing, (bool)o.UseI3dm, tilesetVersion); var file = $"{o.Output}{Path.AltDirectorySeparatorChar}tileset.json"; Console.WriteLine($"Subtree files written: {subtreeFiles.Count}"); Console.WriteLine("SubtreeLevels: " + subtreeLevels); diff --git a/src/Tileset/TilesetClasses.cs b/src/Tileset/TilesetClasses.cs index 5774fad..74d6b9a 100644 --- a/src/Tileset/TilesetClasses.cs +++ b/src/Tileset/TilesetClasses.cs @@ -5,9 +5,9 @@ namespace i3dm.export.Tileset; public class TileSet { + public Asset asset { get; set; } public double geometricError { get; set; } public Root root { get; set; } - public Asset asset { get; set; } } public class Child : ICloneable @@ -76,4 +76,6 @@ public class Asset public string generator { get; set; } public string version { get; set; } + + public string tilesetVersion { get; set; } } \ No newline at end of file diff --git a/src/TreeSerializer.cs b/src/TreeSerializer.cs index b2c6e0b..102b294 100644 --- a/src/TreeSerializer.cs +++ b/src/TreeSerializer.cs @@ -6,13 +6,17 @@ namespace i3dm.export; public static class TreeSerializer { - public static string ToImplicitTileset(double[] box, double geometricError, int availableLevels, int subtreeLevels, Version version, bool useGpuInstancing = false, bool useI3dm = false) + public static string ToImplicitTileset(double[] box, double geometricError, int availableLevels, int subtreeLevels, Version version, bool useGpuInstancing = false, bool useI3dm = false, string tilesetVersion = "") { var tileset = new TileSet { asset = new Asset() { version = "1.1", generator = $"i3dm.export {version}" }, geometricError = geometricError }; + if (!tilesetVersion.Equals(string.Empty)) + { + tileset.asset.tilesetVersion = tilesetVersion; + } var root = GetRoot(geometricError, box, "ADD"); var extension = useGpuInstancing ? "glb" : "cmpt"; if(useI3dm)