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