Example #1
0
        public void LoadModelsWithGpuMeshInstancingExtension(string fileFilter)
        {
            TestContext.CurrentContext.AttachShowDirLink();
            TestContext.CurrentContext.AttachGltfValidatorLinks();

            var f = TestFiles.GetMeshIntancingModelPaths().FirstOrDefault(item => item.Contains(fileFilter));

            var model = _LoadModel(f, false);

            var ff = System.IO.Path.GetFileNameWithoutExtension(f);

            model.AttachToCurrentTest($"{ff}.loaded.glb");

            // perform roundtrip

            var roundtripDefault = model.DefaultScene
                                   .ToSceneBuilder()                                     // glTF to SceneBuilder
                                   .ToGltf2(Scenes.SceneBuilderSchema2Settings.Default); // SceneBuilder to glTF

            var roundtripInstanced = model.DefaultScene
                                     .ToSceneBuilder()                                               // glTF to SceneBuilder
                                     .ToGltf2(Scenes.SceneBuilderSchema2Settings.WithGpuInstancing); // SceneBuilder to glTF

            // compare bounding spheres

            var modelBounds    = Runtime.MeshDecoder.EvaluateBoundingBox(model.DefaultScene);
            var rtripDefBounds = Runtime.MeshDecoder.EvaluateBoundingBox(roundtripDefault.DefaultScene);
            var rtripGpuBounds = Runtime.MeshDecoder.EvaluateBoundingBox(roundtripInstanced.DefaultScene);

            Assert.AreEqual(modelBounds, rtripDefBounds);
            Assert.AreEqual(modelBounds, rtripGpuBounds);

            // save results

            roundtripDefault.AttachToCurrentTest($"{ff}.roundtrip.default.glb");
            roundtripInstanced.AttachToCurrentTest($"{ff}.roundtrip.instancing.glb");
        }