3#include <CesiumGltf/Library.h>
4#include <CesiumGltf/ModelSpec.h>
5#include <CesiumUtility/ErrorList.h>
7#include <glm/mat4x4.hpp>
63 std::function<ForEachRootNodeInSceneCallback>&& callback);
68 std::function<ForEachRootNodeInSceneConstCallback>&& callback)
const;
76 const glm::dmat4& transform);
100 std::function<ForEachNodeInSceneCallback>&& callback);
108 const glm::dmat4& transform);
113 std::function<ForEachNodeInSceneConstCallback>&& callback)
const;
123 const glm::dmat4& transform);
148 std::function<ForEachPrimitiveInSceneCallback>&& callback);
158 const glm::dmat4& transform);
163 std::function<ForEachPrimitiveInSceneConstCallback>&& callback)
const;
180 template <
typename T>
181 static const T&
getSafe(
const std::vector<T>& items, int32_t index) {
182 static T defaultObject;
183 if (index < 0 ||
size_t(index) >= items.size()) {
184 return defaultObject;
186 return items[size_t(index)];
200 template <
typename T>
202 getSafe(
const std::vector<T>* pItems, int32_t index)
noexcept {
203 if (index < 0 ||
size_t(index) >= pItems->size()) {
206 return &(*pItems)[size_t(index)];
220 template <
typename T>
221 static T*
getSafe(std::vector<T>* pItems, int32_t index)
noexcept {
222 if (index < 0 ||
size_t(index) >= pItems->size()) {
225 return &(*pItems)[size_t(index)];
Classes for working with glTF models.
Geometry to be rendered with the given material.
A set of primitives to be rendered. Its global transform is defined by a node that references it.
The root object for a glTF asset.
This class is not meant to be instantiated directly. Use Model instead.
void removeExtensionRequired(const std::string &extensionName)
Removes an extension from the ModelSpec::extensionsRequired property.
void addExtensionRequired(const std::string &extensionName)
Adds an extension to the ModelSpec::extensionsRequired property, if it is not already present.
void ForEachNodeInSceneCallback(Model &gltf, Node &node, const glm::dmat4 &transform)
A callback function for forEachNodeInScene.
void forEachNodeInScene(int32_t sceneID, std::function< ForEachNodeInSceneConstCallback > &&callback) const
Apply the given callback to all nodes in the scene.
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 th...
void ForEachNodeInSceneConstCallback(const Model &gltf, const Node &node, const glm::dmat4 &transform)
A callback function for forEachNodeInScene.
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 prop...
void generateMissingNormalsSmooth()
Fills in smooth normals for any primitives with missing normals.
void forEachPrimitiveInScene(int32_t sceneID, std::function< ForEachPrimitiveInSceneCallback > &&callback)
Apply the given callback to all relevant primitives.
void forEachRootNodeInScene(int32_t sceneID, std::function< ForEachRootNodeInSceneCallback > &&callback)
Apply the given callback to the root nodes of the scene.
void ForEachPrimitiveInSceneConstCallback(const Model &gltf, const Node &node, const Mesh &mesh, const MeshPrimitive &primitive, const glm::dmat4 &transform)
A callback function for forEachPrimitiveInScene.
void forEachNodeInScene(int32_t sceneID, std::function< ForEachNodeInSceneCallback > &&callback)
Apply the given callback to all nodes in the scene.
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 th...
void forEachRootNodeInScene(int32_t sceneID, std::function< ForEachRootNodeInSceneConstCallback > &&callback) const
Apply the given callback to the root nodes of the scene.
void removeExtensionUsed(const std::string &extensionName)
Removes an extension from the ModelSpec::extensionsUsed property.
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 ...
void addExtensionUsed(const std::string &extensionName)
Adds an extension to the ModelSpec::extensionsUsed property, if it is not already present.
void ForEachPrimitiveInSceneCallback(Model &gltf, Node &node, Mesh &mesh, MeshPrimitive &primitive, const glm::dmat4 &transform)
A callback function for forEachPrimitiveInScene.
void ForEachRootNodeInSceneCallback(Model &gltf, Node &node)
A callback function for forEachRootNodeInScene.
void ForEachRootNodeInSceneConstCallback(const Model &gltf, const Node &node)
A callback function for forEachRootNodeInScene.
void forEachPrimitiveInScene(int32_t sceneID, std::function< ForEachPrimitiveInSceneConstCallback > &&callback) const
Apply the given callback to all relevant primitives.
CesiumUtility::ErrorList merge(Model &&rhs)
Merges another model into this one.
A node in the node hierarchy. When the node contains skin, all mesh.primitives MUST contain JOINTS_0 ...
The container to store the error and warning list when loading a tile or glTF content.