cesium-native  0.41.0
GltfWriter.h
1 #pragma once
2 
3 #include "CesiumGltfWriter/Library.h"
4 
5 #include <CesiumJsonWriter/ExtensionWriterContext.h>
6 
7 #include <gsl/span>
8 
9 // forward declarations
10 namespace CesiumGltf {
11 struct Model;
12 }
13 
14 namespace CesiumGltfWriter {
15 
20 struct CESIUMGLTFWRITER_API GltfWriterResult {
24  std::vector<std::byte> gltfBytes;
25 
29  std::vector<std::string> errors;
30 
34  std::vector<std::string> warnings;
35 };
36 
40 struct CESIUMGLTFWRITER_API GltfWriterOptions {
45  bool prettyPrint = false;
46 
51  size_t binaryChunkByteAlignment = 4;
52 };
53 
57 class CESIUMGLTFWRITER_API GltfWriter {
58 public:
63 
68 
73 
88  const CesiumGltf::Model& model,
89  const GltfWriterOptions& options = GltfWriterOptions()) const;
90 
104  const CesiumGltf::Model& model,
105  const gsl::span<const std::byte>& bufferData,
106  const GltfWriterOptions& options = GltfWriterOptions()) const;
107 
108 private:
110 };
111 
112 } // namespace CesiumGltfWriter
GltfWriterResult writeGlb(const CesiumGltf::Model &model, const gsl::span< const std::byte > &bufferData, const GltfWriterOptions &options=GltfWriterOptions()) const
Serializes the provided model into a glb byte vector.
GltfWriter()
Constructs a new instance.
GltfWriterResult writeGltf(const CesiumGltf::Model &model, const GltfWriterOptions &options=GltfWriterOptions()) const
Serializes the provided model into a glTF JSON byte vector.
const CesiumJsonWriter::ExtensionWriterContext & getExtensions() const
Gets the context used to control how glTF extensions are written.
CesiumJsonWriter::ExtensionWriterContext & getExtensions()
Gets the context used to control how glTF extensions are written.
Classes for writing glTF models.
Definition: GltfWriter.h:14
Classes for working with glTF models.
Options for how to write a glTF.
Definition: GltfWriter.h:40
The result of writing a glTF with GltfWriter::writeGltf or GltfWriter::writeGlb.
Definition: GltfWriter.h:20
std::vector< std::string > errors
Errors, if any, that occurred during the write process.
Definition: GltfWriter.h:29
std::vector< std::string > warnings
Warnings, if any, that occurred during the write process.
Definition: GltfWriter.h:34
std::vector< std::byte > gltfBytes
The final generated std::vector<std::byte> of the glTF or glb.
Definition: GltfWriter.h:24
The root object for a glTF asset.
Definition: Model.h:14