109 lines
3.0 KiB
C++
109 lines
3.0 KiB
C++
// This file was generated by generate-classes.
|
|
// DO NOT EDIT THIS FILE!
|
|
#pragma once
|
|
|
|
#include <CesiumGltf/Library.h>
|
|
#include <CesiumUtility/ExtensibleObject.h>
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
namespace CesiumGltf {
|
|
/**
|
|
* @brief Geometry to be rendered with the given material.
|
|
*/
|
|
struct CESIUMGLTF_API MeshPrimitive final
|
|
: public CesiumUtility::ExtensibleObject {
|
|
/**
|
|
* @brief The original name of this type.
|
|
*/
|
|
static constexpr const char* TypeName = "MeshPrimitive";
|
|
|
|
/**
|
|
* @brief Known values for The topology type of primitives to render.
|
|
*/
|
|
struct Mode {
|
|
/** @brief POINTS (`0`) */
|
|
static constexpr int32_t POINTS = 0;
|
|
|
|
/** @brief LINES (`1`) */
|
|
static constexpr int32_t LINES = 1;
|
|
|
|
/** @brief LINE_LOOP (`2`) */
|
|
static constexpr int32_t LINE_LOOP = 2;
|
|
|
|
/** @brief LINE_STRIP (`3`) */
|
|
static constexpr int32_t LINE_STRIP = 3;
|
|
|
|
/** @brief TRIANGLES (`4`) */
|
|
static constexpr int32_t TRIANGLES = 4;
|
|
|
|
/** @brief TRIANGLE_STRIP (`5`) */
|
|
static constexpr int32_t TRIANGLE_STRIP = 5;
|
|
|
|
/** @brief TRIANGLE_FAN (`6`) */
|
|
static constexpr int32_t TRIANGLE_FAN = 6;
|
|
};
|
|
|
|
/**
|
|
* @brief A plain JSON object, where each key corresponds to a mesh attribute
|
|
* semantic and each value is the index of the accessor containing attribute's
|
|
* data.
|
|
*/
|
|
std::unordered_map<std::string, int32_t> attributes;
|
|
|
|
/**
|
|
* @brief The index of the accessor that contains the vertex indices.
|
|
*
|
|
* When this is undefined, the primitive defines non-indexed geometry. When
|
|
* defined, the accessor **MUST** have `SCALAR` type and an unsigned integer
|
|
* component type.
|
|
*/
|
|
int32_t indices = -1;
|
|
|
|
/**
|
|
* @brief The index of the material to apply to this primitive when rendering.
|
|
*/
|
|
int32_t material = -1;
|
|
|
|
/**
|
|
* @brief The topology type of primitives to render.
|
|
*
|
|
* Known values are defined in {@link Mode}.
|
|
*
|
|
*/
|
|
int32_t mode = Mode::TRIANGLES;
|
|
|
|
/**
|
|
* @brief An array of morph targets.
|
|
*/
|
|
std::vector<std::unordered_map<std::string, int32_t>> targets;
|
|
|
|
/**
|
|
* @brief Calculates the size in bytes of this object, including the contents
|
|
* of all collections, pointers, and strings. This will NOT include the size
|
|
* of any extensions attached to the object. Calling this method may be slow
|
|
* as it requires traversing the object's entire structure.
|
|
*/
|
|
int64_t getSizeBytes() const {
|
|
int64_t accum = 0;
|
|
accum += int64_t(sizeof(MeshPrimitive));
|
|
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
|
|
int64_t(sizeof(CesiumUtility::ExtensibleObject));
|
|
accum += int64_t(
|
|
this->attributes.bucket_count() *
|
|
(sizeof(std::string) + sizeof(int32_t)));
|
|
for (const auto& [k, v] : this->attributes) {
|
|
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
|
|
accum += int64_t(sizeof(int32_t));
|
|
}
|
|
accum += int64_t(
|
|
sizeof(std::unordered_map<std::string, int32_t>) *
|
|
this->targets.capacity());
|
|
return accum;
|
|
}
|
|
};
|
|
} // namespace CesiumGltf
|