Cesium for Unreal 2.12.0
Loading...
Searching...
No Matches
CesiumPropertyTextureProperty.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
6#include "GenericPlatform/GenericPlatform.h"
7#include "Kismet/BlueprintFunctionLibrary.h"
8#include <CesiumGltf/KhrTextureTransform.h>
9#include <CesiumGltf/PropertyTexturePropertyView.h>
10#include <any>
11#include <optional>
12#include "CesiumPropertyTextureProperty.generated.h"
13
18UENUM(BlueprintType)
20 /* The property texture property is valid. */
21 Valid = 0,
22 /* The property texture property is empty but has a specified default value.
23 */
25 /* The property texture property does not exist in the glTF, or the property
26 definition itself contains errors. */
28 /* The data associated with the property texture property is malformed and
29 cannot be retrieved. */
31 /* The type of this property texture property is not supported. */
33};
34
39USTRUCT(BlueprintType)
40struct CESIUMRUNTIME_API FCesiumPropertyTextureProperty {
41 GENERATED_USTRUCT_BODY()
42
43public:
46 _property(),
47 _valueType(),
48 _normalized(false) {}
49
50 template <typename T, bool Normalized>
54 _property(Property),
55 _valueType(),
56 _normalized(Normalized) {
57 switch (Property.status()) {
58 case CesiumGltf::PropertyTexturePropertyViewStatus::Valid:
59 _status = ECesiumPropertyTexturePropertyStatus::Valid;
60 break;
61 case CesiumGltf::PropertyTexturePropertyViewStatus::
62 EmptyPropertyWithDefault:
63 _status = ECesiumPropertyTexturePropertyStatus::EmptyPropertyWithDefault;
64 break;
65 case CesiumGltf::PropertyTexturePropertyViewStatus::
66 ErrorUnsupportedProperty:
67 _status = ECesiumPropertyTexturePropertyStatus::ErrorUnsupportedProperty;
68 return;
69 case CesiumGltf::PropertyTexturePropertyViewStatus::
70 ErrorInvalidPropertyTexture:
71 case CesiumGltf::PropertyTexturePropertyViewStatus::
72 ErrorNonexistentProperty:
73 case CesiumGltf::PropertyTexturePropertyViewStatus::ErrorTypeMismatch:
74 case CesiumGltf::PropertyTexturePropertyViewStatus::
75 ErrorComponentTypeMismatch:
76 case CesiumGltf::PropertyTexturePropertyViewStatus::ErrorArrayTypeMismatch:
77 case CesiumGltf::PropertyTexturePropertyViewStatus::
78 ErrorInvalidNormalization:
79 case CesiumGltf::PropertyTexturePropertyViewStatus::
80 ErrorNormalizationMismatch:
81 case CesiumGltf::PropertyTexturePropertyViewStatus::ErrorInvalidOffset:
82 case CesiumGltf::PropertyTexturePropertyViewStatus::ErrorInvalidScale:
83 case CesiumGltf::PropertyTexturePropertyViewStatus::ErrorInvalidMax:
84 case CesiumGltf::PropertyTexturePropertyViewStatus::ErrorInvalidMin:
85 case CesiumGltf::PropertyTexturePropertyViewStatus::ErrorInvalidNoDataValue:
86 case CesiumGltf::PropertyTexturePropertyViewStatus::
87 ErrorInvalidDefaultValue:
88 // The status was already set in the initializer list.
89 return;
90 default:
91 _status = ECesiumPropertyTexturePropertyStatus::ErrorInvalidPropertyData;
92 return;
93 }
94
95 _valueType = TypeToMetadataValueType<T>();
96 _normalized = Normalized;
97 }
98
99 const int64 getTexCoordSetIndex() const;
102 const std::optional<CesiumGltf::KhrTextureTransform>
104
105private:
107
108 std::any _property;
109
110 FCesiumMetadataValueType _valueType;
111 bool _normalized;
112
114};
115
116UCLASS()
118 : public UBlueprintFunctionLibrary {
119 GENERATED_BODY()
120
121public:
128 UFUNCTION(
129 BlueprintCallable,
130 BlueprintPure,
131 Category = "Cesium|Metadata|PropertyTextureProperty")
133 UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
134
142 UFUNCTION(
143 BlueprintCallable,
144 BlueprintPure,
145 Category = "Cesium|Metadata|PropertyTextureProperty")
148
156 UFUNCTION(
157 BlueprintCallable,
158 BlueprintPure,
159 Category = "Cesium|Metadata|PropertyTextureProperty")
161 UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
162
170 UFUNCTION(
171 BlueprintCallable,
172 BlueprintPure,
173 Category = "Cesium|Metadata|PropertyTextureProperty")
175 GetValueType(UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
176
183 UFUNCTION(
184 BlueprintCallable,
185 BlueprintPure,
186 Category = "Cesium|Metadata|PropertyTextureProperty")
187 static int64 GetArraySize(UPARAM(ref)
188 const FCesiumPropertyTextureProperty& Property);
189
199 UFUNCTION(
200 BlueprintCallable,
201 BlueprintPure,
202 Category = "Cesium|Metadata|PropertyTextureProperty")
204 UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
205
226 UFUNCTION(
227 BlueprintCallable,
228 BlueprintPure,
229 Category = "Cesium|Metadata|PropertyTextureProperty")
230 static int64 GetUnrealUVChannel(
231 const UPrimitiveComponent* Component,
232 UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
233
241 UFUNCTION(
242 BlueprintCallable,
243 BlueprintPure,
244 Category = "Cesium|Metadata|PropertyTextureProperty")
245 static TArray<int64>
246 GetChannels(UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
247
274 UFUNCTION(
275 BlueprintCallable,
276 BlueprintPure,
277 Category = "Cesium|Metadata|PropertyTextureProperty")
278 static uint8 GetByte(
279 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
280 const FVector2D& UV,
281 uint8 DefaultValue = 0);
282
310 UFUNCTION(
311 BlueprintCallable,
312 BlueprintPure,
313 Category = "Cesium|Metadata|PropertyTextureProperty")
314 static int32 GetInteger(
315 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
316 const FVector2D& UV,
317 int32 DefaultValue = 0);
318
348 UFUNCTION(
349 BlueprintCallable,
350 BlueprintPure,
351 Category = "Cesium|Metadata|PropertyTextureProperty")
352 static float GetFloat(
353 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
354 const FVector2D& UV,
355 float DefaultValue = 0.0f);
356
385 UFUNCTION(
386 BlueprintCallable,
387 BlueprintPure,
388 Category = "Cesium|Metadata|PropertyTextureProperty")
389 static double GetFloat64(
390 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
391 const FVector2D& UV,
392 double DefaultValue = 0.0);
393
429 UFUNCTION(
430 BlueprintCallable,
431 BlueprintPure,
432 Category = "Cesium|Metadata|PropertyTextureProperty")
433 static FIntPoint GetIntPoint(
434 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
435 const FVector2D& UV,
436 const FIntPoint& DefaultValue);
437
470 UFUNCTION(
471 BlueprintCallable,
472 BlueprintPure,
473 Category = "Cesium|Metadata|PropertyTextureProperty")
474 static FVector2D GetVector2D(
475 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
476 const FVector2D& UV,
477 const FVector2D& DefaultValue);
478
517 UFUNCTION(
518 BlueprintCallable,
519 BlueprintPure,
520 Category = "Cesium|Metadata|PropertyTextureProperty")
521 static FIntVector GetIntVector(
522 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
523 const FVector2D& UV,
524 const FIntVector& DefaultValue);
525
563 UFUNCTION(
564 BlueprintCallable,
565 BlueprintPure,
566 Category = "Cesium|Metadata|PropertyTextureProperty")
567 static FVector GetVector(
568 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
569 const FVector2D& UV,
570 const FVector& DefaultValue);
571
606 UFUNCTION(
607 BlueprintCallable,
608 BlueprintPure,
609 Category = "Cesium|Metadata|PropertyTextureProperty")
610 static FVector4 GetVector4(
611 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
612 const FVector2D& UV,
613 const FVector4& DefaultValue);
614
631 UFUNCTION(
632 BlueprintCallable,
633 BlueprintPure,
634 Category = "Cesium|Metadata|PropertyTextureProperty")
636 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
637 const FVector2D& UV);
638
654 UFUNCTION(
655 BlueprintCallable,
656 BlueprintPure,
657 Category = "Cesium|Metadata|PropertyTextureProperty")
659 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
660 const FVector2D& UV);
661
673 UFUNCTION(
674 BlueprintCallable,
675 BlueprintPure,
676 Category = "Cesium|Metadata|PropertyTextureProperty")
678 UPARAM(ref) const FCesiumPropertyTextureProperty& Property,
679 const FVector2D& UV);
680
688 UFUNCTION(
689 BlueprintCallable,
690 BlueprintPure,
691 Category = "Cesium|Metadata|PropertyTextureProperty")
692 static bool IsNormalized(UPARAM(ref)
693 const FCesiumPropertyTextureProperty& Property);
694
706 UFUNCTION(
707 BlueprintCallable,
708 BlueprintPure,
709 Category = "Cesium|Metadata|PropertyTextureProperty")
711 GetOffset(UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
712
724 UFUNCTION(
725 BlueprintCallable,
726 BlueprintPure,
727 Category = "Cesium|Metadata|PropertyTextureProperty")
729 GetScale(UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
730
744 UFUNCTION(
745 BlueprintCallable,
746 BlueprintPure,
747 Category = "Cesium|Metadata|PropertyTextureProperty")
750
764 UFUNCTION(
765 BlueprintCallable,
766 BlueprintPure,
767 Category = "Cesium|Metadata|PropertyTextureProperty")
770
783 UFUNCTION(
784 BlueprintCallable,
785 BlueprintPure,
786 Category = "Cesium|Metadata|PropertyTextureProperty")
788 GetNoDataValue(UPARAM(ref) const FCesiumPropertyTextureProperty& Property);
789
800 UFUNCTION(
801 BlueprintCallable,
802 BlueprintPure,
803 Category = "Cesium|Metadata|PropertyTextureProperty")
806
807 PRAGMA_DISABLE_DEPRECATION_WARNINGS
815 UFUNCTION(
816 BlueprintCallable,
817 BlueprintPure,
818 Meta =
819 (DeprecatedFunction,
820 DeprecationMessage =
821 "Swizzles are no longer hardcoded in Unreal materials. To see what channels the property uses, use GetChannels instead."))
822 static FString GetSwizzle(UPARAM(ref)
823 const FCesiumPropertyTextureProperty& Property);
824
832 UFUNCTION(
833 BlueprintCallable,
834 BlueprintPure,
835 Meta =
836 (DeprecatedFunction,
837 DeprecationMessage =
838 "Use GetChannels to get the channels array of a property texture property instead."))
839 static int64
841 PRAGMA_ENABLE_DEPRECATION_WARNINGS
842};
ECesiumMetadataBlueprintType
The Blueprint type that can losslessly represent values of a given property.
ECesiumPropertyTexturePropertyStatus
Reports the status of a FCesiumPropertyTextureProperty.
static int64 GetGltfTextureCoordinateSetIndex(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the glTF texture coordinate set index used by the property texture property.
static FVector2D GetVector2D(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, const FVector2D &DefaultValue)
Attempts to retrieve the value at the given texture coordinates as a FVector2D.
static ECesiumPropertyTexturePropertyStatus GetPropertyTexturePropertyStatus(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the status of the property texture property.
static uint8 GetByte(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, uint8 DefaultValue=0)
Attempts to retrieve the value at the given texture coordinates as an unsigned 8-bit integer.
static ECesiumMetadataBlueprintType GetBlueprintType(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the best-fitting type for the property that is accessible from Blueprints.
static float GetFloat(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, float DefaultValue=0.0f)
Attempts to retrieve the value at the given texture coordinates as a single-precision floating-point ...
static FCesiumMetadataValue GetMaximumValue(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the maximum value of this property.
static int64 GetComponentCount(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Get the component count of this property.
static int64 GetArraySize(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the number of elements in an array of this property.
static FVector4 GetVector4(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, const FVector4 &DefaultValue)
Attempts to retrieve the value at the given texture coordinates as a FVector4.
static FCesiumMetadataValue GetScale(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the scale of this property.
static FCesiumMetadataValue GetRawValue(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV)
Retrieves the raw value of the property for the given feature.
static FCesiumMetadataValue GetOffset(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the offset of this property.
static FCesiumPropertyArray GetArray(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV)
Attempts to retrieve the value for the given texture coordinates as a FCesiumPropertyArray.
static FCesiumMetadataValue GetMinimumValue(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the minimum value of this property.
static FIntVector GetIntVector(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, const FIntVector &DefaultValue)
Attempts to retrieve the value at the given texture coordinates as a FIntVector.
static int64 GetUnrealUVChannel(const UPrimitiveComponent *Component, UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the UV channel containing the texture coordinate set that is used by the property texture proper...
static int32 GetInteger(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, int32 DefaultValue=0)
Attempts to retrieve the value at the given texture coordinates as a signed 32-bit integer.
static FCesiumMetadataValue GetNoDataValue(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the "no data" value of this property, as defined by its class property.
static FCesiumMetadataValueType GetValueType(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the type of the metadata value as defined in the EXT_structural_metadata extension.
static FIntPoint GetIntPoint(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, const FIntPoint &DefaultValue)
Attempts to retrieve the value at the given texture coordinates as a FIntPoint.
static TArray< int64 > GetChannels(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Get the channels array of this property.
static FCesiumMetadataValue GetValue(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV)
Retrieves the value of the property for the given texture coordinates.
static PRAGMA_DISABLE_DEPRECATION_WARNINGS FString GetSwizzle(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Get the string representing how the metadata is encoded into a pixel color.
static bool IsNormalized(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Whether this property is normalized.
static ECesiumMetadataBlueprintType GetArrayElementBlueprintType(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the best-fitting Blueprints type for the elements in this property's array values.
static double GetFloat64(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, double DefaultValue=0.0)
Attempts to retrieve the value at the given texture coordinates as a double-precision floating-point ...
static FVector GetVector(UPARAM(ref) const FCesiumPropertyTextureProperty &Property, const FVector2D &UV, const FVector &DefaultValue)
Attempts to retrieve the value at the given texture coordinates as a FVector.
static FCesiumMetadataValue GetDefaultValue(UPARAM(ref) const FCesiumPropertyTextureProperty &Property)
Gets the default value of this property, as defined by its class property.
Represents the true value type of a metadata value, akin to the property types in EXT_structural_meta...
A Blueprint-accessible wrapper for a glTF metadata value.
A Blueprint-accessible wrapper for an array property in glTF metadata.
A blueprint-accessible wrapper for a property texture property from a glTF.
const CesiumGltf::ImageAsset * getImage() const
const int64 getTexCoordSetIndex() const
const CesiumGltf::Sampler * getSampler() const
const std::optional< CesiumGltf::KhrTextureTransform > getTextureTransform() const
FCesiumPropertyTextureProperty(const CesiumGltf::PropertyTexturePropertyView< T, Normalized > &Property)