|
cesium-native 0.52.0
|
#include <CesiumGltfContent/GltfUtilities.h>
Classes | |
| struct | IntersectResult |
| Hit result data for intersectRayGltfModel. More... | |
| struct | RayGltfHit |
| Data describing a hit from a ray / gltf intersection test. More... | |
Static Public Member Functions | |
| static std::optional< glm::dmat4x4 > | getNodeTransform (const CesiumGltf::Node &node) |
| Gets the transformation matrix for a given node. | |
| static void | setNodeTransform (CesiumGltf::Node &node, const glm::dmat4x4 &newTransform) |
| Sets the transformation matrix for a given node. | |
| static glm::dmat4x4 | applyRtcCenter (const CesiumGltf::Model &gltf, const glm::dmat4x4 &rootTransform) |
| Applies the glTF's RTC_CENTER, if any, to the given transform. | |
| static glm::dmat4x4 | applyGltfUpAxisTransform (const CesiumGltf::Model &model, const glm::dmat4x4 &rootTransform) |
Applies the glTF's gltfUpAxis, if any, to the given transform. | |
| static CesiumGeospatial::BoundingRegion | computeBoundingRegion (const CesiumGltf::Model &gltf, const glm::dmat4 &transform, const CesiumGeospatial::Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84) |
| Computes a bounding region from the vertex positions in a glTF model. | |
| static std::vector< std::string_view > | parseGltfCopyright (const CesiumGltf::Model &gltf) |
| Parse the copyright field of a glTF model and return the individual credits. | |
| static std::vector< std::string_view > | parseGltfCopyright (const std::string_view &s) |
| Parse a semicolon-separated string, such as the copyright field of a glTF model, and return the individual parts (credits). | |
| static void | collapseToSingleBuffer (CesiumGltf::Model &gltf) |
| Merges all of the glTF's buffers into a single buffer (the first one). | |
| static void | moveBufferContent (CesiumGltf::Model &gltf, CesiumGltf::Buffer &destination, CesiumGltf::Buffer &source) |
Copies the content of one CesiumGltf::Buffer to the end of another, updates all CesiumGltf::BufferView instances to refer to the destination buffer, and clears the contents of the original buffer. | |
| static void | removeUnusedTextures (CesiumGltf::Model &gltf, const std::vector< int32_t > &extraUsedTextureIndices={}) |
| Removes unused textures from the given glTF model. | |
| static void | removeUnusedSamplers (CesiumGltf::Model &gltf, const std::vector< int32_t > &extraUsedSamplerIndices={}) |
| Removes unused samplers from the given glTF model. | |
| static void | removeUnusedImages (CesiumGltf::Model &gltf, const std::vector< int32_t > &extraUsedImageIndices={}) |
| Removes unused images from the given glTF model. | |
| static void | removeUnusedAccessors (CesiumGltf::Model &gltf, const std::vector< int32_t > &extraUsedAccessorIndices={}) |
| Removes unused accessors from the given glTF model. | |
| static void | removeUnusedBufferViews (CesiumGltf::Model &gltf, const std::vector< int32_t > &extraUsedBufferViewIndices={}) |
| Removes unused buffer views from the given glTF model. | |
| static void | removeUnusedBuffers (CesiumGltf::Model &gltf, const std::vector< int32_t > &extraUsedBufferIndices={}) |
| Removes unused buffers from the given glTF model. | |
| static void | removeUnusedMeshes (CesiumGltf::Model &gltf, const std::vector< int32_t > &extraUsedMeshIndices={}) |
| Removes unused meshes from the given glTF model. | |
| static void | removeUnusedMaterials (CesiumGltf::Model &gltf, const std::vector< int32_t > &extraUsedMaterialIndices={}) |
| Removes unused materials from the given glTF model. | |
| static void | compactBuffers (CesiumGltf::Model &gltf) |
| Shrink buffers by removing any sections that are not referenced by any BufferView. | |
| static void | compactBuffer (CesiumGltf::Model &gltf, int32_t bufferIndex) |
| Shrink a buffer by removing any sections that are not referenced by any BufferView. | |
| static IntersectResult | intersectRayGltfModel (const CesiumGeometry::Ray &ray, const CesiumGltf::Model &gltf, bool cullBackFaces=true, const glm::dmat4x4 &gltfTransform=glm::dmat4(1.0)) |
| Intersects a ray with a glTF model and returns the first intersection point. | |
A collection of utility functions that are used to process and transform a gltf model
Definition at line 30 of file GltfUtilities.h.
|
static |
Applies the glTF's gltfUpAxis, if any, to the given transform.
By default, the up-axis of a glTF model will the the Y-axis.
If the tileset that contained the model had the asset.gltfUpAxis string property, then the information about the up-axis has been stored in as a number property called gltfUpAxis in the extras of the given model.
Depending on whether this value is CesiumGeometry::Axis::X, Y, or Z, the given matrix will be multiplied with a matrix that converts the respective axis to be the Z-axis, as required by the 3D Tiles standard.
| model | The glTF model |
| rootTransform | The matrix that will be multiplied with the transform |
rootTransform with the gltfUpAxis.
|
static |
Applies the glTF's RTC_CENTER, if any, to the given transform.
If the glTF has a CESIUM_RTC extension, this function will multiply the given matrix with the (translation) matrix that is created from the RTC_CENTER in the. If the given model does not have this extension, then this function will return the rootTransform unchanged.
| gltf | The glTF model |
| rootTransform | The matrix that will be multiplied with the transform |
RTC_CENTER with the rootTransform.
|
static |
Merges all of the glTF's buffers into a single buffer (the first one).
This is useful when writing the glTF as a GLB, which supports only a single embedded buffer.
| gltf | The glTF in which to merge buffers. |
|
static |
Shrink a buffer by removing any sections that are not referenced by any BufferView.
| gltf | The glTF to modify. |
| bufferIndex | The index of the buffer to compact. |
|
static |
Shrink buffers by removing any sections that are not referenced by any BufferView.
| gltf | The glTF to modify. |
|
static |
Computes a bounding region from the vertex positions in a glTF model.
If the glTF model spans the anti-meridian, the west and east longitude values will be in the usual -PI to PI range, but east will have a smaller value than west.
If the glTF contains no geometry, the returned region's rectangle will be CesiumGeospatial::GlobeRectangle::EMPTY, its minimum height will be 1.0, and its maximum height will be -1.0 (the minimum will be greater than the maximum).
| gltf | The model. |
| transform | The transform from model coordinates to ECEF coordinates. |
| ellipsoid | The CesiumGeospatial::Ellipsoid. |
|
static |
Gets the transformation matrix for a given node.
This returns the node's local transform as-is. It does not incorporate transforms from any of the node's ancestors.
| node | The node from which to get the transformation matrix. |
|
static |
Intersects a ray with a glTF model and returns the first intersection point.
Supports all mesh primitive modes. Points and lines are assumed to have no area, and are ignored
| ray | A ray in world space. |
| gltf | The glTF model to intersect. |
| cullBackFaces | Ignore triangles that face away from ray. Front faces use CCW winding order. |
| gltfTransform | Optional matrix to apply to entire gltf model. |
|
static |
Copies the content of one CesiumGltf::Buffer to the end of another, updates all CesiumGltf::BufferView instances to refer to the destination buffer, and clears the contents of the original buffer.
The source buffer is not removed, but it has a byteLength of zero after this function completes.
| gltf | The glTF model to modify. |
| destination | The destination Buffer into which to move content. |
| source | The source Buffer from which to move content. |
|
static |
Parse the copyright field of a glTF model and return the individual credits.
Credits are read from the glTF's asset.copyright field. This method assumes that individual credits are separated by semicolons.
| gltf | The model. |
|
static |
Parse a semicolon-separated string, such as the copyright field of a glTF model, and return the individual parts (credits).
| s | The string to parse. |
|
static |
Removes unused accessors from the given glTF model.
| gltf | The glTF to remove unused accessors from. |
| extraUsedAccessorIndices | Indices of accessors that should be considered "used" even if they're not referenced by anything else in the glTF. |
|
static |
Removes unused buffers from the given glTF model.
| gltf | The glTF to remove unused buffers from. |
| extraUsedBufferIndices | Indices of buffers that should be considered "used" even if they're not referenced by anything else in the glTF. |
|
static |
Removes unused buffer views from the given glTF model.
| gltf | The glTF to remove unused buffer views from. |
| extraUsedBufferViewIndices | Indices of buffer views that should be considered "used" even if they're not referenced by anything else in the glTF. |
|
static |
Removes unused images from the given glTF model.
| gltf | The glTF to remove unused images from. |
| extraUsedImageIndices | Indices of images that should be considered "used" even if they're not referenced by anything else in the glTF. |
|
static |
Removes unused materials from the given glTF model.
| gltf | The glTF to remove unused materials from. |
| extraUsedMaterialIndices | Indices of materials that should be considered "used" even if they're not referenced by anything else in the glTF. |
|
static |
Removes unused meshes from the given glTF model.
| gltf | The glTF to remove unused meshes from. |
| extraUsedMeshIndices | Indices of meshes that should be considered "used" even if they're not referenced by anything else in the glTF. |
|
static |
Removes unused samplers from the given glTF model.
| gltf | The glTF to remove unused samplers from. |
| extraUsedSamplerIndices | Indices of samplers that should be considered "used" even if they're not referenced by anything else in the glTF. |
|
static |
Removes unused textures from the given glTF model.
| gltf | The glTF to remove unused textures from. |
| extraUsedTextureIndices | Indices of textures that should be considered "used" even if they're not referenced by anything else in the glTF. |
|
static |
Sets the transformation matrix for a given node.
This sets only the local transform of the node. It does not affect the transforms of any ancestor or descendant nodes, if present.
| node | The node on which to set the transformation matrix. |
| newTransform | The new transformation matrix. |