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