cesium-native 0.43.0
Loading...
Searching...
No Matches
CesiumGltf::Model Struct Reference

This class is not meant to be instantiated directly. Use Model instead. More...

#include <CesiumGltf/Model.h>

Inheritance diagram for CesiumGltf::Model:
CesiumGltf::ModelSpec CesiumUtility::ExtensibleObject

Public Types

typedef void ForEachRootNodeInSceneCallback(Model &gltf, Node &node)
 A callback function for forEachRootNodeInScene.
 
typedef void ForEachRootNodeInSceneConstCallback(const Model &gltf, const Node &node)
 A callback function for forEachRootNodeInScene.
 
typedef void ForEachNodeInSceneCallback(Model &gltf, Node &node, const glm::dmat4 &transform)
 A callback function for forEachNodeInScene.
 
typedef void ForEachNodeInSceneConstCallback(const Model &gltf, const Node &node, const glm::dmat4 &transform)
 A callback function for forEachNodeInScene.
 
typedef void ForEachPrimitiveInSceneCallback(Model &gltf, Node &node, Mesh &mesh, MeshPrimitive &primitive, const glm::dmat4 &transform)
 A callback function for forEachPrimitiveInScene.
 
typedef void ForEachPrimitiveInSceneConstCallback(const Model &gltf, const Node &node, const Mesh &mesh, const MeshPrimitive &primitive, const glm::dmat4 &transform)
 A callback function for forEachPrimitiveInScene.
 

Public Member Functions

CesiumUtility::ErrorList merge (Model &&rhs)
 Merges another model into this one.
 
void forEachRootNodeInScene (int32_t sceneID, std::function< ForEachRootNodeInSceneCallback > &&callback)
 Apply the given callback to the root nodes of the scene.
 
void forEachRootNodeInScene (int32_t sceneID, std::function< ForEachRootNodeInSceneConstCallback > &&callback) const
 Apply the given callback to the root nodes of the scene.
 
void forEachNodeInScene (int32_t sceneID, std::function< ForEachNodeInSceneCallback > &&callback)
 Apply the given callback to all nodes in the scene.
 
void forEachNodeInScene (int32_t sceneID, std::function< ForEachNodeInSceneConstCallback > &&callback) const
 Apply the given callback to all nodes in the scene.
 
void forEachPrimitiveInScene (int32_t sceneID, std::function< ForEachPrimitiveInSceneCallback > &&callback)
 Apply the given callback to all relevant primitives.
 
void forEachPrimitiveInScene (int32_t sceneID, std::function< ForEachPrimitiveInSceneConstCallback > &&callback) const
 Apply the given callback to all relevant primitives.
 
void generateMissingNormalsSmooth ()
 Fills in smooth normals for any primitives with missing normals.
 
void addExtensionUsed (const std::string &extensionName)
 Adds an extension to the ModelSpec::extensionsUsed property, if it is not already present.
 
void addExtensionRequired (const std::string &extensionName)
 Adds an extension to the ModelSpec::extensionsRequired property, if it is not already present.
 
void removeExtensionUsed (const std::string &extensionName)
 Removes an extension from the ModelSpec::extensionsUsed property.
 
void removeExtensionRequired (const std::string &extensionName)
 Removes an extension from the ModelSpec::extensionsRequired property.
 
bool isExtensionUsed (const std::string &extensionName) const noexcept
 Determines whether a given extension name is listed in the model's ModelSpec::extensionsUsed property.
 
bool isExtensionRequired (const std::string &extensionName) const noexcept
 Determines whether a given extension name is listed in the model's ModelSpec::extensionsRequired property.
 
- Public Member Functions inherited from CesiumGltf::ModelSpec
int64_t getSizeBytes () const
 Calculates the size in bytes of this object, including the contents of all collections, pointers, and strings. This will NOT include the size of any extensions attached to the object. Calling this method may be slow as it requires traversing the object's entire structure.
 
- Public Member Functions inherited from CesiumUtility::ExtensibleObject
template<typename T >
bool hasExtension () const noexcept
 Checks if an extension exists given its static type.
 
template<typename T >
const T * getExtension () const noexcept
 Gets an extension given its static type.
 
template<typename T >
T * getExtension () noexcept
 Gets an extension given its static type.
 
const JsonValuegetGenericExtension (const std::string &extensionName) const noexcept
 Gets a generic extension with the given name as a CesiumUtility::JsonValue.
 
JsonValuegetGenericExtension (const std::string &extensionName) noexcept
 Gets a generic extension with the given name as a CesiumUtility::JsonValue.
 
template<typename T , typename... ConstructorArgumentTypes>
T & addExtension (ConstructorArgumentTypes &&... constructorArguments)
 Adds a statically-typed extension to this object.
 
template<typename T >
void removeExtension ()
 Removes a statically-typed extension from this object.
 
int64_t getSizeBytes () const
 Calculates the size in bytes of this ExtensibleObject, including all of its extras but NOT including its extensions. Calling this method may be slow as it requires traversing the entire object.
 

Static Public Member Functions

template<typename T >
static const T & getSafe (const std::vector< T > &items, int32_t index)
 Safely gets the element with a given index, returning a default instance if the index is outside the range.
 
template<typename T >
static const T * getSafe (const std::vector< T > *pItems, int32_t index) noexcept
 Safely gets a pointer to the element with a given index, returning nullptr if the index is outside the range.
 
template<typename T >
static T * getSafe (std::vector< T > *pItems, int32_t index) noexcept
 Safely gets a pointer to the element with a given index, returning nullptr if the index is outside the range.
 

Additional Inherited Members

- Public Attributes inherited from CesiumGltf::ModelSpec
std::vector< std::string > extensionsUsed
 Names of glTF extensions used in this asset.
 
std::vector< std::string > extensionsRequired
 Names of glTF extensions required to properly load this asset.
 
std::vector< CesiumGltf::Accessoraccessors
 An array of accessors.
 
std::vector< CesiumGltf::Animationanimations
 An array of keyframe animations.
 
CesiumGltf::Asset asset
 Metadata about the glTF asset.
 
std::vector< CesiumGltf::Bufferbuffers
 An array of buffers.
 
std::vector< CesiumGltf::BufferViewbufferViews
 An array of bufferViews.
 
std::vector< CesiumGltf::Cameracameras
 An array of cameras.
 
std::vector< CesiumGltf::Imageimages
 An array of images.
 
std::vector< CesiumGltf::Materialmaterials
 An array of materials.
 
std::vector< CesiumGltf::Meshmeshes
 An array of meshes.
 
std::vector< CesiumGltf::Nodenodes
 An array of nodes.
 
std::vector< CesiumGltf::Samplersamplers
 An array of samplers.
 
int32_t scene = -1
 The index of the default scene.
 
std::vector< CesiumGltf::Scenescenes
 An array of scenes.
 
std::vector< CesiumGltf::Skinskins
 An array of skins.
 
std::vector< CesiumGltf::Texturetextures
 An array of textures.
 
- Public Attributes inherited from CesiumUtility::ExtensibleObject
std::unordered_map< std::string, std::any > extensions
 The extensions attached to this object.
 
JsonValue::Object extras
 Application-specific data.
 
JsonValue::Object unknownProperties
 Unknown properties that exist on this object but do not have any representation in the statically-typed classes.
 
- Static Public Attributes inherited from CesiumGltf::ModelSpec
static constexpr const char * TypeName = "Model"
 The original name of this type.
 
- Protected Member Functions inherited from CesiumGltf::ModelSpec
 ModelSpec ()=default
 This class is not meant to be instantiated directly. Use Model instead.
 

Detailed Description

This class is not meant to be instantiated directly. Use Model instead.

Definition at line 14 of file Model.h.

Member Typedef Documentation

◆ ForEachNodeInSceneCallback

void CesiumGltf::Model::ForEachNodeInSceneCallback(Model &gltf, Node &node, const glm::dmat4 &transform)

A callback function for forEachNodeInScene.

Definition at line 73 of file Model.h.

◆ ForEachNodeInSceneConstCallback

void CesiumGltf::Model::ForEachNodeInSceneConstCallback(const Model &gltf, const Node &node, const glm::dmat4 &transform)

A callback function for forEachNodeInScene.

Definition at line 105 of file Model.h.

◆ ForEachPrimitiveInSceneCallback

void CesiumGltf::Model::ForEachPrimitiveInSceneCallback(Model &gltf, Node &node, Mesh &mesh, MeshPrimitive &primitive, const glm::dmat4 &transform)

A callback function for forEachPrimitiveInScene.

Definition at line 118 of file Model.h.

◆ ForEachPrimitiveInSceneConstCallback

void CesiumGltf::Model::ForEachPrimitiveInSceneConstCallback(const Model &gltf, const Node &node, const Mesh &mesh, const MeshPrimitive &primitive, const glm::dmat4 &transform)

A callback function for forEachPrimitiveInScene.

Definition at line 153 of file Model.h.

◆ ForEachRootNodeInSceneCallback

void CesiumGltf::Model::ForEachRootNodeInSceneCallback(Model &gltf, Node &node)

A callback function for forEachRootNodeInScene.

Definition at line 33 of file Model.h.

◆ ForEachRootNodeInSceneConstCallback

void CesiumGltf::Model::ForEachRootNodeInSceneConstCallback(const Model &gltf, const Node &node)

A callback function for forEachRootNodeInScene.

Definition at line 39 of file Model.h.

Member Function Documentation

◆ addExtensionRequired()

void CesiumGltf::Model::addExtensionRequired ( const std::string & extensionName)

Adds an extension to the ModelSpec::extensionsRequired property, if it is not already present.

Calling this function also adds the extension to extensionsUsed, if it's not already present.

Parameters
extensionNameThe name of the required extension.

◆ addExtensionUsed()

void CesiumGltf::Model::addExtensionUsed ( const std::string & extensionName)

Adds an extension to the ModelSpec::extensionsUsed property, if it is not already present.

Parameters
extensionNameThe name of the used extension.

◆ forEachNodeInScene() [1/2]

void CesiumGltf::Model::forEachNodeInScene ( int32_t sceneID,
std::function< ForEachNodeInSceneCallback > && callback )

Apply the given callback to all nodes in the scene.

If the given sceneID is non-negative and exists in the given glTF, then the given callback will be applied to all nodes in this scene.

If the given sceneId is negative, then the nodes that the callback will be applied to depends on the structure of the glTF model:

  • If the glTF model has a default scene, then it will be applied to all nodes in the default scene.
  • Otherwise, it will be applied to all nodes in the first scene.
  • Otherwise (if the glTF model does not contain any scenes), it will be applied to the first node.
  • Otherwise (if there are no scenes and no nodes), then this method will do nothing.
Parameters
sceneIDThe scene ID (index)
callbackThe callback to apply

◆ forEachNodeInScene() [2/2]

void CesiumGltf::Model::forEachNodeInScene ( int32_t sceneID,
std::function< ForEachNodeInSceneConstCallback > && callback ) const

Apply the given callback to all nodes in the scene.

If the given sceneID is non-negative and exists in the given glTF, then the given callback will be applied to all nodes in this scene.

If the given sceneId is negative, then the nodes that the callback will be applied to depends on the structure of the glTF model:

  • If the glTF model has a default scene, then it will be applied to all nodes in the default scene.
  • Otherwise, it will be applied to all nodes in the first scene.
  • Otherwise (if the glTF model does not contain any scenes), it will be applied to the first node.
  • Otherwise (if there are no scenes and no nodes), then this method will do nothing.
Parameters
sceneIDThe scene ID (index)
callbackThe callback to apply

◆ forEachPrimitiveInScene() [1/2]

void CesiumGltf::Model::forEachPrimitiveInScene ( int32_t sceneID,
std::function< ForEachPrimitiveInSceneCallback > && callback )

Apply the given callback to all relevant primitives.

If the given sceneID is non-negative and exists in the given glTF, then the given callback will be applied to all meshes of this scene.

If the given sceneId is negative, then the meshes that the callback will be applied to depends on the structure of the glTF model:

  • If the glTF model has a default scene, then it will be applied to all meshes of the default scene.
  • Otherwise, it will be applied to all meshes of the the first scene.
  • Otherwise (if the glTF model does not contain any scenes), it will be applied to all meshes that can be found by starting a traversal at the root node.
  • Otherwise (if there are no scenes and no nodes), then all meshes will be traversed.
Parameters
sceneIDThe scene ID (index)
callbackThe callback to apply

◆ forEachPrimitiveInScene() [2/2]

void CesiumGltf::Model::forEachPrimitiveInScene ( int32_t sceneID,
std::function< ForEachPrimitiveInSceneConstCallback > && callback ) const

Apply the given callback to all relevant primitives.

If the given sceneID is non-negative and exists in the given glTF, then the given callback will be applied to all meshes of this scene.

If the given sceneId is negative, then the meshes that the callback will be applied to depends on the structure of the glTF model:

  • If the glTF model has a default scene, then it will be applied to all meshes of the default scene.
  • Otherwise, it will be applied to all meshes of the the first scene.
  • Otherwise (if the glTF model does not contain any scenes), it will be applied to all meshes that can be found by starting a traversal at the root node.
  • Otherwise (if there are no scenes and no nodes), then all meshes will be traversed.
Parameters
sceneIDThe scene ID (index)
callbackThe callback to apply

◆ forEachRootNodeInScene() [1/2]

void CesiumGltf::Model::forEachRootNodeInScene ( int32_t sceneID,
std::function< ForEachRootNodeInSceneCallback > && callback )

Apply the given callback to the root nodes of the scene.

If the given sceneID is non-negative and exists in the given glTF, then the given callback will be applied to all root nodes of this scene.

If the given sceneId is negative, then the nodes that the callback will be applied to depends on the structure of the glTF model:

  • If the glTF model has a default scene, then it will be applied to all root nodes of the default scene.
  • Otherwise, it will be applied to all root nodes of the first scene.
  • Otherwise (if the glTF model does not contain any scenes), it will be applied to the first node.
  • Otherwise (if there are no scenes and no nodes), then this method will do nothing.
Parameters
sceneIDThe scene ID (index)
callbackThe callback to apply

◆ forEachRootNodeInScene() [2/2]

void CesiumGltf::Model::forEachRootNodeInScene ( int32_t sceneID,
std::function< ForEachRootNodeInSceneConstCallback > && callback ) const

Apply the given callback to the root nodes of the scene.

If the given sceneID is non-negative and exists in the given glTF, then the given callback will be applied to all root nodes of this scene.

If the given sceneId is negative, then the nodes that the callback will be applied to depends on the structure of the glTF model:

  • If the glTF model has a default scene, then it will be applied to all root nodes of the default scene.
  • Otherwise, it will be applied to all root nodes of the first scene.
  • Otherwise (if the glTF model does not contain any scenes), it will be applied to the first node.
  • Otherwise (if there are no scenes and no nodes), then this method will do nothing.
Parameters
sceneIDThe scene ID (index)
callbackThe callback to apply

◆ getSafe() [1/3]

template<typename T >
static const T & CesiumGltf::Model::getSafe ( const std::vector< T > & items,
int32_t index )
inlinestatic

Safely gets the element with a given index, returning a default instance if the index is outside the range.

Template Parameters
TThe type of the array.
Parameters
itemsThe array.
indexThe index of the array element to retrieve.
Returns
The requested element, or a default instance if the index is invalid.

Definition at line 181 of file Model.h.

◆ getSafe() [2/3]

template<typename T >
static const T * CesiumGltf::Model::getSafe ( const std::vector< T > * pItems,
int32_t index )
inlinestaticnoexcept

Safely gets a pointer to the element with a given index, returning nullptr if the index is outside the range.

Template Parameters
TThe type of the array.
Parameters
pItemsThe array.
indexThe index of the array element to retrieve.
Returns
A pointer to the requested element, or nullptr if the index is invalid.

Definition at line 202 of file Model.h.

◆ getSafe() [3/3]

template<typename T >
static T * CesiumGltf::Model::getSafe ( std::vector< T > * pItems,
int32_t index )
inlinestaticnoexcept

Safely gets a pointer to the element with a given index, returning nullptr if the index is outside the range.

Template Parameters
TThe type of the array.
Parameters
pItemsThe array.
indexThe index of the array element to retrieve.
Returns
A pointer to the requested element, or nullptr if the index is invalid.

Definition at line 221 of file Model.h.

◆ isExtensionRequired()

bool CesiumGltf::Model::isExtensionRequired ( const std::string & extensionName) const
noexcept

Determines whether a given extension name is listed in the model's ModelSpec::extensionsRequired property.

Parameters
extensionNameThe extension name to check.
Returns
True if the extension is found in extensionsRequired; otherwise, false.

◆ isExtensionUsed()

bool CesiumGltf::Model::isExtensionUsed ( const std::string & extensionName) const
noexcept

Determines whether a given extension name is listed in the model's ModelSpec::extensionsUsed property.

Parameters
extensionNameThe extension name to check.
Returns
True if the extension is found in extensionsUsed; otherwise, false.

◆ merge()

CesiumUtility::ErrorList CesiumGltf::Model::merge ( Model && rhs)

Merges another model into this one.

After this method returns, this Model contains all of the elements that were originally in it plus all of the elements that were in rhs. Element indices are updated accordingly. However, element indices in CesiumUtility::ExtensibleObject::extras, if any, are not updated.

Parameters
rhsThe model to merge into this one.

◆ removeExtensionRequired()

void CesiumGltf::Model::removeExtensionRequired ( const std::string & extensionName)

Removes an extension from the ModelSpec::extensionsRequired property.

Calling this function also removes the extension from extensionsUsed.

Parameters
extensionNameThe name of the required extension.

◆ removeExtensionUsed()

void CesiumGltf::Model::removeExtensionUsed ( const std::string & extensionName)

Removes an extension from the ModelSpec::extensionsUsed property.

Parameters
extensionNameThe name of the used extension.

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