Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to asset sharing to support Unreal implementation #959

Merged
merged 8 commits into from
Oct 4, 2024
51 changes: 51 additions & 0 deletions CesiumGltf/include/CesiumGltf/VertexAttributeSemantics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma once

#include <array>
#include <string>

namespace CesiumGltf {

/**
* @brief The standard glTF vertex attribute semantics from the specification.
*/
struct VertexAttributeSemantics {
/**
* @brief Unitless XYZ vertex positions.
*/
static const std::string POSITION;

/**
* @brief Normalized XYZ vertex normals.
*/
static const std::string NORMAL;

/**
* @brief XYZW vertex tangents where the XYZ portion is normalized, and the W
* component is a sign value (-1 or +1) indicating handedness of the tangent
* basis.
*/
static const std::string TANGENT;

/**
* @brief ST texture coordinates
*/
static const std::array<std::string, 8> TEXCOORD_n;

/**
* @brief RGB or RGBA vertex color linear multiplier.
*/
static const std::array<std::string, 8> COLOR_n;

/**
* @brief The indices of the joints from the corresponding skin.joints array
* that affect the vertex.
*/
static const std::array<std::string, 8> JOINTS_n;

/**
* @brief The weights indicating how strongly the joint influences the vertex.
*/
static const std::array<std::string, 8> WEIGHTS_n;
};

} // namespace CesiumGltf
75 changes: 75 additions & 0 deletions CesiumGltf/src/VertexAttributeSemantics.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <CesiumGltf/VertexAttributeSemantics.h>

namespace CesiumGltf {

/**
* @brief Unitless XYZ vertex positions.
*/
const std::string VertexAttributeSemantics::POSITION = "POSITION";

/**
* @brief Normalized XYZ vertex normals.
*/
const std::string VertexAttributeSemantics::NORMAL = "NORMAL";

/**
* @brief XYZW vertex tangents where the XYZ portion is normalized, and the W
* component is a sign value (-1 or +1) indicating handedness of the tangent
* basis.
*/
const std::string VertexAttributeSemantics::TANGENT = "TANGENT";

/**
* @brief ST texture coordinates
*/
const std::array<std::string, 8> VertexAttributeSemantics::TEXCOORD_n = {
"TEXCOORD_0",
"TEXCOORD_1",
"TEXCOORD_2",
"TEXCOORD_3",
"TEXCOORD_4",
"TEXCOORD_5",
"TEXCOORD_6",
"TEXCOORD_7"};

/**
* @brief RGB or RGBA vertex color linear multiplier.
*/
const std::array<std::string, 8> VertexAttributeSemantics::COLOR_n = {
"COLOR_0",
"COLOR_1",
"COLOR_2",
"COLOR_3",
"COLOR_4",
"COLOR_5",
"COLOR_6",
"COLOR_7"};

/**
* @brief The indices of the joints from the corresponding skin.joints array
* that affect the vertex.
*/
const std::array<std::string, 8> VertexAttributeSemantics::JOINTS_n = {
"JOINTS_0",
"JOINTS_1",
"JOINTS_2",
"JOINTS_3",
"JOINTS_4",
"JOINTS_5",
"JOINTS_6",
"JOINTS_7"};

/**
* @brief The weights indicating how strongly the joint influences the vertex.
*/
const std::array<std::string, 8> VertexAttributeSemantics::WEIGHTS_n = {
"WEIGHTS_0",
"WEIGHTS_1",
"WEIGHTS_2",
"WEIGHTS_3",
"WEIGHTS_4",
"WEIGHTS_5",
"WEIGHTS_6",
"WEIGHTS_7"};

} // namespace CesiumGltf
9 changes: 7 additions & 2 deletions CesiumUtility/include/CesiumUtility/ExtensibleObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ struct CESIUMUTILITY_API ExtensibleObject {
* @tparam T The type of the extension to add.
* @return The added extension.
*/
template <typename T> T& addExtension() {
template <typename T, typename... ConstructorArgumentTypes>
T& addExtension(ConstructorArgumentTypes&&... constructorArguments) {
std::any& extension =
extensions.try_emplace(T::ExtensionName, std::make_any<T>())
extensions
.try_emplace(
T::ExtensionName,
std::make_any<T>(std::forward<ConstructorArgumentTypes>(
constructorArguments)...))
.first->second;
return std::any_cast<T&>(extension);
}
Expand Down
Loading