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