public void ReadFirstCompositeTest()
        {
            // arrange
            // source: https://github.com/CesiumGS/cesium/tree/master/Specs/Data/Cesium3DTiles/Composite/Composite
            var cmptfile = File.OpenRead(@"testfixtures/composite.cmpt");

            Assert.IsTrue(cmptfile != null);

            // act. This cmpt contains a batched model and an instanced model
            var cmpt = CmptReader.Read(cmptfile);

            // assert
            Assert.IsTrue(cmpt != null);
            Assert.IsTrue(cmpt.CmptHeader.Magic == expectedMagicHeader);
            Assert.IsTrue(cmpt.CmptHeader.Version == expectedVersionHeader);
            Assert.IsTrue(cmpt.CmptHeader.ByteLength == 13472); // The length of the entire Composite tile, including this header and each inner tile, in bytes.
            Assert.IsTrue(cmpt.CmptHeader.TilesLength == 2);
            Assert.IsTrue(cmpt.Tiles.Count() == 2);
            Assert.IsTrue(cmpt.Magics.ToArray()[0] == "b3dm");
            Assert.IsTrue(cmpt.Magics.ToArray()[1] == "i3dm");

            var b3dm = B3dmReader.ReadB3dm(new MemoryStream(cmpt.Tiles.ToArray()[0]));

            Assert.IsTrue(b3dm.FeatureTableJson == "{\"BATCH_LENGTH\":10,\"RTC_CENTER\":[1215012.8988049095,-4736313.0423059845,4081604.3368623317]}");
            Assert.IsTrue(b3dm.GlbData != null);


            var i3dm = I3dmReader.Read(new MemoryStream(cmpt.Tiles.ToArray()[1]));

            Assert.IsTrue(i3dm.Positions.Count == 25);
        }
        public void ReadTrafficCompositeTest()
        {
            var cmptfile = File.OpenRead(@"testfixtures/tile_0_14.cmpt");

            Assert.IsTrue(cmptfile != null);
            var cmpt = CmptReader.Read(cmptfile);

            Assert.IsTrue(cmpt.Tiles.Count() == 2);
        }
Exemple #3
0
        public void ReadCmptest()
        {
            var cmptfile = File.OpenRead(@"testfixtures/0_0_0_0.cmpt");

            Assert.IsTrue(cmptfile != null);
            var cmpt = CmptReader.Read(cmptfile);

            Assert.IsTrue(cmpt.Tiles.Count() == 5);
        }
Exemple #4
0
        public void GetCompositeTileTest()
        {
            // arrange
            var instances = new List <Instance>();
            var instance  = new Instance();

            instance.Position = new Wkx.Point(1, 2);
            instance.Scale    = 1;
            instance.Model    = "box.glb";
            instances.Add(instance);

            var instance2 = new Instance();

            instance2.Position = new Wkx.Point(3, 4);
            instance2.Scale    = 1;
            instance2.Model    = "box1.glb";
            instances.Add(instance2);

            var instance3 = new Instance();

            instance3.Position = new Wkx.Point(5, 6);
            instance3.Scale    = 1;
            instance3.Model    = "box1.glb";
            instances.Add(instance3);

            // act
            var tile = TileHandler.GetTile(instances, UseExternalModel: true);

            Assert.IsTrue(tile.isI3dm == false);
            var cmpt = CmptReader.Read(new MemoryStream(tile.tile));

            // assert
            Assert.IsTrue(cmpt.Tiles.Count == 2);
            var i3dm0 = I3dmReader.Read(new MemoryStream(cmpt.Tiles[0]));

            Assert.IsTrue(i3dm0.Positions.Count == 1);
            Assert.IsTrue(i3dm0.GlbUrl == "box.glb");
            Assert.IsTrue(i3dm0.Positions[0] == new Vector3(1, 2, 0));

            var i3dm1 = I3dmReader.Read(new MemoryStream(cmpt.Tiles[1]));

            Assert.IsTrue(i3dm1.Positions.Count == 2);
            Assert.IsTrue(i3dm1.GlbUrl == "box1.glb");
            Assert.IsTrue(i3dm1.Positions[0] == new Vector3(3, 4, 0));
            Assert.IsTrue(i3dm1.Positions[1] == new Vector3(5, 6, 0));
        }
        public void ReadCompositeOfInstancedTest()
        {
            // source: https://github.com/CesiumGS/cesium/blob/master/Specs/Data/Cesium3DTiles/Composite/CompositeOfInstanced/
            var cmptfile = File.OpenRead(@"testfixtures/compositeOfInstanced.cmpt");

            Assert.IsTrue(cmptfile != null);
            var cmpt = CmptReader.Read(cmptfile);

            Assert.IsTrue(cmpt != null);
            Assert.IsTrue(cmpt.CmptHeader.Magic == expectedMagicHeader);
            Assert.IsTrue(cmpt.CmptHeader.Version == expectedVersionHeader);
            Assert.IsTrue(cmpt.CmptHeader.TilesLength == 2);

            var i3dm = I3dmReader.Read(new MemoryStream(cmpt.Tiles.First()));

            Assert.IsTrue(i3dm.Positions.Count == 25);
        }
        public void WriteFromInnerTiles()
        {
            // arrange
            var tile0 = File.ReadAllBytes(@"./testfixtures/inner/tile0.i3dm");
            var tile1 = File.ReadAllBytes(@"./testfixtures/inner/tile1.i3dm");

            var tiles = new List <byte[]>();

            tiles.Add(tile0);
            tiles.Add(tile1);

            // act
            var cmptBytes = CmptWriter.Write(tiles);

            // assert
            var cmpt = CmptReader.Read(new MemoryStream(cmptBytes));

            Assert.IsTrue(cmpt.Tiles.Count() == 2);
        }
        public void MultipleInnertilesCmptWriterTest()
        {
            // arrange
            var treeUrlGlb = "https://bertt.github.io/mapbox_3dtiles_samples/samples/instanced/trees_external_gltf/tree.glb";
            var pos1       = new Vector3(100, 101, 102);
            var pos2       = new Vector3(200, 201, 202);
            var positions  = new List <Vector3>()
            {
                pos1, pos2
            };

            var i3dm = new I3dm.Tile.I3dm(positions, treeUrlGlb);

            i3dm.RtcCenter = new Vector3(100, 100, 100);

            var i3dm1 = new I3dm.Tile.I3dm(positions, treeUrlGlb);

            i3dm1.RtcCenter = new Vector3(200, 200, 200);

            var i3dmBytes = I3dmWriter.Write(i3dm);

            File.WriteAllBytes(@"d:\aaa\i3dmvalid.i3dm", i3dmBytes);

            var i3dm1Bytes = I3dmWriter.Write(i3dm1);

            var tiles = new List <byte[]>();

            tiles.Add(i3dmBytes);
            tiles.Add(i3dm1Bytes);

            // act
            var cmptBytes = CmptWriter.Write(tiles);

            // assert
            Assert.IsTrue(cmptBytes.Length > 0);

            var ms   = new MemoryStream(cmptBytes);
            var cmpt = CmptReader.Read(ms);

            Assert.IsTrue(cmpt.Tiles.Count() == 2);
        }