Cesium for Unreal 2.21.1
Loading...
Searching...
No Matches
CesiumMetadataPickingBlueprintLibrary.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
6#include "Containers/UnrealString.h"
7#include "Kismet/BlueprintFunctionLibrary.h"
8#include "UObject/ObjectMacros.h"
9#include "CesiumMetadataPickingBlueprintLibrary.generated.h"
10
11struct FHitResult;
15
16UCLASS()
18 : public UBlueprintFunctionLibrary {
19 GENERATED_BODY()
20
21public:
22 /**
23 * Compute the UV coordinates from the given line trace hit, assuming it has
24 * hit a glTF primitive component that contains the specified texture
25 * coordinate set. The texture coordinate set is specified relative to the
26 * glTF itself, where the set index N resolves to the "TEXCOORD_N" attribute
27 * in the glTF primitive.
28 *
29 * This function can be used to sample feature ID textures or property
30 * textures in the primitive. This works similarly to the FindCollisionUV
31 * Blueprint, except it does not require the texture coordinate sets to be
32 * present in the model's physics mesh.
33 *
34 * Returns false if the given texture coordinate set index does not exist for
35 * the primitive, or if its accessor is invalid.
36 */
37 UFUNCTION(
38 BlueprintCallable,
39 BlueprintPure,
40 Category = "Cesium|Metadata|Picking")
41 static bool FindUVFromHit(
42 const FHitResult& Hit,
43 int64 GltfTexCoordSetIndex,
44 FVector2D& UV);
45
46 /**
47 * Gets the property table values from a given line trace hit, assuming
48 * that it has hit a feature of a glTF primitive component.
49 *
50 * A primitive may have multiple feature ID sets, so this allows a feature ID
51 * set to be specified by index. This value should index into the array of
52 * CesiumFeatureIdSets in the component's CesiumPrimitiveFeatures. If the
53 * feature ID set is associated with a property table, it will return that
54 * property table's data.
55 *
56 * For feature ID textures and implicit feature IDs, the feature ID can vary
57 * across the face of a primitive. If the specified CesiumFeatureIdSet is one
58 * of those types, the feature ID of the first vertex on the face will be
59 * used.
60 *
61 * The returned result may be empty for several reasons:
62 * - if the component is not a Cesium glTF primitive component
63 * - if the hit's face index is somehow out-of-bounds
64 * - if the specified feature ID set does not exist on the primitive
65 * - if the specified feature ID set is not associated with a valid property
66 * table
67 *
68 * Additionally, if any of the property table's properties are invalid, they
69 * will not be included in the result.
70 */
71 UFUNCTION(
72 BlueprintCallable,
73 BlueprintPure,
74 Category = "Cesium|Metadata|Picking")
76 const FHitResult& Hit,
77 int64 FeatureIDSetIndex = 0);
78
79 /**
80 * Gets the property texture values from a given line trace hit, assuming it
81 * has hit a glTF primitive component.
82 *
83 * A primitive may use multiple property textures, as indicated by its indices
84 * in CesiumPrimitiveMetadata. This function allows for selection of which
85 * property texture to use from those available in CesiumPrimitiveMetadata.
86 *
87 * In other words, the "Primitive Property Texture Index" should index into
88 * the array property texture indices in the CesiumPrimitiveMetadata. The
89 * primitive metadata will not necessarily contain all of the available
90 * property textures in the CesiumModelMetadata, nor will it necessarily be
91 * listed in the same order.
92 *
93 * The returned result may be empty for several reasons:
94 * - if the component is not a Cesium glTF primitive component
95 * - if the given primitive property texture index is out-of-bounds
96 * - if the property texture index derived from CesiumPrimitiveMetadata
97 * is out-of-bounds
98 *
99 * Additionally, if any of the property texture's properties are invalid, they
100 * will not be included in the result.
101 */
102 UFUNCTION(
103 BlueprintCallable,
104 BlueprintPure,
105 Category = "Cesium|Metadata|Picking")
107 const FHitResult& Hit,
108 int64 PrimitivePropertyTextureIndex = 0);
109
110 PRAGMA_DISABLE_DEPRECATION_WARNINGS
111 /**
112 * Gets the metadata values for a face on a glTF primitive component.
113 *
114 * A primitive may have multiple feature ID sets, so this allows a feature ID
115 * set to be specified by index. This value should index into the array of
116 * CesiumFeatureIdSets in the component's CesiumPrimitiveFeatures. If the
117 * feature ID set is associated with a property table, it will return that
118 * property table's data.
119 *
120 * For feature ID textures and implicit feature IDs, the feature ID can vary
121 * across the face of a primitive. If the specified CesiumFeatureIdSet is one
122 * of those types, the feature ID of the first vertex on the face will be
123 * used.
124 *
125 * The returned result may be empty for several reasons:
126 * - if the component is not a Cesium glTF primitive component
127 * - if the given face index is out-of-bounds
128 * - if the specified feature ID set does not exist on the primitive
129 * - if the specified feature ID set is not associated with a valid property
130 * table
131 *
132 * Additionally, if any of the property table's properties are invalid, they
133 * will not be included in the result.
134 */
135 UFUNCTION(
136 BlueprintCallable,
137 BlueprintPure,
138 Meta =
139 (DeprecatedFunction,
140 DeprecationMessage = "Use GetPropertyTableValuesFromHit instead."))
142 const UPrimitiveComponent* Component,
143 int64 FaceIndex,
144 int64 FeatureIDSetIndex = 0);
145
146 /**
147 * Gets the metadata values for a face on a glTF primitive component, as
148 * strings.
149 *
150 * A primitive may have multiple feature ID sets, so this allows a feature ID
151 * set to be specified by index. This value should index into the array of
152 * CesiumFeatureIdSets in the component's CesiumPrimitiveFeatures. If the
153 * feature ID set is associated with a property table, it will return that
154 * property table's data.
155 *
156 * For feature ID textures and implicit feature IDs, the feature ID can vary
157 * across the face of a primitive. If the specified CesiumFeatureIdSet is one
158 * of those types, the feature ID of the first vertex on the face will be
159 * used.
160 *
161 * The returned result may be empty for several reasons:
162 * - if the component is not a Cesium glTF primitive component
163 * - if the given face index is out-of-bounds
164 * - if the specified feature ID set does not exist on the primitive
165 * - if the specified feature ID set is not associated with a valid property
166 * table
167 *
168 * Additionally, if any of the property table's properties are invalid, they
169 * will not be included in the result. Array properties will return empty
170 * strings.
171 */
172 UFUNCTION(
173 BlueprintCallable,
174 BlueprintPure,
175 Meta =
176 (DeprecatedFunction,
177 DeprecationMessage =
178 "Use GetValuesAsStrings to convert the output of GetPropertyTableValuesFromHit instead."))
179 static TMap<FString, FString> GetMetadataValuesForFaceAsStrings(
180 const UPrimitiveComponent* Component,
181 int64 FaceIndex,
182 int64 FeatureIDSetIndex = 0);
183 PRAGMA_ENABLE_DEPRECATION_WARNINGS
184
185 /**
186 * Retrieves a property table property from the component by name.
187 * If the specified feature ID set does not exist or if the property table
188 * does not contain a property with that name, the returned property will be
189 * invalid.
190 */
191 UFUNCTION(
192 BlueprintCallable,
193 BlueprintPure,
194 Category = "Cesium|Metadata|Picking")
196 const UPrimitiveComponent* Component,
197 const FString& PropertyName,
198 int64 FeatureIDSetIndex = 0);
199
200 /**
201 * Retrieves a property table property by name, from the primitive features
202 * and the model metadata.
203 * If the specified feature ID set does not exist or if the property table
204 * does not contain a property with that name, the returned property will be
205 * invalid.
206 */
208 const FCesiumPrimitiveFeatures& Features,
209 const FCesiumModelMetadata& Metadata,
210 const FString& PropertyName,
211 int64 FeatureIDSetIndex);
212};
static bool FindUVFromHit(const FHitResult &Hit, int64 GltfTexCoordSetIndex, FVector2D &UV)
Compute the UV coordinates from the given line trace hit, assuming it has hit a glTF primitive compon...
static PRAGMA_ENABLE_DEPRECATION_WARNINGS const FCesiumPropertyTableProperty & FindPropertyTableProperty(const UPrimitiveComponent *Component, const FString &PropertyName, int64 FeatureIDSetIndex=0)
Retrieves a property table property from the component by name.
static TMap< FString, FString > GetMetadataValuesForFaceAsStrings(const UPrimitiveComponent *Component, int64 FaceIndex, int64 FeatureIDSetIndex=0)
Gets the metadata values for a face on a glTF primitive component, as strings.
static PRAGMA_DISABLE_DEPRECATION_WARNINGS TMap< FString, FCesiumMetadataValue > GetMetadataValuesForFace(const UPrimitiveComponent *Component, int64 FaceIndex, int64 FeatureIDSetIndex=0)
Gets the metadata values for a face on a glTF primitive component.
static TMap< FString, FCesiumMetadataValue > GetPropertyTableValuesFromHit(const FHitResult &Hit, int64 FeatureIDSetIndex=0)
Gets the property table values from a given line trace hit, assuming that it has hit a feature of a g...
static TMap< FString, FCesiumMetadataValue > GetPropertyTextureValuesFromHit(const FHitResult &Hit, int64 PrimitivePropertyTextureIndex=0)
Gets the property texture values from a given line trace hit, assuming it has hit a glTF primitive co...
A Blueprint-accessible wrapper for a glTF metadata value.
A blueprint-accessible wrapper for metadata contained in a glTF model.
A Blueprint-accessible wrapper for a glTF Primitive's mesh features.
A Blueprint-accessible wrapper for a glTF property table property in EXT_structural_metadata.