Cesium for Unreal 2.19.1
Loading...
Searching...
No Matches
CesiumRasterOverlay.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
6#include "CesiumRasterOverlays/RasterOverlay.h"
7#include "CesiumUtility/IntrusivePointer.h"
8#include "Components/ActorComponent.h"
9#include "CoreMinimal.h"
10#include "Engine/Texture.h"
11#include "Engine/TextureDefines.h"
12#include <memory>
13#include "CesiumRasterOverlay.generated.h"
14
15namespace Cesium3DTilesSelection {
16class Tileset;
17}
18
19/**
20 * The delegate for OnCesiumRasterOverlayLoadFailure, which is triggered when
21 * the raster overlay encounters a load error.
22 */
24 FCesiumRasterOverlayLoadFailure,
26
27CESIUMRUNTIME_API extern FCesiumRasterOverlayLoadFailure
29
30/**
31 * This struct is passed through the raster overlay options and is used when
32 * `prepareRasterInLoadThread` is called.
33 */
34USTRUCT(BlueprintType)
36 GENERATED_BODY()
37
38 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
39 TEnumAsByte<TextureFilter> filter = TextureFilter::TF_Default;
40
41 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
42 TEnumAsByte<TextureGroup> group = TextureGroup::TEXTUREGROUP_World;
43
44 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
45 bool useMipmaps = true;
46};
47
48/**
49 * A quadtree pyramid of 2D raster images meant to be draped over a Cesium 3D
50 * Tileset. Raster overlays are commonly used for satellite imagery, street
51 * maps, and more.
52 */
53UCLASS(Abstract)
54class CESIUMRUNTIME_API UCesiumRasterOverlay : public UActorComponent {
55 GENERATED_BODY()
56
57public:
58 /**
59 * The key to use to match this overlay to a material layer.
60 *
61 * When using Material Layers, any material layers inside a "Cesium" layer
62 * stack with a name that matches this name will have their Texture,
63 * TranslationScale, and TextureCoordinateIndex properties set automatically
64 * so that a ML_CesiumOverlay layer function (or similar) will correctly
65 * sample from this overlay.
66 */
67 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
68 FString MaterialLayerKey = "Overlay0";
69
70 /**
71 * Sets the texture filter and texture group of raster tile images. Depending
72 * on the project settings, the default texture filter, TF_Default, should
73 * have the best quality.
74 */
75 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
77
78 // Sets default values for this component's properties
80
81 /**
82 * Displays this raster overlay on its owning Cesium 3D Tileset Actor, without
83 * changing its activation state. It is usually better to call Activate
84 * rather than this function, in order to ensure that the component is also
85 * activated. Otherwise, if the Cesium3DTileset is reloaded for any reason,
86 * this overlay will no longer be shown.
87 *
88 * If the overlay is already added or if this component's Owner is not a
89 * Cesium 3D Tileset, this method does nothing.
90 */
91 UFUNCTION(BlueprintCallable, Category = "Cesium")
93
94 /**
95 * Stops displaying this raster overlay on its owning Cesium 3D Tileset Actor.
96 * It is usually better to call Deactivate rather than this function, in order
97 * to ensure that the component is also deactivated. Otherwise, if the
98 * component remains active and the Cesium3DTileset is reloaded for any
99 * reason, this overlay will reappear.
100 *
101 * If the overlay is not yet added or if this component's Owner is not a
102 * Cesium 3D Tileset, this method does nothing.
103 */
104 UFUNCTION(BlueprintCallable, Category = "Cesium")
106
107 /**
108 * Refreshes this overlay by removing from its owning Cesium 3D Tileset Actor
109 * and re-adding it. If this component's Owner is not a Cesium 3D Tileset
110 * Actor, this method does nothing. If this component is not active, the
111 * overlay will be removed from the Cesium3DTileset if already present but not
112 * re-added.
113 */
114 UFUNCTION(BlueprintCallable, Category = "Cesium")
115 void Refresh();
116
117 UFUNCTION(BlueprintCallable, Category = "Cesium")
119
120 UFUNCTION(BlueprintCallable, Category = "Cesium")
121 void SetMaximumScreenSpaceError(double Value);
122
123 UFUNCTION(BlueprintCallable, Category = "Cesium")
125
126 UFUNCTION(BlueprintCallable, Category = "Cesium")
127 void SetMaximumTextureSize(int32 Value);
128
129 UFUNCTION(BlueprintCallable, Category = "Cesium")
131
132 UFUNCTION(BlueprintCallable, Category = "Cesium")
134
135 UFUNCTION(BlueprintCallable, Category = "Cesium")
136 int64 GetSubTileCacheBytes() const;
137
138 UFUNCTION(BlueprintCallable, Category = "Cesium")
139 void SetSubTileCacheBytes(int64 Value);
140
141 /**
142 * Activates this raster overlay, which will display it on the Cesium3DTileset
143 * to which the component is attached, if it isn't already displayed. The
144 * overlay will continue to be shown on the tileset until it is deactivated.
145 *
146 * If the overlay is already displayed on the Cesium3DTileset, calling this
147 * function will not cause it to pick up any new values for properties that
148 * have been modified since it was added. To do that, call Refresh.
149 *
150 * If you created this overlay component via Blueprints, consider setting the
151 * "Auto Activate" property to false on the "Add Component" node and calling
152 * Activate after setting all the desired properties. This will avoid the need
153 * to call Refresh, and will ensure the overlay is not loaded multiple times.
154 *
155 * @param bReset Whether the activation should happen even if ShouldActivate
156 * returns false.
157 */
158 virtual void Activate(bool bReset) override;
159
160 /**
161 * Deactivates this raster overlay. This will stop displaying it on the
162 * Cesium3DTileset to which the component is attached. The overlay will not be
163 * shown again until the component is re-activated.
164 */
165 virtual void Deactivate() override;
166
167 virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override;
168 virtual bool IsReadyForFinishDestroy() override;
169
170protected:
171 /**
172 * The maximum number of pixels of error when rendering this overlay.
173 * This is used to select an appropriate level-of-detail.
174 *
175 * When this property has its default value, 2.0, it means that raster overlay
176 * images will be sized so that, when zoomed in closest, a single pixel in
177 * the raster overlay maps to approximately 2x2 pixels on the screen.
178 */
179 UPROPERTY(
180 EditAnywhere,
181 BlueprintReadWrite,
182 BlueprintGetter = GetMaximumScreenSpaceError,
183 BlueprintSetter = SetMaximumScreenSpaceError,
184 Category = "Cesium")
186
187 /**
188 * The maximum texel size of raster overlay textures, in either
189 * direction.
190 *
191 * Images created by this overlay will be no more than this number of texels
192 * in either direction. This may result in reduced raster overlay detail in
193 * some cases.
194 */
195 UPROPERTY(
196 EditAnywhere,
197 BlueprintReadWrite,
198 BlueprintGetter = GetMaximumTextureSize,
199 BlueprintSetter = SetMaximumTextureSize,
200 Category = "Cesium")
201 int32 MaximumTextureSize = 2048;
202
203 /**
204 * The maximum number of overlay tiles that may simultaneously be in
205 * the process of loading.
206 */
207 UPROPERTY(
208 EditAnywhere,
209 BlueprintReadWrite,
210 BlueprintGetter = GetMaximumSimultaneousTileLoads,
211 BlueprintSetter = SetMaximumSimultaneousTileLoads,
212 Category = "Cesium")
214
215 /**
216 * The maximum number of bytes to use to cache sub-tiles in memory.
217 *
218 * This is used by provider types that have an underlying tiling scheme that
219 * may not align with the tiling scheme of the geometry tiles on which the
220 * raster overlay tiles are draped. Because a single sub-tile may overlap
221 * multiple geometry tiles, it is useful to cache loaded sub-tiles in memory
222 * in case they're needed again soon. This property controls the maximum size
223 * of that cache.
224 */
225 UPROPERTY(
226 EditAnywhere,
227 BlueprintReadWrite,
228 BlueprintGetter = GetSubTileCacheBytes,
229 BlueprintSetter = SetSubTileCacheBytes,
230 Category = "Cesium")
231 int64 SubTileCacheBytes = 16 * 1024 * 1024;
232
233 /**
234 * Whether or not to show credits of this raster overlay on screen.
235 */
236 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
238
239#if WITH_EDITOR
240 // Called when properties are changed in the editor
241 virtual void
242 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
243#endif
244
246
247 virtual std::unique_ptr<CesiumRasterOverlays::RasterOverlay>
249 PURE_VIRTUAL(UCesiumRasterOverlay::CreateOverlay, return nullptr;);
250
251 virtual void OnAdd(
257
258private:
260 _pOverlay;
261 int32 _overlaysBeingDestroyed;
262};
DECLARE_MULTICAST_DELEGATE_OneParam(FCesiumRasterOverlayLoadFailure, const FCesiumRasterOverlayLoadFailureDetails &)
The delegate for OnCesiumRasterOverlayLoadFailure, which is triggered when the raster overlay encount...
FCesiumRasterOverlayLoadFailure OnCesiumRasterOverlayLoadFailure
int32 MaximumSimultaneousTileLoads
The maximum number of overlay tiles that may simultaneously be in the process of loading.
double MaximumScreenSpaceError
The maximum number of pixels of error when rendering this overlay.
virtual void OnAdd(Cesium3DTilesSelection::Tileset *pTileset, CesiumRasterOverlays::RasterOverlay *pOverlay)
int32 MaximumTextureSize
The maximum texel size of raster overlay textures, in either direction.
virtual void Deactivate() override
Deactivates this raster overlay.
virtual void OnRemove(Cesium3DTilesSelection::Tileset *pTileset, CesiumRasterOverlays::RasterOverlay *pOverlay)
virtual std::unique_ptr< CesiumRasterOverlays::RasterOverlay > CreateOverlay(const CesiumRasterOverlays::RasterOverlayOptions &options={}) 0
FString MaterialLayerKey
The key to use to match this overlay to a material layer.
void RemoveFromTileset()
Stops displaying this raster overlay on its owning Cesium 3D Tileset Actor.
int64 GetSubTileCacheBytes() const
void SetSubTileCacheBytes(int64 Value)
int32 GetMaximumSimultaneousTileLoads() const
int64 SubTileCacheBytes
The maximum number of bytes to use to cache sub-tiles in memory.
virtual void Activate(bool bReset) override
Activates this raster overlay, which will display it on the Cesium3DTileset to which the component is...
Cesium3DTilesSelection::Tileset * FindTileset() const
FRasterOverlayRendererOptions rendererOptions
Sets the texture filter and texture group of raster tile images.
virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override
double GetMaximumScreenSpaceError() const
void SetMaximumScreenSpaceError(double Value)
void Refresh()
Refreshes this overlay by removing from its owning Cesium 3D Tileset Actor and re-adding it.
bool ShowCreditsOnScreen
Whether or not to show credits of this raster overlay on screen.
virtual bool IsReadyForFinishDestroy() override
void SetMaximumSimultaneousTileLoads(int32 Value)
int32 GetMaximumTextureSize() const
void SetMaximumTextureSize(int32 Value)
void AddToTileset()
Displays this raster overlay on its owning Cesium 3D Tileset Actor, without changing its activation s...
This struct is passed through the raster overlay options and is used when prepareRasterInLoadThread i...
TEnumAsByte< TextureGroup > group
TEnumAsByte< TextureFilter > filter