Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
CesiumFeatureIdSet.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 <variant>
9#include "CesiumFeatureIdSet.generated.h"
10
11namespace CesiumGltf {
12struct Model;
13struct FeatureId;
14struct ExtensionExtInstanceFeaturesFeatureId;
15} // namespace CesiumGltf
16
17/**
18 * @brief The type of a feature ID set.
19 */
20UENUM(BlueprintType)
21enum class ECesiumFeatureIdSetType : uint8 {
22 None,
24 Texture,
28};
29
30/**
31 * @brief A blueprint-accessible wrapper for a feature ID set from a glTF
32 * primitive. A feature ID can be defined as a per-vertex attribute, as a
33 * feature texture, implicitly via vertex ID, or associated with glTF
34 * instances. These can be used with the corresponding {@link
35 * FCesiumPropertyTable} to access the metadata.
36 */
37USTRUCT(BlueprintType)
38struct CESIUMRUNTIME_API FCesiumFeatureIdSet {
39 GENERATED_USTRUCT_BODY()
40
41 using FeatureIDType = std::variant<
42 std::monostate,
45
46public:
48 : _featureIDSetType(ECesiumFeatureIdSetType::None),
49 _featureCount(0),
50 _nullFeatureID(-1) {}
51
53 const CesiumGltf::Model& Model,
54 const CesiumGltf::MeshPrimitive& Primitive,
55 const CesiumGltf::FeatureId& FeatureId);
56
58 const CesiumGltf::Model& Model,
59 const CesiumGltf::Node& Node,
61 InstanceFeatureId);
62
63private:
64 FeatureIDType _featureID;
65 ECesiumFeatureIdSetType _featureIDSetType;
66 int64 _featureCount;
67 int64 _nullFeatureID;
68 int64 _propertyTableIndex;
69 FString _label;
70
72};
73
74UCLASS()
76 : public UBlueprintFunctionLibrary {
77 GENERATED_BODY()
78public:
79 /**
80 * Gets the type of this feature ID set.
81 */
82 UFUNCTION(
83 BlueprintCallable,
84 BlueprintPure,
85 Category = "Cesium|Features|FeatureIDSet")
86 static const ECesiumFeatureIdSetType
87 GetFeatureIDSetType(UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet);
88
89 /**
90 * Gets this feature ID set as a feature ID attribute. This can be used for
91 * more fine-grained interaction with the attribute itself. If this feature ID
92 * is not defined as an attribute, then the returned attribute will be
93 * invalid.
94 */
95 UFUNCTION(
96 BlueprintCallable,
97 BlueprintPure,
98 Category = "Cesium|Features|FeatureIDSet")
99 static const FCesiumFeatureIdAttribute&
100 GetAsFeatureIDAttribute(UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet);
101
102 /**
103 * Gets this feature ID set as a feature ID texture. This can be used for more
104 * fine-grained interaction with the texture itself. If this feature ID is
105 * not defined as a texture, then the returned texture will be invalid.
106 */
107 UFUNCTION(
108 BlueprintCallable,
109 BlueprintPure,
110 Category = "Cesium|Features|FeatureIDSet")
111 static const FCesiumFeatureIdTexture&
112 GetAsFeatureIDTexture(UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet);
113
114 /**
115 * Get the index of the property table corresponding to this feature
116 * ID set. The index can be used to fetch the appropriate
117 * FCesiumPropertyTable from the FCesiumModelMetadata. If the
118 * feature ID set does not specify a property table, this returns -1.
119 */
120 UFUNCTION(
121 BlueprintCallable,
122 BlueprintPure,
123 Category = "Cesium|Features|FeatureIDSet")
124 static const int64
125 GetPropertyTableIndex(UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet);
126
127 /**
128 * Get the number of features this primitive has.
129 */
130 UFUNCTION(
131 BlueprintCallable,
132 BlueprintPure,
133 Category = "Cesium|Features|FeatureIDSet")
134 static int64 GetFeatureCount(UPARAM(ref)
135 const FCesiumFeatureIdSet& FeatureIDSet);
136
137 /**
138 * Gets the null feature ID, i.e., the value that indicates no feature is
139 * associated with the owner. In other words, if a vertex or texel returns
140 * this value, then it is not associated with any feature.
141 *
142 * If this value was not defined in the glTF feature ID set, this defaults to
143 * -1.
144 */
145 UFUNCTION(
146 BlueprintCallable,
147 BlueprintPure,
148 Category = "Cesium|Features|FeatureIDSet")
149 static const int64
150 GetNullFeatureID(UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet);
151
152 /**
153 * Gets the label assigned to this feature ID set. If no label was present in
154 * the glTF feature ID set, this returns an empty string.
155 */
156 UFUNCTION(
157 BlueprintCallable,
158 BlueprintPure,
159 Category = "Cesium|Features|FeatureIDSet")
160 static const FString GetLabel(UPARAM(ref)
161 const FCesiumFeatureIdSet& FeatureIDSet);
162
163 /**
164 * Gets the feature ID associated with a given vertex. The feature ID can be
165 * used with a FCesiumPropertyTable to retrieve the corresponding metadata.
166 *
167 * This returns -1 if the given vertex is out-of-bounds, or if the feature ID
168 * set is invalid (e.g., it contains an invalid feature ID texture).
169 */
170 UFUNCTION(
171 BlueprintCallable,
172 BlueprintPure,
173 Category = "Cesium|Features|FeatureIDSet")
175 UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet,
176 int64 VertexIndex);
177
178 /**
179 * Gets the feature ID associated with a given instance in glTF models using
180 * the EXT_mesh_gpu_instancing and EXT_instance_features extensions. The
181 * feature ID can be used with a FCesiumPropertyTable to retrieve the
182 * corresponding metadata.
183 *
184 * This returns -1 if the given instance is out-of-bounds, if the feature ID
185 * set is not for instances, or if the feature ID set is invalid (e.g., it
186 * contains an invalid feature ID attribute).
187 */
188 UFUNCTION(
189 BlueprintCallable,
190 BlueprintPure,
191 Category = "Cesium|Features|FeatureIDSet")
193 UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet,
194 int64 InstanceIndex);
195
196 /**
197 * Given a trace hit result, gets the feature ID from the feature ID set on
198 * the hit component. This returns a more accurate value for feature ID
199 * textures, since they define feature IDs per-texel instead of per-vertex.
200 * The feature ID can be used with a FCesiumPropertyTable to retrieve the
201 * corresponding metadata.
202 *
203 * This can still retrieve the feature IDs for non-texture feature ID sets.
204 * For attribute or implicit feature IDs, the first feature ID associated
205 * with the first vertex of the intersected face is returned.
206 *
207 * This returns -1 if the feature ID set is invalid (e.g., it contains an
208 * invalid feature ID texture).
209 */
210 UFUNCTION(
211 BlueprintCallable,
212 BlueprintPure,
213 Category = "Cesium|Features|FeatureIDSet")
215 UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet,
216 const FHitResult& Hit);
217};
ECesiumFeatureIdSetType
The type of a feature ID set.
static const int64 GetNullFeatureID(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet)
Gets the null feature ID, i.e., the value that indicates no feature is associated with the owner.
static const FCesiumFeatureIdAttribute & GetAsFeatureIDAttribute(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet)
Gets this feature ID set as a feature ID attribute.
static const int64 GetPropertyTableIndex(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet)
Get the index of the property table corresponding to this feature ID set.
static int64 GetFeatureIDFromHit(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet, const FHitResult &Hit)
Given a trace hit result, gets the feature ID from the feature ID set on the hit component.
static int64 GetFeatureIDForInstance(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet, int64 InstanceIndex)
Gets the feature ID associated with a given instance in glTF models using the EXT_mesh_gpu_instancing...
static int64 GetFeatureCount(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet)
Get the number of features this primitive has.
static int64 GetFeatureIDForVertex(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet, int64 VertexIndex)
Gets the feature ID associated with a given vertex.
static const ECesiumFeatureIdSetType GetFeatureIDSetType(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet)
Gets the type of this feature ID set.
static const FString GetLabel(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet)
Gets the label assigned to this feature ID set.
static const FCesiumFeatureIdTexture & GetAsFeatureIDTexture(UPARAM(ref) const FCesiumFeatureIdSet &FeatureIDSet)
Gets this feature ID set as a feature ID texture.
STL namespace.
A blueprint-accessible wrapper for a feature ID attribute from a glTF model.
A blueprint-accessible wrapper for a feature ID set from a glTF primitive.
std::variant< std::monostate, FCesiumFeatureIdAttribute, FCesiumFeatureIdTexture > FeatureIDType
FCesiumFeatureIdSet(const CesiumGltf::Model &Model, const CesiumGltf::MeshPrimitive &Primitive, const CesiumGltf::FeatureId &FeatureId)
FCesiumFeatureIdSet(const CesiumGltf::Model &Model, const CesiumGltf::Node &Node, const CesiumGltf::ExtensionExtInstanceFeaturesFeatureId &InstanceFeatureId)
A blueprint-accessible wrapper for a feature ID texture from a glTF primitive.