/// <summary> /// Converts this <see cref="SceneBuilder"/> instance into a <see cref="ModelRoot"/> instance. /// </summary> /// <param name="useStridedBuffers">True to generate strided vertex buffers whenever possible.</param> /// <returns>A new <see cref="ModelRoot"/> instance.</returns> public ModelRoot ToSchema2(bool useStridedBuffers = true) { var context = new Schema2SceneBuilder(); var dstModel = ModelRoot.CreateModel(); context.AddGeometryResources(dstModel, new[] { this }, useStridedBuffers); var dstScene = dstModel.UseScene(0); dstScene.Name = this.Name; context.AddScene(dstScene, this); return(dstModel); }
/// <summary> /// Converts this <see cref="SceneBuilder"/> instance into a <see cref="ModelRoot"/> instance. /// </summary> /// <param name="useStridedBuffers">True to generate strided vertex buffers whenever possible.</param> /// <returns>A new <see cref="ModelRoot"/> instance.</returns> public ModelRoot ToGltf2(SceneBuilderSchema2Settings settings) { var context = new Schema2SceneBuilder(); var dstModel = ModelRoot.CreateModel(); context.AddGeometryResources(dstModel, new[] { this }, settings); var dstScene = dstModel.UseScene(0); dstScene.Name = this.Name; context.AddScene(dstScene, this); dstModel.DefaultScene = dstScene; return(dstModel); }
/// <summary> /// Convertes a collection of <see cref="SceneBuilder"/> instances to a single <see cref="ModelRoot"/> instance. /// </summary> /// <param name="srcScenes">A collection of scenes</param> /// <param name="useStridedBuffers">True to generate strided vertex buffers whenever possible.</param> /// <returns>A new <see cref="ModelRoot"/> instance.</returns> public static ModelRoot ToSchema2(IEnumerable <SceneBuilder> srcScenes, SceneBuilderSchema2Settings settings) { Guard.NotNull(srcScenes, nameof(srcScenes)); var context = new Schema2SceneBuilder(); var dstModel = ModelRoot.CreateModel(); context.AddGeometryResources(dstModel, srcScenes, settings); foreach (var srcScene in srcScenes) { var dstScene = dstModel.UseScene(dstModel.LogicalScenes.Count); dstScene.Name = srcScene.Name; context.AddScene(dstScene, srcScene); } return(dstModel); }
/// <summary> /// Converts a collection of <see cref="SceneBuilder"/> instances to a single <see cref="ModelRoot"/> instance. /// </summary> /// <param name="srcScenes">A collection of scenes</param> /// <param name="settings">Conversion settings.</param> /// <returns>A new <see cref="ModelRoot"/> instance.</returns> public static ModelRoot ToGltf2(IEnumerable <SceneBuilder> srcScenes, SceneBuilderSchema2Settings settings) { Guard.NotNull(srcScenes, nameof(srcScenes)); var context = new Schema2SceneBuilder(); var dstModel = ModelRoot.CreateModel(); context.AddGeometryResources(dstModel, srcScenes, settings); foreach (var srcScene in srcScenes) { var dstScene = dstModel.UseScene(dstModel.LogicalScenes.Count); srcScene.TryCopyNameAndExtrasTo(dstScene); context.AddScene(dstScene, srcScene); } dstModel.DefaultScene = dstModel.LogicalScenes[0]; return(dstModel); }