Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
CesiumPropertyTable.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
7#include "Kismet/BlueprintFunctionLibrary.h"
8#include "UObject/ObjectMacros.h"
9#include "CesiumPropertyTable.generated.h"
10
11namespace CesiumGltf {
12struct Model;
13struct PropertyTable;
14} // namespace CesiumGltf
15
16/**
17 * @brief Reports the status of a FCesiumPropertyTable. If the property table
18 * cannot be accessed, this briefly indicates why.
19 */
20UENUM(BlueprintType)
21enum class ECesiumPropertyTableStatus : uint8 {
22 /* The property table is valid. */
23 Valid = 0,
24 /* The property table instance was not initialized from an actual glTF
25 property table. */
27 /* The property table's class could be found in the schema of the metadata
28 extension. */
30};
31
32/**
33 * A Blueprint-accessible wrapper for a glTF property table. A property table is
34 * a collection of properties for the features in a mesh. It knows how to
35 * look up the metadata values associated with a given feature ID.
36 */
37USTRUCT(BlueprintType)
38struct CESIUMRUNTIME_API FCesiumPropertyTable {
39 GENERATED_USTRUCT_BODY()
40
41public:
42 /**
43 * Construct an empty property table instance.
44 */
47
48 /**
49 * Constructs a property table from a glTF Property Table.
50 *
51 * @param Model The model that stores EXT_structural_metadata.
52 * @param PropertyTable The target property table.
53 */
55 const CesiumGltf::Model& Model,
56 const CesiumGltf::PropertyTable& PropertyTable);
57
58 /**
59 * Gets the name of the metadata class that this property table conforms to.
60 */
61 FString getClassName() const { return _className; }
62
63private:
65 FString _name;
66 FString _className;
67
68 int64 _count;
69 TMap<FString, FCesiumPropertyTableProperty> _properties;
70
72};
73
74UCLASS()
76 : public UBlueprintFunctionLibrary {
77 GENERATED_BODY()
78
79public:
80 /**
81 * Gets the status of the property table. If an error occurred while parsing
82 * the property table from the glTF extension, this briefly conveys why.
83 *
84 * @param PropertyTable The property table.
85 */
86 UFUNCTION(
87 BlueprintCallable,
88 BlueprintPure,
89 Category = "Cesium|Metadata|PropertyTable")
91 GetPropertyTableStatus(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
92
93 /**
94 * Gets the name of the property table. If no name was specified in the glTF
95 * extension, this returns an empty string.
96 *
97 * @param PropertyTable The property table.
98 */
99 UFUNCTION(
100 BlueprintCallable,
101 BlueprintPure,
102 Category = "Cesium|Metadata|PropertyTable")
103 static const FString&
104 GetPropertyTableName(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
105
106 /**
107 * Gets the number of values each property in the table is expected to have.
108 * If an error occurred while parsing the property table, this returns zero.
109 *
110 * @param PropertyTable The property table.
111 */
112 UFUNCTION(
113 BlueprintCallable,
114 BlueprintPure,
115 Category = "Cesium|Metadata|PropertyTable")
116 static int64
117 GetPropertyTableCount(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
118
119 /**
120 * Gets all the properties of the property table, mapped by property name.
121 *
122 * @param PropertyTable The property table.
123 */
124 UFUNCTION(
125 BlueprintCallable,
126 BlueprintPure,
127 Category = "Cesium|Metadata|PropertyTable")
128 static const TMap<FString, FCesiumPropertyTableProperty>&
129 GetProperties(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
130
131 /**
132 * Gets the names of the properties in this property table.
133 *
134 * @param PropertyTable The property table.
135 */
136 UFUNCTION(
137 BlueprintCallable,
138 BlueprintPure,
139 Category = "Cesium|Metadata|PropertyTable")
140 static const TArray<FString>
141 GetPropertyNames(UPARAM(ref) const FCesiumPropertyTable& PropertyTable);
142
143 /**
144 * Retrieve a FCesiumPropertyTableProperty by name. If the property table
145 * does not contain a property with that name, this returns an invalid
146 * FCesiumPropertyTableProperty.
147 *
148 * @param PropertyTable The property table.
149 * @param PropertyName The name of the property to find.
150 */
151 UFUNCTION(
152 BlueprintCallable,
153 BlueprintPure,
154 Category = "Cesium|Metadata|PropertyTable")
156 UPARAM(ref) const FCesiumPropertyTable& PropertyTable,
157 const FString& PropertyName);
158
159 /**
160 * Gets all of the property values for a given feature, mapped by property
161 * name. This will only include values from valid property table properties.
162 *
163 * If the feature ID is out-of-bounds, the returned map will be empty.
164 *
165 * @param PropertyTable The property table.
166 * @param FeatureID The ID of the feature.
167 * @return The property values mapped by property name.
168 */
169 UFUNCTION(
170 BlueprintCallable,
171 BlueprintPure,
172 Category = "Cesium|Metadata|PropertyTable")
174 UPARAM(ref) const FCesiumPropertyTable& PropertyTable,
175 int64 FeatureID);
176
177 PRAGMA_DISABLE_DEPRECATION_WARNINGS
178 /**
179 * Gets all of the property values for a given feature as strings, mapped by
180 * property name. This will only include values from valid property table
181 * properties.
182 *
183 * Array properties cannot be converted to strings, so empty strings
184 * will be returned for their values.
185 *
186 * If the feature ID is out-of-bounds, the returned map will be empty.
187 *
188 * @param PropertyTable The property table.
189 * @param FeatureID The ID of the feature.
190 * @return The property values as strings mapped by property name.
191 */
192 UFUNCTION(
193 BlueprintCallable,
194 BlueprintPure,
195 Category = "Cesium|Metadata|PropertyTable",
196 Meta =
197 (DeprecatedFunction,
198 DeprecationMessage =
199 "Use GetValuesAsStrings to convert the output of GetMetadataValuesForFeature instead."))
200 static TMap<FString, FString> GetMetadataValuesForFeatureAsStrings(
201 UPARAM(ref) const FCesiumPropertyTable& PropertyTable,
202 int64 FeatureID);
203 PRAGMA_ENABLE_DEPRECATION_WARNINGS
204};
ECesiumPropertyTableStatus
Reports the status of a FCesiumPropertyTable.
static ECesiumPropertyTableStatus GetPropertyTableStatus(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets the status of the property table.
static PRAGMA_DISABLE_DEPRECATION_WARNINGS TMap< FString, FString > GetMetadataValuesForFeatureAsStrings(UPARAM(ref) const FCesiumPropertyTable &PropertyTable, int64 FeatureID)
Gets all of the property values for a given feature as strings, mapped by property name.
static TMap< FString, FCesiumMetadataValue > GetMetadataValuesForFeature(UPARAM(ref) const FCesiumPropertyTable &PropertyTable, int64 FeatureID)
Gets all of the property values for a given feature, mapped by property name.
static int64 GetPropertyTableCount(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets the number of values each property in the table is expected to have.
static const FCesiumPropertyTableProperty & FindProperty(UPARAM(ref) const FCesiumPropertyTable &PropertyTable, const FString &PropertyName)
Retrieve a FCesiumPropertyTableProperty by name.
static const TArray< FString > GetPropertyNames(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets the names of the properties in this property table.
static const TMap< FString, FCesiumPropertyTableProperty > & GetProperties(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets all the properties of the property table, mapped by property name.
static const FString & GetPropertyTableName(UPARAM(ref) const FCesiumPropertyTable &PropertyTable)
Gets the name of the property table.
A Blueprint-accessible wrapper for a glTF metadata value.
A Blueprint-accessible wrapper for a glTF property table property in EXT_structural_metadata.
A Blueprint-accessible wrapper for a glTF property table.
FString getClassName() const
Gets the name of the metadata class that this property table conforms to.
FCesiumPropertyTable(const CesiumGltf::Model &Model, const CesiumGltf::PropertyTable &PropertyTable)
Constructs a property table from a glTF Property Table.
FCesiumPropertyTable()
Construct an empty property table instance.