Cesium for Unreal 2.18.0
Loading...
Searching...
No Matches
CesiumPropertyAttribute.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
8#include "Kismet/BlueprintFunctionLibrary.h"
9#include "UObject/ObjectMacros.h"
10#include "CesiumPropertyAttribute.generated.h"
11
12namespace CesiumGltf {
13struct Model;
15} // namespace CesiumGltf
16
17/**
18 * @brief Reports the status of a FCesiumPropertyAttribute. If the property
19 * attribute cannot be accessed, this briefly indicates why.
20 */
21UENUM(BlueprintType)
23 /* The property attribute is valid. */
24 Valid = 0,
25 /* The property attribute instance was not initialized from an actual glTF
26 property attribute. */
28 /* The property attribute's class could not be found in the schema of the
29 metadata extension. */
31};
32
33/**
34 * A Blueprint-accessible wrapper for a glTF property attribute.
35 * Provides access to {@link FCesiumPropertyAttributeProperty} views of
36 * per-vertex metadata.
37 */
38USTRUCT(BlueprintType)
39struct CESIUMRUNTIME_API FCesiumPropertyAttribute {
40 GENERATED_USTRUCT_BODY()
41
42public:
43 /**
44 * Construct an empty property attribute instance.
45 */
49
50 /**
51 * Constructs a property attribute from the given glTF.
52 *
53 * @param model The model that stores EXT_structural_metadata.
54 * @param primitive The primitive that contains the target property attribute.
55 * @param propertyAttribute The target property attribute.
56 */
58 const CesiumGltf::Model& model,
59 const CesiumGltf::MeshPrimitive& primitive,
60 const CesiumGltf::PropertyAttribute& propertyAttribute)
62 model,
63 primitive,
64 propertyAttribute,
65 FCesiumMetadataEnumCollection::GetOrCreateFromModel(model)) {}
66
67 /**
68 * Constructs a property attribute from the given glTF.
69 *
70 * @param model The model that stores EXT_structural_metadata.
71 * @param primitive The primitive that contains the target property attribute.
72 * @param propertyAttribute The target property attribute.
73 * @param pEnumCollection The enum collection to use, if any.
74 */
76 const CesiumGltf::Model& model,
77 const CesiumGltf::MeshPrimitive& primitive,
78 const CesiumGltf::PropertyAttribute& propertyAttribute,
79 const TSharedPtr<FCesiumMetadataEnumCollection>& pEnumCollection);
80
81 /**
82 * Gets the name of the metadata class that this property attribute conforms
83 * to.
84 */
85 FString getClassName() const { return _className; }
86
87private:
89 FString _name;
90 FString _className;
91
92 int64 _elementCount;
93 TMap<FString, FCesiumPropertyAttributeProperty> _properties;
94
96};
97
98UCLASS()
100 : public UBlueprintFunctionLibrary {
101 GENERATED_BODY()
102
103public:
104 /**
105 * Gets the status of the property attribute. If an error occurred while
106 * parsing the property attribute from the glTF extension, this briefly
107 * conveys why.
108 *
109 * @param PropertyAttribute The property attribute.
110 */
111 UFUNCTION(
112 BlueprintCallable,
113 BlueprintPure,
114 Category = "Cesium|Metadata|PropertyAttribute")
116 UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute);
117
118 /**
119 * Gets the name of the property attribute. If no name was specified in the
120 * glTF extension, this returns an empty string.
121 *
122 * @param PropertyAttribute The property attribute.
123 */
124 UFUNCTION(
125 BlueprintCallable,
126 BlueprintPure,
127 Category = "Cesium|Metadata|PropertyAttribute")
128 static const FString& GetPropertyAttributeName(
129 UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute);
130
131 /**
132 * Gets all the properties of the property attribute, mapped by property name.
133 *
134 * @param PropertyAttribute The property attribute.
135 */
136 UFUNCTION(
137 BlueprintCallable,
138 BlueprintPure,
139 Category = "Cesium|Metadata|PropertyAttribute")
140 static const TMap<FString, FCesiumPropertyAttributeProperty>&
141 GetProperties(UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute);
142
143 /**
144 * Gets the names of the properties in this property attribute.
145 *
146 * @param PropertyAttribute The property attribute.
147 */
148 UFUNCTION(
149 BlueprintCallable,
150 BlueprintPure,
151 Category = "Cesium|Metadata|PropertyAttribute")
152 static const TArray<FString>
154 const FCesiumPropertyAttribute& PropertyAttribute);
155
156 /**
157 * Retrieve a FCesiumPropertyAttributeProperty by name. If the property
158 * attribute does not contain a property with that name, this returns an
159 * invalid FCesiumPropertyAttributeProperty.
160 *
161 * @param PropertyAttribute The property attribute.
162 * @param PropertyName The name of the property to find.
163 */
164 UFUNCTION(
165 BlueprintCallable,
166 BlueprintPure,
167 Category = "Cesium|Metadata|PropertyAttribute")
169 UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute,
170 const FString& PropertyName);
171
172 /**
173 * Gets all of the property values for the given vertex index, mapped by
174 * property name. This will only include values from valid property attribute
175 * properties.
176 *
177 * If the index is out-of-bounds, the returned map will be empty.
178 *
179 * @param PropertyAttribute The property attribute.
180 * @param Index The index of the target vertex.
181 * @return The property values mapped by property name.
182 */
183 UFUNCTION(
184 BlueprintCallable,
185 BlueprintPure,
186 Category = "Cesium|Metadata|PropertyAttribute")
188 UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute,
189 int64 Index);
190};
ECesiumPropertyAttributeStatus
Reports the status of a FCesiumPropertyAttribute.
static const TArray< FString > GetPropertyNames(UPARAM(ref) const FCesiumPropertyAttribute &PropertyAttribute)
Gets the names of the properties in this property attribute.
static TMap< FString, FCesiumMetadataValue > GetMetadataValuesAtIndex(UPARAM(ref) const FCesiumPropertyAttribute &PropertyAttribute, int64 Index)
Gets all of the property values for the given vertex index, mapped by property name.
static const FCesiumPropertyAttributeProperty & FindProperty(UPARAM(ref) const FCesiumPropertyAttribute &PropertyAttribute, const FString &PropertyName)
Retrieve a FCesiumPropertyAttributeProperty by name.
static const TMap< FString, FCesiumPropertyAttributeProperty > & GetProperties(UPARAM(ref) const FCesiumPropertyAttribute &PropertyAttribute)
Gets all the properties of the property attribute, mapped by property name.
static const FString & GetPropertyAttributeName(UPARAM(ref) const FCesiumPropertyAttribute &PropertyAttribute)
Gets the name of the property attribute.
static ECesiumPropertyAttributeStatus GetPropertyAttributeStatus(UPARAM(ref) const FCesiumPropertyAttribute &PropertyAttribute)
Gets the status of the property attribute.
Contains a set of enum definitions obtained from a CesiumGltf::Schema.
A Blueprint-accessible wrapper for a glTF metadata value.
A Blueprint-accessible wrapper for a glTF property attribute property in EXT_structural_metadata.
A Blueprint-accessible wrapper for a glTF property attribute.
FString getClassName() const
Gets the name of the metadata class that this property attribute conforms to.
friend class UCesiumPropertyAttributeBlueprintLibrary
FCesiumPropertyAttribute()
Construct an empty property attribute instance.
FCesiumPropertyAttribute(const CesiumGltf::Model &model, const CesiumGltf::MeshPrimitive &primitive, const CesiumGltf::PropertyAttribute &propertyAttribute)
Constructs a property attribute from the given glTF.
FCesiumPropertyAttribute(const CesiumGltf::Model &model, const CesiumGltf::MeshPrimitive &primitive, const CesiumGltf::PropertyAttribute &propertyAttribute, const TSharedPtr< FCesiumMetadataEnumCollection > &pEnumCollection)
Constructs a property attribute from the given glTF.