Cesium for Unreal 2.31.0
Loading...
Searching...
No Matches
CesiumFeaturesMetadataComponent.h
Go to the documentation of this file.
1// Copyright 2020-2026 CesiumGS, Inc. and Contributors
2
3#pragma once
4
8
9#if WITH_EDITOR
10#include "Materials/MaterialFunctionMaterialLayer.h"
11#endif
12
13#include "CesiumFeaturesMetadataComponent.generated.h"
14
15/**
16 * @brief A component that can be added to Cesium3DTileset actors to
17 * dictate what feature ID sets or metadata to encode for access on the GPU.
18 * "Add Properties" allows users to find and select desired feature ID sets and
19 * metadata properties. Once a selection is made, "Generate Material" can be
20 * used to auto-generated the boiler-plate code to access the selected
21 * properties in the Unreal material.
22 */
23UCLASS(ClassGroup = Cesium, Meta = (BlueprintSpawnableComponent))
24class CESIUMRUNTIME_API UCesiumFeaturesMetadataComponent
26 GENERATED_BODY()
27
28public:
29#if WITH_EDITOR
30 /**
31 * Opens a window to add feature ID sets and metadata properties from the
32 * current view of the tileset.
33 */
34 UFUNCTION(
35 CallInEditor,
36 Category = "Cesium",
37 Meta = (DisplayName = "Add Properties"))
38 void AddProperties();
39
40 /**
41 * Creates or overwrites a boiler-plate material layer that exposes the
42 * requested metadata properties in the current description. The nodes to
43 * access the metadata will be added to TargetMaterialLayer if it is already
44 * specified. Otherwise a new material layer will be created in the /Content/
45 * folder and TargetMaterialLayer will be set to the new material layer.
46 */
47 UFUNCTION(
48 CallInEditor,
49 Category = "Cesium",
50 Meta = (DisplayName = "Generate Material"))
51 void GenerateMaterial();
52#endif
53
54#if WITH_EDITORONLY_DATA
55 /**
56 * This is the target UMaterialFunctionMaterialLayer that the
57 * boiler-plate material generation will use. When pressing
58 * "Generate Material", nodes will be added to this material to enable access
59 * to the requested metadata. If this is left blank, a new material layer
60 * will be created in the /Content/ folder.
61 */
62 UPROPERTY(EditAnywhere, Category = "Cesium")
63 UMaterialFunctionMaterialLayer* TargetMaterialLayer = nullptr;
64#endif
65
66 /**
67 * The Blueprint class to instantiate for feature styling. This is used for
68 * any feature ID sets with StylingMode set to Blueprint.
69 */
70 UPROPERTY(
71 EditAnywhere,
72 BlueprintReadWrite,
73 Category = "Cesium",
74 meta =
75 (MustImplement =
76 "/Script/CesiumRuntime.Cesium3DTilesStylingProvider"))
77 TSubclassOf<UObject> BlueprintStyleClass;
78
79 /**
80 * Reapplies the Blueprint style specified in BlueprintStyleClass to the
81 * tileset. Use this function to pick up any changes to the Blueprint
82 * in-Editor as well as its instance at runtime.
83 */
84 UFUNCTION(
85 CallInEditor,
86 BlueprintCallable,
87 Category = "Cesium",
88 Meta = (DisplayName = "Refresh Style"))
90
91 /**
92 * Description of both feature IDs and metadata from a glTF via the
93 * EXT_mesh_features, EXT_instance_features, and EXT_structural_metadata
94 * extensions. Indicates what parts of the extension should be uploaded to the
95 * GPU for access in Unreal materials.
96 */
97 UPROPERTY(
98 EditAnywhere,
99 Category = "Cesium",
100 Meta =
101 (TitleProperty = "Name",
102 DisplayAfter = "TargetMaterialLayer",
103 ShowOnlyInnerProperties))
105
106 PRAGMA_DISABLE_DEPRECATION_WARNINGS
107 // Previously the properties of FCesiumFeaturesMetadataDescription were
108 // deconstructed here in order to flatten the Details panel UI. However, the
109 // ShowOnlyInnerProperties attribute accomplishes the same thing. These
110 // properties are deprecated but migrated over in PostLoad().
111
112 /**
113 * Description of the feature ID sets in the visible glTF primitives across
114 * the tileset.
115 */
116 UPROPERTY(
117 Meta =
118 (DeprecatedProperty,
119 DeprecationMessage =
120 "Use FeatureIdSets on the CesiumFeaturesMetadataDescription's Features instead."))
122
123 /**
124 * Names of the property textures used by the glTF primitives across the
125 * tileset.
126 *
127 * This should be a subset of the property textures listed in the model
128 * metadata. Property textures can be passed to the material even if they are
129 * not explicitly used by a glTF primitive, but the primitive may lack the
130 * corresponding sets of texture coordinates intended to sample them.
131 */
132 UPROPERTY(
133 Meta =
134 (DeprecatedProperty,
135 DeprecationMessage =
136 "Use PropertyTextureNames on the CesiumFeaturesMetadataDescription's PrimitiveMetadata instead."))
137 TSet<FString> PropertyTextureNames;
138
139 /**
140 * Descriptions of the property tables in the visible glTF
141 * models across the tileset.
142 */
143 UPROPERTY(
144 Meta =
145 (DeprecatedProperty,
146 DeprecationMessage =
147 "Use PropertyTables on the CesiumFeaturesMetadataDescription's ModelMetadata instead."))
149
150 /**
151 * Descriptions of property textures in the visible glTF models across
152 * the tileset.
153 */
154 UPROPERTY(
155 Meta =
156 (DeprecatedProperty,
157 DeprecationMessage =
158 "Use PropertyTextures on the CesiumFeaturesMetadataDescription's ModelMetadata instead."))
160 PRAGMA_ENABLE_DEPRECATION_WARNINGS
161
162 virtual void PostLoad() override;
163
164#if WITH_EDITOR
165 virtual void
166 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
167 virtual void PostEditChangeChainProperty(
168 FPropertyChangedChainEvent& PropertyChangedChainEvent) override;
169 virtual void PostEditUndo() override;
170#endif
171
172 /**
173 * Gets the instance of BlueprintStyleClass that has been created to style
174 * features in this tileset. If no BlueprintStyleClass was specified, this
175 * will be null.
176 *
177 * This function may be used to modify variables on the instance of the style
178 * at runtime.
179 */
180 UFUNCTION(BlueprintCallable, Category = "Cesium|Styling")
181 UObject* GetStyleInstance() const { return this->_pStyleInstance; }
182
183protected:
184 virtual void OnFetchMetadata(
185 ACesium3DTileset* pActor,
186 const Cesium3DTilesSelection::TilesetMetadata* pMetadata) override;
187 virtual void ClearStatistics() override;
188
189private:
190 void recreateStyleInstance();
191
192 UPROPERTY(Transient)
193 UObject* _pStyleInstance;
194};
A component that can be added to Cesium3DTileset actors to dictate what feature ID sets or metadata t...
TSubclassOf< UObject > BlueprintStyleClass
The Blueprint class to instantiate for feature styling.
TArray< FCesiumPropertyTextureDescription > PropertyTextures
Descriptions of property textures in the visible glTF models across the tileset.
virtual PRAGMA_ENABLE_DEPRECATION_WARNINGS void PostLoad() override
PRAGMA_DISABLE_DEPRECATION_WARNINGS TArray< FCesiumFeatureIdSetDescription > FeatureIdSets
Description of the feature ID sets in the visible glTF primitives across the tileset.
FCesiumFeaturesMetadataDescription Description
Description of both feature IDs and metadata from a glTF via the EXT_mesh_features,...
virtual void OnFetchMetadata(ACesium3DTileset *pActor, const Cesium3DTilesSelection::TilesetMetadata *pMetadata) override
Event that occurs once metadata is successfully synced from the tileset during SyncStatistics.
void RefreshStyle()
Reapplies the Blueprint style specified in BlueprintStyleClass to the tileset.
UObject * GetStyleInstance() const
Gets the instance of BlueprintStyleClass that has been created to style features in this tileset.
TArray< FCesiumPropertyTableDescription > PropertyTables
Descriptions of the property tables in the visible glTF models across the tileset.
TSet< FString > PropertyTextureNames
Names of the property textures used by the glTF primitives across the tileset.
virtual void ClearStatistics() override
Called during various parts of the sync process.
A base component interface for interacting with metadata in a Cesium3DTileset.
Description of a feature ID set from either EXT_mesh_features or EXT_instance_features.
Description of both feature IDs and metadata from a glTF via the EXT_mesh_features and EXT_structural...
Description of a property table containing properties to be encoded for access in Unreal materials.
Description of a property texture with properties that should be made accessible to Unreal materials.