public void InstanceContentElement() { var model = this.Model; // <example> var avocadoType = new TestContentElem("../../../models/MergeGlTF/Avocado.glb", new BBox3(new Vector3(-0.5, -0.5, 0), new Vector3(0.5, 0.5, 3)), new Vector3(), new Transform(new Vector3(), Vector3.XAxis), 20, BuiltInMaterials.Default, null, true, Guid.NewGuid(), "Avocado Type"); var duckType = new TestContentElem("../../../models/MergeGlTF/Duck.glb", new BBox3(new Vector3(-1, -1, 0), new Vector3(1, 1, 2)), new Vector3(), new Transform(new Vector3(), Vector3.YAxis), .005, BuiltInMaterials.Default, null, true, Guid.NewGuid(), "Duck Type"); for (int i = 0; i < 5; i++) { var newAvo = avocadoType.CreateInstance(new Transform(2 * i, 0, 0), "An Avocado"); model.AddElement(newAvo); } var oneDuck = duckType.CreateInstance(new Transform(new Vector3(5, 0, 0)), "A Duck"); model.AddElement(oneDuck); var twoDuck = duckType.CreateInstance(new Transform(new Vector3(15, 0, 0)), "A Duck"); model.AddElement(twoDuck); // </example> var sw = System.Diagnostics.Stopwatch.StartNew(); model.ToGlTF("./models/ContentInstancing.glb"); var firstRun = sw.Elapsed.TotalSeconds; sw.Restart(); model.ToGlTF("./models/ContentInstancing.gltf", false); var secondRun = sw.Elapsed.TotalSeconds; Assert.True(firstRun > secondRun); // caching should result in faster model generation second time. }
public void InstanceContentElement() { var model = this.Model; // <example> var avocadoType = new TestContentElem("../../../models/MergeGlTF/Avocado.glb", new BBox3(new Vector3(-0.5, -0.5, 0), new Vector3(0.5, 0.5, 3)), new Vector3(), new Transform(new Vector3(), Vector3.XAxis), 20, BuiltInMaterials.Default, null, true, Guid.NewGuid(), "Avocado Type"); var duckType = new TestContentElem("../../../models/MergeGlTF/Duck.glb", new BBox3(new Vector3(-1, -1, 0), new Vector3(1, 1, 2)), new Vector3(), new Transform(new Vector3(), Vector3.YAxis), .005, BuiltInMaterials.Default, null, true, Guid.NewGuid(), "Duck Type"); for (int i = 0; i < 5; i++) { var newAvo = avocadoType.CreateInstance(new Transform(2 * i, 0, 0), "An Avocado"); model.AddElement(newAvo); } var oneDuck = duckType.CreateInstance(new Transform(new Vector3(5, 0, 0)), "A Duck"); model.AddElement(oneDuck); var twoDuck = duckType.CreateInstance(new Transform(new Vector3(15, 0, 0)), "A Duck"); model.AddElement(twoDuck); // </example> model.ToGlTF("./models/ContentInstancing.gltf", false); model.ToGlTF("./models/ContentInstancing.glb"); }