3#include "AccessorView.h"
5#include <CesiumGltf/MeshPrimitive.h>
7#include <glm/common.hpp>
94 int32_t featureIdAttributeIndex);
105 int32_t featureIdAttributeIndex);
123 return static_cast<int64_t
>(glm::round(value[
index]));
131 return static_cast<int64_t
>(value[
index]);
173 int64_t numFaces = 0;
196 std::array<int64_t, 3> result;
200 result[1] = firstVertex <
vertexCount ? firstVertex : -1;
201 result[2] = firstVertex + 1 <
vertexCount ? firstVertex + 1 : -1;
203 for (int64_t i = 0; i < 3; i++) {
204 int64_t vertexIndex = firstVertex + i;
205 result[i] = vertexIndex <
vertexCount ? vertexIndex : -1;
215 template <
typename T>
218 int64_t numFaces = 0;
222 numFaces = value.
size() - 2;
225 numFaces = value.
size() - 2;
229 numFaces = value.
size() / 3;
241 std::array<int64_t, 3> result;
244 result[0] = value[0];
245 result[1] = firstIndex < value.
size() ? value[firstIndex] : -1;
246 result[2] = firstIndex + 1 < value.
size() ? value[firstIndex + 1] : -1;
248 for (int64_t i = 0; i < 3; i++) {
249 int64_t index = firstIndex + i;
250 result[i] = index < value.
size() ? value[index] : -1;
280 template <
typename T>
310 int32_t textureCoordinateSetIndex);
325 std::optional<glm::dvec2>
331 return glm::dvec2(value[
index].value[0], value[
index].value[1]);
340 template <
typename T>
341 std::optional<glm::dvec2>
347 double u =
static_cast<double>(value[
index].value[0]);
348 double v =
static_cast<double>(value[
index].value[1]);
351 u /= std::numeric_limits<T>::max();
352 v /= std::numeric_limits<T>::max();
354 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.
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 ...
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....