cesium-native  0.41.0
CesiumGltf::Accessor Struct Referencefinal

A typed view into a buffer view that contains raw binary data. More...

#include <CesiumGltf/Accessor.h>

Inheritance diagram for CesiumGltf::Accessor:
CesiumGltf::AccessorSpec CesiumGltf::NamedObject CesiumUtility::ExtensibleObject

Public Member Functions

int8_t computeNumberOfComponents () const noexcept
 Computes the number of components for this accessor. More...
 
int8_t computeByteSizeOfComponent () const noexcept
 Computes the number of bytes for this accessor's component type. More...
 
int64_t computeBytesPerVertex () const noexcept
 Computes the total number of bytes for this accessor in each vertex. More...
 
int64_t computeByteStride (const CesiumGltf::Model &model) const noexcept
 Computes this accessor's stride. More...
 
- Public Member Functions inherited from CesiumUtility::ExtensibleObject
template<typename T >
bool hasExtension () const noexcept
 Checks if an extension exists given its static type. More...
 
template<typename T >
const T * getExtension () const noexcept
 Gets an extension given its static type. More...
 
template<typename T >
T * getExtension () noexcept
 Gets an extension given its static type. More...
 
const JsonValuegetGenericExtension (const std::string &extensionName) const noexcept
 Gets a generic extension with the given name as a CesiumUtility::JsonValue. More...
 
JsonValuegetGenericExtension (const std::string &extensionName) noexcept
 Gets a generic extension with the given name as a CesiumUtility::JsonValue. More...
 
template<typename T , typename... ConstructorArgumentTypes>
T & addExtension (ConstructorArgumentTypes &&... constructorArguments)
 Adds a statically-typed extension to this object. More...
 
template<typename T >
void removeExtension ()
 Removes a statically-typed extension from this object. More...
 

Static Public Member Functions

static int8_t computeNumberOfComponents (const std::string &type) noexcept
 Computes the number of components for a given accessor type. More...
 
static int8_t computeByteSizeOfComponent (int32_t componentType) noexcept
 Computes the number of bytes for a given accessor component type. More...
 

Additional Inherited Members

- Public Attributes inherited from CesiumGltf::AccessorSpec
int32_t bufferView = -1
 The index of the bufferView. More...
 
int64_t byteOffset = 0
 The offset relative to the start of the buffer view in bytes. More...
 
int32_t componentType = ComponentType::BYTE
 The datatype of the accessor's components. More...
 
bool normalized = false
 Specifies whether integer data values are normalized before usage. More...
 
int64_t count = int64_t()
 The number of elements referenced by this accessor. More...
 
std::string type = Type::SCALAR
 Specifies if the accessor's elements are scalars, vectors, or matrices. More...
 
std::vector< double > max
 Maximum value of each component in this accessor. More...
 
std::vector< double > min
 Minimum value of each component in this accessor. More...
 
std::optional< CesiumGltf::AccessorSparsesparse
 Sparse storage of elements that deviate from their initialization value.
 
- Public Attributes inherited from CesiumGltf::NamedObject
std::string name
 The user-defined name of this object. More...
 
- Public Attributes inherited from CesiumUtility::ExtensibleObject
std::unordered_map< std::string, std::any > extensions
 The extensions attached to this object. More...
 
JsonValue::Object extras
 Application-specific data. More...
 
JsonValue::Object unknownProperties
 Unknown properties that exist on this object but do not have any representation in the statically-typed classes. More...
 
- Static Public Attributes inherited from CesiumGltf::AccessorSpec
static constexpr const char * TypeName = "Accessor"
 

Detailed Description

A typed view into a buffer view that contains raw binary data.

Definition at line 12 of file Accessor.h.

Member Function Documentation

◆ computeByteSizeOfComponent() [1/2]

int8_t CesiumGltf::Accessor::computeByteSizeOfComponent ( ) const
noexcept

Computes the number of bytes for this accessor's component type.

For example if this accessor's Accessor::componentType is CesiumGltf::Accessor::ComponentType::UNSIGNED_SHORT, then the component type is 2 bytes, while if it's CesiumGltf::Accessor::ComponentType::FLOAT then it is 4 bytes.

Returns
The number of bytes for this accessor's component type. Returns 0 if this accessor's Accessor::componentType does not have a valid enumeration value.

◆ computeByteSizeOfComponent() [2/2]

static int8_t CesiumGltf::Accessor::computeByteSizeOfComponent ( int32_t  componentType)
staticnoexcept

Computes the number of bytes for a given accessor component type.

For example CesiumGltf::Accessor::ComponentType::UNSIGNED_SHORT is 2 bytes while CesiumGltf::Accessor::ComponentType::FLOAT is 4 bytes.

Parameters
componentTypeThe accessor component type.
Returns
The number of bytes for the component type. Returns 0 if Accessor::componentType is not a valid enumeration value.

◆ computeBytesPerVertex()

int64_t CesiumGltf::Accessor::computeBytesPerVertex ( ) const
noexcept

Computes the total number of bytes for this accessor in each vertex.

This is computed by multiplying Accessor::computeByteSizeOfComponent by Accessor::computeNumberOfComponents.

Returns
The total number of bytes for this accessor in each vertex. Returns 0 if this accessor's Accessor::type or Accessor::componentType does not have a valid enumeration value.

◆ computeByteStride()

int64_t CesiumGltf::Accessor::computeByteStride ( const CesiumGltf::Model model) const
noexcept

Computes this accessor's stride.

The stride is the number of bytes between the same elements of successive vertices. The returned value will be at least as large as Accessor::computeBytesPerVertex, but maybe be larger if this accessor's data is interleaved with other accessors.

The behavior is undefined if this accessor is not part of the given model.

Parameters
modelThe model that this accessor is a part of.
Returns
The stride in bytes. Returns 0 if this accessor's Accessor::type or Accessor::componentType does not have a valid enumeration value, or if Accessor::bufferView does not refer to a valid BufferView.

◆ computeNumberOfComponents() [1/2]

int8_t CesiumGltf::Accessor::computeNumberOfComponents ( ) const
noexcept

Computes the number of components for this accessor.

For example if this accessor's Accessor::type is CesiumGltf::Accessor::Type::SCALAR, then it has 1 component, while if it's CesiumGltf::Accessor::Type::VEC4 it has 4 components.

Returns
The number of components in this accessor. Returns 0 if this accessor's Accessor::type does not have a valid enumeration value.

◆ computeNumberOfComponents() [2/2]

static int8_t CesiumGltf::Accessor::computeNumberOfComponents ( const std::string &  type)
staticnoexcept

Computes the number of components for a given accessor type.

For example CesiumGltf::Accessor::Type::SCALAR has 1 component while CesiumGltf::Accessor::Type::VEC4 has 4 components.

Parameters
typeThe accessor type.
Returns
The number of components. Returns 0 if Accessor::type is not a valid enumeration value.

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