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