Cesium for Unreal 2.12.0
Loading...
Searching...
No Matches
UnrealMetadataConversions.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CesiumGltf/PropertyTypeTraits.h"
7#include "CesiumUtility/JsonValue.h"
8#include <cstdlib>
9#include <glm/common.hpp>
10#include <type_traits>
11
13
22
23// Deprecated.
26
27// For backwards compatibility.
30
31static const std::string VectorComponents = "XYZW";
32
34public:
35 static FIntPoint toIntPoint(const glm::ivec2& vec2);
41 static FIntPoint
42 toIntPoint(const std::string_view& string, const FIntPoint& defaultValue);
43
44 static FVector2D toVector2D(const glm::dvec2& vec2);
51 static FVector2D
52 toVector2D(const std::string_view& string, const FVector2D& defaultValue);
53
54 static FIntVector toIntVector(const glm::ivec3& vec3);
63 static FIntVector
64 toIntVector(const std::string_view& string, const FIntVector& defaultValue);
65
66 static FVector3f toVector3f(const glm::vec3& vec3);
67 static FVector3f
68 toVector3f(const std::string_view& string, const FVector3f& defaultValue);
69
70 static FVector toVector(const glm::dvec3& vec3);
71 static FVector
72 toVector(const std::string_view& string, const FVector& defaultValue);
73
74 static FVector4 toVector4(const glm::dvec4& vec4);
75 static FVector4
76 toVector4(const std::string_view& string, const FVector4& defaultValue);
77
78 static FMatrix toMatrix(const glm::dmat4& mat4);
79
87 template <glm::length_t N, typename T>
88 static FString toString(const glm::vec<N, T>& from) {
89 std::string result;
90 for (glm::length_t i = 0; i < N; i++) {
91 if (i > 0) {
92 result += " ";
93 }
94 result += VectorComponents[i];
95 result += "=";
96 result += std::to_string(from[i]);
97 }
98 return FString(result.c_str());
99 }
100
108 template <glm::length_t N, typename T>
109 static FString toString(const glm::mat<N, N, T>& from) {
110 std::string result;
111 // glm::matNs are column-major, but Unreal matrices are row-major and print
112 // their values by row.
113 for (glm::length_t r = 0; r < N; r++) {
114 if (r > 0) {
115 result += " ";
116 }
117 result += "[";
118 for (glm::length_t c = 0; c < N; c++) {
119 if (c > 0) {
120 result += " ";
121 }
122 result += std::to_string(from[c][r]);
123 }
124 result += "]";
125 }
126 return FString(result.c_str());
127 }
128
129 static FString toString(const std::string_view& from);
130
131 static FString toString(const std::string& from);
132};
ECesiumEncodedMetadataComponentType
The component type that a metadata property's values will be encoded as.
ECesiumMetadataTrueType_DEPRECATED
The type of a metadata property in EXT_feature_metadata.
ECesiumMetadataBlueprintType
The Blueprint type that can losslessly represent values of a given property.
ECesiumMetadataBlueprintType CesiumMetadataValueTypeToBlueprintType(FCesiumMetadataValueType ValueType)
Converts a FCesiumMetadataValueType to the best-fitting Blueprints type.
ECesiumMetadataTrueType_DEPRECATED CesiumMetadataValueTypeToTrueType(FCesiumMetadataValueType ValueType)
ECesiumMetadataBlueprintType CesiumMetadataTrueTypeToBlueprintType(ECesiumMetadataTrueType_DEPRECATED trueType)
Represents the true value type of a metadata value, akin to the property types in EXT_structural_meta...
static FMatrix toMatrix(const glm::dmat4 &mat4)
static FString toString(const glm::mat< N, N, T > &from)
Converts a glm::matN to a FString.
static FVector4 toVector4(const std::string_view &string, const FVector4 &defaultValue)
static FIntPoint toIntPoint(const std::string_view &string, const FIntPoint &defaultValue)
Converts a std::string_view to a FIntPoint.
static FVector2D toVector2D(const glm::dvec2 &vec2)
static FVector4 toVector4(const glm::dvec4 &vec4)
static FString toString(const glm::vec< N, T > &from)
Converts a glm::vecN to a FString.
static FString toString(const std::string &from)
static FVector toVector(const std::string_view &string, const FVector &defaultValue)
static FVector toVector(const glm::dvec3 &vec3)
static FVector3f toVector3f(const std::string_view &string, const FVector3f &defaultValue)
static FVector2D toVector2D(const std::string_view &string, const FVector2D &defaultValue)
Converts a std::string_view to a FVector2D.
static FIntPoint toIntPoint(const glm::ivec2 &vec2)
static FIntVector toIntVector(const std::string_view &string, const FIntVector &defaultValue)
Converts a std::string_view to a FIntVector.
static FIntVector toIntVector(const glm::ivec3 &vec3)
static FVector3f toVector3f(const glm::vec3 &vec3)
static FString toString(const std::string_view &from)