Cesium for Unreal 2.24.1
Loading...
Searching...
No Matches
CesiumFeaturesMetadataComponent.h
Go to the documentation of this file.
1// Copyright 2020-2025 CesiumGS, Inc. and Contributors
2
3#pragma once
4
6#include "Components/ActorComponent.h"
7
8#if WITH_EDITOR
9#include "Materials/MaterialFunctionMaterialLayer.h"
10#endif
11
12#include "CesiumFeaturesMetadataComponent.generated.h"
13
14/**
15 * @brief A component that can be added to Cesium3DTileset actors to
16 * dictate what feature ID sets or metadata to encode for access on the GPU.
17 * "Add Properties" allows users to find and select desired feature ID sets and
18 * metadata properties. Once a selection is made, "Generate Material" can be
19 * used to auto-generated the boiler-plate code to access the selected
20 * properties in the Unreal material.
21 */
22UCLASS(ClassGroup = Cesium, Meta = (BlueprintSpawnableComponent))
23class CESIUMRUNTIME_API UCesiumFeaturesMetadataComponent
24 : public UActorComponent {
25 GENERATED_BODY()
26
27public:
28#if WITH_EDITOR
29 /**
30 * Opens a window to add feature ID sets and metadata properties from the
31 * current view of the tileset.
32 */
33 UFUNCTION(
34 CallInEditor,
35 Category = "Cesium",
36 Meta = (DisplayName = "Add Properties"))
37 void AddProperties();
38
39 /**
40 * This button can be used to create a boiler-plate material layer that
41 * exposes the requested metadata properties in the current description. The
42 * nodes to access the metadata will be added to TargetMaterialLayer if it
43 * exists. Otherwise a new material layer will be created in the /Content/
44 * folder and TargetMaterialLayer will be set to the new material layer.
45 */
46 UFUNCTION(
47 CallInEditor,
48 Category = "Cesium",
49 Meta = (DisplayName = "Generate Material"))
50 void GenerateMaterial();
51#endif
52
53#if WITH_EDITORONLY_DATA
54 /**
55 * This is the target UMaterialFunctionMaterialLayer that the
56 * boiler-plate material generation will use. When pressing
57 * "Generate Material", nodes will be added to this material to enable access
58 * to the requested metadata. If this is left blank, a new material layer
59 * will be created in the /Game/ folder.
60 */
61 UPROPERTY(EditAnywhere, Category = "Cesium")
62 UMaterialFunctionMaterialLayer* TargetMaterialLayer = nullptr;
63#endif
64
65 /**
66 * @brief Description of both feature IDs and metadata from a glTF via the
67 * EXT_mesh_features, EXT_instance_features, and EXT_structural_metadata
68 * extensions. Indicates what parts of the extension should be uploaded to the
69 * GPU for access in Unreal materials.
70 */
71 UPROPERTY(
72 EditAnywhere,
73 Category = "Cesium",
74 Meta =
75 (TitleProperty = "Name",
76 DisplayAfter = "TargetMaterialLayer",
77 ShowOnlyInnerProperties))
79
80 PRAGMA_DISABLE_DEPRECATION_WARNINGS
81 // Previously the properties of FCesiumFeaturesMetadataDescription were
82 // deconstructed here in order to flatten the Details panel UI. However, the
83 // ShowOnlyInnerProperties attribute accomplishes the same thing. These
84 // properties are deprecated but migrated over in PostLoad().
85
86 /**
87 * Description of the feature ID sets in the visible glTF primitives across
88 * the tileset.
89 */
90 UPROPERTY(
91 Meta =
92 (DeprecatedProperty,
93 DeprecationMessage =
94 "Use FeatureIdSets on the CesiumFeaturesMetadataDescription's Features instead."))
96
97 /**
98 * Names of the property textures used by the glTF primitives across the
99 * tileset.
100 *
101 * This should be a subset of the property textures listed in the model
102 * metadata. Property textures can be passed to the material even if they are
103 * not explicitly used by a glTF primitive, but the primitive may lack the
104 * corresponding sets of texture coordinates intended to sample them.
105 */
106 UPROPERTY(
107 Meta =
108 (DeprecatedProperty,
109 DeprecationMessage =
110 "Use PropertyTextureNames on the CesiumFeaturesMetadataDescription's PrimitiveMetadata instead."))
111 TSet<FString> PropertyTextureNames;
112
113 /**
114 * Descriptions of the property tables in the visible glTF
115 * models across the tileset.
116 */
117 UPROPERTY(
118 Meta =
119 (DeprecatedProperty,
120 DeprecationMessage =
121 "Use PropertyTables on the CesiumFeaturesMetadataDescription's ModelMetadata instead."))
123
124 /**
125 * Descriptions of property textures in the visible glTF models across
126 * the tileset.
127 */
128 UPROPERTY(
129 Meta =
130 (DeprecatedProperty,
131 DeprecationMessage =
132 "Use PropertyTextures on the CesiumFeaturesMetadataDescription's ModelMetadata instead."))
134 PRAGMA_ENABLE_DEPRECATION_WARNINGS
135
136 /**
137 * Syncs this component's statistics description from its tileset owner,
138 * retrieving values for the corresponding semantics.
139 *
140 * If there are described statistics that are not present on the tileset
141 * owner, they will be left as null values.
142 */
144
145 /**
146 * Whether a sync is already in progress.
147 */
148 bool IsSyncing() const;
149
150 /**
151 * Interrupts any sync happening on this component. Usually called before
152 * destroying or refreshing a tileset.
153 */
155
156 virtual void PostLoad() override;
157
158#if WITH_EDITOR
159 virtual void
160 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
161 virtual void PostEditChangeChainProperty(
162 FPropertyChangedChainEvent& PropertyChangedChainEvent) override;
163#endif
164
165protected:
166 // Called when a component is registered. This seems to be the best way to
167 // intercept when the component is pasted (to then update its statistics).
168 virtual void OnRegister() override;
169
170private:
171 void clearStatistics();
172
173 bool _syncInProgress;
174};
A component that can be added to Cesium3DTileset actors to dictate what feature ID sets or metadata t...
PRAGMA_ENABLE_DEPRECATION_WARNINGS void SyncStatistics()
Syncs this component's statistics description from its tileset owner, retrieving values for the corre...
bool IsSyncing() const
Whether a sync is already in progress.
virtual void OnRegister() override
TArray< FCesiumPropertyTextureDescription > PropertyTextures
Descriptions of property textures in the visible glTF models across the tileset.
virtual 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,...
void InterruptSync()
Interrupts any sync happening on this component.
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.
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.