cesium-native 0.43.0
Loading...
Searching...
No Matches
Cesium3DTilesContent::GltfConverters Class Reference

Creates GltfConverterResult objects from a a binary content. More...

#include <Cesium3DTilesContent/GltfConverters.h>

Public Types

using ConverterFunction
 A function pointer that can create a GltfConverterResult from a tile binary content.
 

Static Public Member Functions

static void registerMagic (const std::string &magic, ConverterFunction converter)
 Register the given function for the given magic header.
 
static void registerFileExtension (const std::string &fileExtension, ConverterFunction converter)
 Register the given function for the given file extension.
 
static ConverterFunction getConverterByFileExtension (const std::string &filePath)
 Retrieve the converter function that is already registered for the given file extension. If no such function is found, nullptr will be returned.
 
static ConverterFunction getConverterByMagic (const std::span< const std::byte > &content)
 Retrieve the converter function that is registered for the given magic header. If no such function is found, nullptr will be returned.
 
static CesiumAsync::Future< GltfConverterResultconvert (const std::string &filePath, const std::span< const std::byte > &content, const CesiumGltfReader::GltfReaderOptions &options, const AssetFetcher &assetFetcher)
 Creates the GltfConverterResult from the given binary content.
 
static CesiumAsync::Future< GltfConverterResultconvert (const std::span< const std::byte > &content, const CesiumGltfReader::GltfReaderOptions &options, const AssetFetcher &assetFetcher)
 Creates the GltfConverterResult from the given binary content.
 

Detailed Description

Creates GltfConverterResult objects from a a binary content.

The class offers a lookup functionality for registering ConverterFunction instances that can create GltfConverterResult instances from a binary content.

The loaders are registered based on the magic header or the file extension of the input data. The binary data is usually received as a response to a network request, and the first four bytes of the raw data form the magic header. Based on this header or the file extension of the network response, the loader that will be used for processing the input can be looked up.

Definition at line 120 of file GltfConverters.h.

Member Typedef Documentation

◆ ConverterFunction

Initial value:
const std::span<const std::byte>& content,
const AssetFetcher& subprocessor)
A value that will be available in the future, as produced by AsyncSystem.
Definition Promise.h:11
Options for how to read a glTF.
Definition GltfReader.h:50

A function pointer that can create a GltfConverterResult from a tile binary content.

Definition at line 126 of file GltfConverters.h.

Member Function Documentation

◆ convert() [1/2]

static CesiumAsync::Future< GltfConverterResult > Cesium3DTilesContent::GltfConverters::convert ( const std::span< const std::byte > & content,
const CesiumGltfReader::GltfReaderOptions & options,
const AssetFetcher & assetFetcher )
static

Creates the GltfConverterResult from the given binary content.

This will look up the ConverterFunction that can be used to process the given input data, based on all loaders that have been registered with GltfConverters::registerMagic.

It will try to find a loader based on the magic header of the content in the given input. If no such loader is found then an empty GltfConverterResult is returned.

If a matching loader is found, it will be applied to the given input, and the result will be returned.

Parameters
contentThe tile binary content that may contains the magic header to look up the converter and is used to convert to gltf model.
optionsThe CesiumGltfReader::GltfReaderOptions for how to read a glTF.
assetFetcherAn object that can perform recursive asset requests.
Returns
The GltfConverterResult that stores the gltf model converted from the binary data.

◆ convert() [2/2]

static CesiumAsync::Future< GltfConverterResult > Cesium3DTilesContent::GltfConverters::convert ( const std::string & filePath,
const std::span< const std::byte > & content,
const CesiumGltfReader::GltfReaderOptions & options,
const AssetFetcher & assetFetcher )
static

Creates the GltfConverterResult from the given binary content.

This will look up the ConverterFunction that can be used to process the given input data, based on all loaders that have been registered with GltfConverters::registerMagic or GltfConverters::registerFileExtension.

It will first try to find a loader based on the magic header of the content in the given input. If no matching loader is found, then it will look up a loader based on the file extension of filePath of the given input.

If no such loader is found then an empty GltfConverterResult is returned.

If a matching loader is found, it will be applied to the given input, and the result will be returned.

Parameters
filePathThe file path that contains the file extension to look up the converter.
contentThe tile binary content that may contains the magic header to look up the converter and is used to convert to gltf model.
optionsThe CesiumGltfReader::GltfReaderOptions for how to read a glTF.
assetFetcherAn object that can perform recursive asset requests.
Returns
The GltfConverterResult that stores the gltf model converted from the binary data.

◆ getConverterByFileExtension()

static ConverterFunction Cesium3DTilesContent::GltfConverters::getConverterByFileExtension ( const std::string & filePath)
static

Retrieve the converter function that is already registered for the given file extension. If no such function is found, nullptr will be returned.

Parameters
filePathThe file path that contains the file extension.
Returns
The ConverterFunction that is registered with the file extension.

◆ getConverterByMagic()

static ConverterFunction Cesium3DTilesContent::GltfConverters::getConverterByMagic ( const std::span< const std::byte > & content)
static

Retrieve the converter function that is registered for the given magic header. If no such function is found, nullptr will be returned.

The given magic header is a 4-character string. It will be compared to the first 4 bytes of the raw input data, to decide whether the given factory function should be used to create the GltfConverterResult from the input data.

Parameters
contentThe binary tile content that contains the magic header.
Returns
The ConverterFunction that is registered with the magic header.

◆ registerFileExtension()

static void Cesium3DTilesContent::GltfConverters::registerFileExtension ( const std::string & fileExtension,
ConverterFunction converter )
static

Register the given function for the given file extension.

The given string is a file extension including the "." (e.g. ".ext"). It is used for deciding whether the given factory function should be used to create the GltfConverterResult from the input data with the same file extension in its url.

Parameters
fileExtensionThe file extension.
converterThe converter that will be used to create the tile gltf content

◆ registerMagic()

static void Cesium3DTilesContent::GltfConverters::registerMagic ( const std::string & magic,
ConverterFunction converter )
static

Register the given function for the given magic header.

The given magic header is a 4-character string. It will be compared to the first 4 bytes of the raw input data, to decide whether the given factory function should be used to create the GltfConverterResult from the input data.

Parameters
magicThe string describing the magic header.
converterThe converter that will be used to create the tile gltf content.

The documentation for this class was generated from the following file: