Cesium for Unreal 2.18.0
Loading...
Searching...
No Matches
CesiumPropertyTexture.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
7#include "Containers/Array.h"
8#include "Kismet/BlueprintFunctionLibrary.h"
9#include "Kismet/GameplayStatics.h"
10
11#include <CesiumGltf/PropertyTextureView.h>
12
13#include "CesiumPropertyTexture.generated.h"
14
15namespace CesiumGltf {
16struct Model;
17struct PropertyTexture;
18}; // namespace CesiumGltf
19
20UENUM(BlueprintType)
21enum class ECesiumPropertyTextureStatus : uint8 {
22 /* The property texture is valid. */
23 Valid = 0,
24 /* The property texture instance was not initialized from an actual glTF
25 property texture. */
27 /* The property texture's class could not be found in the schema of the
28 metadata extension. */
30};
31
32/**
33 * @brief A blueprint-accessible wrapper of a property texture from a glTF.
34 * Provides access to {@link FCesiumPropertyTextureProperty} views of texture
35 * metadata.
36 */
37USTRUCT(BlueprintType)
38struct CESIUMRUNTIME_API FCesiumPropertyTexture {
39 GENERATED_USTRUCT_BODY()
40
41public:
42 /**
43 * Construct an empty property texture instance.
44 */
47
48 /**
49 * Constructs a property texture from the given glTF.
50 *
51 * @param model The model that stores EXT_structural_metadata.
52 * @param propertyTexture The target property texture.
53 */
55 const CesiumGltf::Model& model,
56 const CesiumGltf::PropertyTexture& propertyTexture)
58 model,
59 propertyTexture,
60 FCesiumMetadataEnumCollection::GetOrCreateFromModel(model)) {}
61
62 /**
63 * Constructs a property texture from the given glTF.
64 *
65 * @param model The model that stores EXT_structural_metadata.
66 * @param propertyTexture The target property texture.
67 * @param pEnumCollection The enum collection to use, if any.
68 */
70 const CesiumGltf::Model& model,
71 const CesiumGltf::PropertyTexture& propertyTexture,
72 const TSharedPtr<FCesiumMetadataEnumCollection>& pEnumCollection);
73
74 /**
75 * Gets the name of the metadata class that this property table conforms to.
76 */
77 FString getClassName() const { return _className; }
78
79private:
81 FString _name;
82 FString _className;
83
84 TMap<FString, FCesiumPropertyTextureProperty> _properties;
85
87};
88
89UCLASS()
91 : public UBlueprintFunctionLibrary {
92 GENERATED_BODY()
93
94public:
95 /**
96 * Gets the status of the property texture. If the property texture is invalid
97 * in any way, this briefly indicates why.
98 *
99 * @param PropertyTexture The property texture.
100 */
101 UFUNCTION(
102 BlueprintCallable,
103 BlueprintPure,
104 Category = "Cesium|Metadata|PropertyTexture")
107 const FCesiumPropertyTexture& PropertyTexture);
108
109 /**
110 * Gets the name of the property texture.
111 *
112 * @param PropertyTexture The property texture.
113 */
114 UFUNCTION(
115 BlueprintCallable,
116 BlueprintPure,
117 Category = "Cesium|Metadata|PropertyTexture")
118 static const FString&
120 const FCesiumPropertyTexture& PropertyTexture);
121
122 /**
123 * Gets all the properties of the property texture, mapped by property name.
124 *
125 * @param PropertyTexture The property texture.
126 */
127 UFUNCTION(
128 BlueprintCallable,
129 BlueprintPure,
130 Category = "Cesium|Metadata|PropertyTexture")
131 static const TMap<FString, FCesiumPropertyTextureProperty>
132 GetProperties(UPARAM(ref) const FCesiumPropertyTexture& PropertyTexture);
133
134 /**
135 * Gets the names of the properties in this property texture. If the property
136 * texture is invalid, this returns an empty array.
137 *
138 * @param PropertyTexture The property texture.
139 */
140 UFUNCTION(
141 BlueprintCallable,
142 BlueprintPure,
143 Category = "Cesium|Metadata|PropertyTexture")
144 static const TArray<FString>
145 GetPropertyNames(UPARAM(ref) const FCesiumPropertyTexture& PropertyTexture);
146
147 /**
148 * Retrieve a FCesiumPropertyTextureProperty by name. If the property texture
149 * does not contain a property with that name, this returns an invalid
150 * FCesiumPropertyTextureProperty.
151 *
152 * @param PropertyTexture The property texture.
153 * @param PropertyName The name of the property to find.
154 */
155 UFUNCTION(
156 BlueprintCallable,
157 BlueprintPure,
158 Category = "Cesium|Metadata|PropertyTexture")
160 UPARAM(ref) const FCesiumPropertyTexture& PropertyTexture,
161 const FString& PropertyName);
162
163 /**
164 * Gets all of the property values at the given texture coordinates, mapped by
165 * property name. This will only include values from valid property texture
166 * properties.
167 *
168 * In EXT_structural_metadata, individual properties can specify different
169 * texture coordinate sets to be sampled from. This method uses the same
170 * coordinates to sample each property, regardless of its intended texture
171 * coordinate set. Use GetMetadataValuesForHit instead to sample the property
172 * texture's properties with their respective texture coordinate sets.
173 *
174 * @param PropertyTexture The property texture.
175 * @param UV The texture coordinates.
176 * @return The property values mapped by property name.
177 */
178 UFUNCTION(
179 BlueprintCallable,
180 BlueprintPure,
181 Category = "Cesium|Metadata|PropertyTexture")
183 UPARAM(ref) const FCesiumPropertyTexture& PropertyTexture,
184 const FVector2D& UV);
185
186 /**
187 * Given a trace hit result, gets all of the property values from property
188 * texture on the hit component, mapped by property name. This will only
189 * include values from valid property texture properties.
190 *
191 * In EXT_structural_metadata, individual properties can specify different
192 * texture coordinate sets to be sampled from. This method uses the
193 * corresponding texture coordinate sets to sample each property.
194 *
195 * @param PropertyTexture The property texture.
196 * @param Hit The trace hit result
197 * @return The property values mapped by property name.
198 */
199 UFUNCTION(
200 BlueprintCallable,
201 BlueprintPure,
202 Category = "Cesium|Metadata|PropertyTexture")
204 UPARAM(ref) const FCesiumPropertyTexture& PropertyTexture,
205 const FHitResult& Hit);
206};
ECesiumPropertyTextureStatus
static const ECesiumPropertyTextureStatus GetPropertyTextureStatus(UPARAM(ref) const FCesiumPropertyTexture &PropertyTexture)
Gets the status of the property texture.
static TMap< FString, FCesiumMetadataValue > GetMetadataValuesFromHit(UPARAM(ref) const FCesiumPropertyTexture &PropertyTexture, const FHitResult &Hit)
Given a trace hit result, gets all of the property values from property texture on the hit component,...
static const FString & GetPropertyTextureName(UPARAM(ref) const FCesiumPropertyTexture &PropertyTexture)
Gets the name of the property texture.
static const FCesiumPropertyTextureProperty & FindProperty(UPARAM(ref) const FCesiumPropertyTexture &PropertyTexture, const FString &PropertyName)
Retrieve a FCesiumPropertyTextureProperty by name.
static const TMap< FString, FCesiumPropertyTextureProperty > GetProperties(UPARAM(ref) const FCesiumPropertyTexture &PropertyTexture)
Gets all the properties of the property texture, mapped by property name.
static TMap< FString, FCesiumMetadataValue > GetMetadataValuesForUV(UPARAM(ref) const FCesiumPropertyTexture &PropertyTexture, const FVector2D &UV)
Gets all of the property values at the given texture coordinates, mapped by property name.
static const TArray< FString > GetPropertyNames(UPARAM(ref) const FCesiumPropertyTexture &PropertyTexture)
Gets the names of the properties in this property texture.
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 property texture property from a glTF.
A blueprint-accessible wrapper of a property texture from a glTF.
FCesiumPropertyTexture(const CesiumGltf::Model &model, const CesiumGltf::PropertyTexture &propertyTexture, const TSharedPtr< FCesiumMetadataEnumCollection > &pEnumCollection)
Constructs a property texture from the given glTF.
FCesiumPropertyTexture()
Construct an empty property texture instance.
FString getClassName() const
Gets the name of the metadata class that this property table conforms to.
FCesiumPropertyTexture(const CesiumGltf::Model &model, const CesiumGltf::PropertyTexture &propertyTexture)
Constructs a property texture from the given glTF.
friend class UCesiumPropertyTextureBlueprintLibrary