cesium-native 0.56.0
Loading...
Searching...
No Matches
GltfReader.h
1#pragma once
2
3#include <CesiumAsync/AsyncSystem.h>
4#include <CesiumAsync/Future.h>
5#include <CesiumAsync/HttpHeaders.h>
6#include <CesiumAsync/IAssetAccessor.h>
7#include <CesiumGltf/ImageAsset.h>
8#include <CesiumGltf/Ktx2TranscodeTargets.h>
9#include <CesiumGltf/Model.h>
10#include <CesiumGltfReader/GltfSharedAssetSystem.h>
11#include <CesiumGltfReader/ImageDecoder.h>
12#include <CesiumGltfReader/Library.h>
13#include <CesiumJsonReader/IExtensionJsonHandler.h>
14#include <CesiumJsonReader/JsonReaderOptions.h>
15
16#include <functional>
17#include <memory>
18#include <optional>
19#include <span>
20#include <string>
21#include <vector>
22
24
29struct CESIUMGLTFREADER_API GltfReaderResult {
33 std::optional<CesiumGltf::Model> model;
34
38 std::vector<std::string> errors;
39
43 std::vector<std::string> warnings;
44};
45
131
135class CESIUMGLTFREADER_API GltfReader {
136public:
141
146
151
160 const std::span<const std::byte>& data,
161 const GltfReaderOptions& options = GltfReaderOptions()) const;
162
176 const std::span<const std::byte>& data,
177 const CesiumAsync::AsyncSystem& asyncSystem,
178 const CesiumAsync::HttpHeaders& headers,
179 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
180 const std::string& baseUrl = {},
181 const GltfReaderOptions& options = GltfReaderOptions()) const;
182
196 const std::span<const std::byte>& data,
197 const CesiumAsync::AsyncSystem& asyncSystem,
198 const std::vector<CesiumAsync::IAssetAccessor::THeader>& headers,
199 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
200 const std::string& baseUrl = {},
201 const GltfReaderOptions& options = GltfReaderOptions()) const;
202
215 const CesiumAsync::AsyncSystem& asyncSystem,
216 const std::string& url,
217 const std::vector<CesiumAsync::IAssetAccessor::THeader>& headers,
218 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
219 const GltfReaderOptions& options = GltfReaderOptions()) const;
220
228 void
230
244 const CesiumAsync::AsyncSystem& asyncSystem,
245 const std::string& baseUrl,
246 const CesiumAsync::HttpHeaders& headers,
247 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
248 const GltfReaderOptions& options,
249 GltfReaderResult&& result);
250
255 [[deprecated(
256 "Use ImageDecoder::readImage instead.")]] static ImageReaderResult
258 const std::span<const std::byte>& data,
259 const CesiumGltf::Ktx2TranscodeTargets& ktx2TranscodeTargets);
260
265 [[deprecated("Use ImageDecoder::generateMipMaps instead.")]] static std::
266 optional<std::string>
268
269private:
271};
272
273} // namespace CesiumGltfReader
A system for managing asynchronous requests and tasks.
Definition AsyncSystem.h:36
A value that will be available in the future, as produced by AsyncSystem.
Definition Future.h:29
GltfReaderResult readGltf(const std::span< const std::byte > &data, const GltfReaderOptions &options=GltfReaderOptions()) const
Reads a glTF or binary glTF (GLB) from a buffer.
GltfReader()
Constructs a new instance.
const CesiumJsonReader::JsonReaderOptions & getExtensions() const
Gets the options controlling how the JSON is read.
static CesiumAsync::Future< GltfReaderResult > resolveExternalData(const CesiumAsync::AsyncSystem &asyncSystem, const std::string &baseUrl, const CesiumAsync::HttpHeaders &headers, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const GltfReaderOptions &options, GltfReaderResult &&result)
Accepts the result of readGltf and resolves any remaining external buffers and images.
void postprocessGltf(GltfReaderResult &readGltf, const GltfReaderOptions &options)
Performs post-load processing on a glTF. The specific operations performed are controlled by the prov...
static ImageReaderResult readImage(const std::span< const std::byte > &data, const CesiumGltf::Ktx2TranscodeTargets &ktx2TranscodeTargets)
Reads an Image from a buffer.
CesiumAsync::Future< GltfReaderResult > loadGltf(const CesiumAsync::AsyncSystem &asyncSystem, const std::string &url, const std::vector< CesiumAsync::IAssetAccessor::THeader > &headers, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const GltfReaderOptions &options=GltfReaderOptions()) const
Reads a glTF or binary glTF file from a URL and resolves external buffers and images.
CesiumAsync::Future< GltfReaderResult > readGltfAndExternalData(const std::span< const std::byte > &data, const CesiumAsync::AsyncSystem &asyncSystem, const CesiumAsync::HttpHeaders &headers, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::string &baseUrl={}, const GltfReaderOptions &options=GltfReaderOptions()) const
Read a glTF or binary glTF (GLB) from a buffer and then resolve external references.
CesiumAsync::Future< GltfReaderResult > readGltfAndExternalData(const std::span< const std::byte > &data, const CesiumAsync::AsyncSystem &asyncSystem, const std::vector< CesiumAsync::IAssetAccessor::THeader > &headers, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::string &baseUrl={}, const GltfReaderOptions &options=GltfReaderOptions()) const
Read a glTF or binary glTF (GLB) from a buffer and then resolve external references.
static std::optional< std::string > generateMipMaps(CesiumGltf::ImageAsset &image)
Generate mipmaps for this image.
CesiumJsonReader::JsonReaderOptions & getOptions()
Gets the options controlling how the JSON is read.
static CesiumUtility::IntrusivePointer< GltfSharedAssetSystem > getDefault()
Obtains an IntrusivePointer to the GltfSharedAssetSystem singleton.
Holds options for reading statically-typed data structures from JSON.
A smart pointer that calls addReference and releaseReference on the controlled object.
std::map< std::string, std::string, CaseInsensitiveCompare > HttpHeaders
Http Headers that maps case-insensitive header key with header value.
Definition HttpHeaders.h:25
Classes for reading glTF models.
Definition GltfReader.h:23
Options for how to read a glTF.
Definition GltfReader.h:49
bool decodeEmbeddedImages
Whether embedded images in CesiumGltf::Model::buffers should be automatically decoded as part of the ...
Definition GltfReader.h:72
bool dequantizeMeshData
Whether the quantized mesh data are dequantized and converted to floating-point values when loading,...
Definition GltfReader.h:104
bool decodeDraco
Whether geometry compressed using the KHR_draco_mesh_compression extension should be automatically de...
Definition GltfReader.h:83
CesiumUtility::IntrusivePointer< GltfSharedAssetSystem > pSharedAssetSystem
Definition GltfReader.h:122
bool resolveExternalStructuralMetadata
Whether the schemaUri property of EXT_structural_metadata will be properly resolved....
Definition GltfReader.h:129
bool clearDecodedDataUrls
Whether data URLs should be cleared after they are successfully decoded.
Definition GltfReader.h:62
bool applyTextureTransform
Whether the texture coordinates of a texture are transformed or not, according to the KHR_texture_tra...
Definition GltfReader.h:110
bool decodeSpz
Whether gaussian splatting data are decompressed as part of the load process, or left in the compress...
Definition GltfReader.h:97
bool resolveExternalImages
Whether external images should be resolved.
Definition GltfReader.h:77
CesiumGltf::Ktx2TranscodeTargets ktx2TranscodeTargets
For each possible input transmission format, this struct names the ideal target gpu-compressed pixel ...
Definition GltfReader.h:116
bool decodeMeshOptData
Whether the mesh data are decompressed as part of the load process, or left in the compressed format ...
Definition GltfReader.h:90
bool decodeDataUrls
Whether data URLs in buffers and images should be automatically decoded as part of the load process.
Definition GltfReader.h:54
The result of reading a glTF model with GltfReader::readGltf.
Definition GltfReader.h:29
std::optional< CesiumGltf::Model > model
The read model, or std::nullopt if the model could not be read.
Definition GltfReader.h:33
std::vector< std::string > errors
Errors, if any, that occurred during the load process.
Definition GltfReader.h:38
std::vector< std::string > warnings
Warnings, if any, that occurred during the load process.
Definition GltfReader.h:43
The result of reading an image with ImageDecoder::readImage.
A 2D image asset, including its pixel data. The image may have mipmaps, and it may be encoded in a GP...
Definition ImageAsset.h:33
For each possible input transmission format, this struct names the ideal target gpu-compressed pixel ...