3#include <CesiumGltf/AccessorView.h>
4#include <CesiumGltf/MeshPrimitive.h>
6#include <glm/common.hpp>
93 int32_t featureIdAttributeIndex);
104 int32_t featureIdAttributeIndex);
122 return static_cast<int64_t
>(glm::round(value[
index]));
130 return static_cast<int64_t
>(value[
index]);
196 return static_cast<int64_t
>(std::numeric_limits<T>::max());
215 int64_t numFaces = 0;
238 std::array<int64_t, 3> result;
242 result[1] = firstVertex <
vertexCount ? firstVertex : -1;
243 result[2] = firstVertex + 1 <
vertexCount ? firstVertex + 1 : -1;
245 for (int64_t i = 0; i < 3; i++) {
246 int64_t vertexIndex = firstVertex + i;
247 result[
static_cast<size_t>(i)] =
258 template <
typename T>
261 int64_t numFaces = 0;
265 numFaces = value.
size() - 2;
268 numFaces = value.
size() - 2;
272 numFaces = value.
size() / 3;
284 std::array<int64_t, 3> result;
287 result[0] = value[0];
288 result[1] = firstIndex < value.
size()
289 ?
static_cast<int64_t
>(value[firstIndex])
291 result[2] = firstIndex + 1 < value.
size()
292 ?
static_cast<int64_t
>(value[firstIndex + 1])
295 for (int64_t i = 0; i < 3; i++) {
296 int64_t index = firstIndex + i;
297 result[
static_cast<size_t>(i)] =
298 index < value.
size() ?
static_cast<int64_t
>(value[index]) : -1;
328 template <
typename T>
358 int32_t textureCoordinateSetIndex);
373 std::optional<glm::dvec2>
379 return glm::dvec2(value[
index].value[0], value[
index].value[1]);
388 template <
typename T>
389 std::optional<glm::dvec2>
395 double u =
static_cast<double>(value[
index].value[0]);
396 double v =
static_cast<double>(value[
index].value[1]);
399 u /= std::numeric_limits<T>::max();
400 v /= std::numeric_limits<T>::max();
402 return glm::dvec2(u, v);
A view on the data of one accessor of a glTF asset.
int64_t size() const noexcept
Returns the size (number of elements) of this accessor.
AccessorViewStatus status() const noexcept
Gets the status of this accessor view.
Classes for working with glTF models.
AccessorView< AccessorTypes::VEC3< float > > NormalAccessorType
std::variant< AccessorView< int8_t >, AccessorView< uint8_t >, AccessorView< int16_t >, AccessorView< uint16_t >, AccessorView< uint32_t >, AccessorView< float > > FeatureIdAccessorType
std::variant< std::monostate, AccessorView< uint8_t >, AccessorView< uint16_t >, AccessorView< uint32_t > > IndexAccessorType
std::variant< AccessorView< AccessorTypes::VEC4< uint8_t > >, AccessorView< AccessorTypes::VEC4< int8_t > >, AccessorView< AccessorTypes::VEC4< uint16_t > >, AccessorView< AccessorTypes::VEC4< int16_t > >, AccessorView< AccessorTypes::VEC4< float > > > QuaternionAccessorType
Type definition for quaternion accessors, as used in ExtMeshGpuInstancing rotations and animation sam...
IndexAccessorType getIndexAccessorView(const Model &model, const MeshPrimitive &primitive)
FeatureIdAccessorType getFeatureIdAccessorView(const Model &model, const MeshPrimitive &primitive, int32_t featureIdAttributeIndex)
TexCoordAccessorType getTexCoordAccessorView(const Model &model, const MeshPrimitive &primitive, int32_t textureCoordinateSetIndex)
NormalAccessorType getNormalAccessorView(const Model &model, const MeshPrimitive &primitive)
AccessorViewStatus
Indicates the status of an accessor view.
@ InvalidAccessorIndex
The accessor index does not refer to a valid accessor.
std::variant< AccessorView< AccessorTypes::VEC2< uint8_t > >, AccessorView< AccessorTypes::VEC2< uint16_t > >, AccessorView< AccessorTypes::VEC2< float > > > TexCoordAccessorType
AccessorView< AccessorTypes::VEC3< float > > PositionAccessorType
QuaternionAccessorType getQuaternionAccessorView(const Model &model, const Accessor *accessor)
Obtains a QuaternionAccessorType from the given Accessor on the given Model.
PositionAccessorType getPositionAccessorView(const Model &model, const MeshPrimitive &primitive)
A 2D vector element for an AccessorView.
This class is not meant to be instantiated directly. Use Accessor instead.
Visitor that retrieves the count of elements in the given accessor type as an int64_t.
int64_t operator()(const AccessorView< T > &value)
Attempts to obtain an element count from an AccessorView.
int64_t operator()(std::monostate)
Attempts to obtain an element count from an empty accessor variant, resulting in 0.
int64_t operator()(const AccessorView< float > &value)
Attempts to obtain a feature ID from an AccessorView over float values, returning the float value rou...
int64_t operator()(const AccessorView< T > &value)
Attempts to obtain a feature ID from an AccessorView.
int64_t index
The index of the vertex whose feature ID is being queried.
int64_t operator()(const CesiumGltf::AccessorView< T > &value)
Attempts to obtain a vertex index from an CesiumGltf::AccessorView.
int64_t index
The index of the vertex index within the accessor itself.
int64_t operator()(std::monostate)
Attempts to obtain a vertex index from an empty IndexAccessorType, resulting in -1.
std::array< int64_t, 3 > operator()(const AccessorView< T > &value)
Attempts to obtain the indices for the given face from an AccessorView, using the view's size and con...
int64_t faceIndex
The index of the face to obtain indices for.
std::array< int64_t, 3 > operator()(std::monostate)
Attempts to obtain the indices for the given face from an empty accessor variant, using the vertexCou...
int64_t vertexCount
The total number of vertices in the data being accessed.
int32_t primitiveMode
The MeshPrimitive::Mode of the data being accessed.
Returns the maximum possible index value for the given IndexAccessorType.
int64_t operator()(const AccessorView< T > &)
Attempts to obtain a maximum index value from an AccessorView.
int64_t operator()(std::monostate)
Attempts to obtain a maximum index value from an empty IndexAccessorType, resulting in -1.
static constexpr int32_t TRIANGLES
TRIANGLES (4)
static constexpr int32_t TRIANGLE_FAN
TRIANGLE_FAN (6)
static constexpr int32_t TRIANGLE_STRIP
TRIANGLE_STRIP (5)
Geometry to be rendered with the given material.
This class is not meant to be instantiated directly. Use Model instead.
A node in the node hierarchy. When the node contains skin, all mesh.primitives MUST contain JOINTS_0 ...
int64_t operator()(std::monostate)
Attempts to obtain a number of indices from an empty IndexAccessorType, resulting in 0.
int64_t operator()(const AccessorView< T > &value)
Attempts to obtain a number of indices from an AccessorView.
Visitor that retrieves the status from the given accessor. Returns an invalid status for a std::monos...
AccessorViewStatus operator()(std::monostate)
Attempts to obtain an AccessorViewStatus from an empty accessor variant, resulting in AccessorViewSta...
AccessorViewStatus operator()(const AccessorView< T > &value)
Attempts to obtain an AccessorViewStatus from an AccessorView.
int64_t index
The index of texcoords to obtain.
std::optional< glm::dvec2 > operator()(const AccessorView< AccessorTypes::VEC2< T > > &value)
Attempts to obtain a glm::dvec2 at the given index from an accessor over a vec2. The values will be c...
std::optional< glm::dvec2 > operator()(const AccessorView< AccessorTypes::VEC2< float > > &value)
Attempts to obtain a glm::dvec2 at the given index from an accessor over a vec2 of floats....