Cesium for Unreal 2.24.1
Loading...
Searching...
No Matches
Cesium3DTileset.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "Cesium3DTilesSelection/Tileset.h"
6#include "Cesium3DTilesSelection/ViewState.h"
7#include "Cesium3DTilesSelection/ViewUpdateResult.h"
12#include "CesiumGeoreference.h"
13#include "CesiumIonServer.h"
17#include "CoreMinimal.h"
19#include "Engine/EngineTypes.h"
20#include "GameFramework/Actor.h"
21#include "Interfaces/IHttpRequest.h"
22#include "PrimitiveSceneProxy.h"
23#include <PhysicsEngine/BodyInstance.h>
24#include <atomic>
25#include <chrono>
26#include <glm/mat4x4.hpp>
27#include <unordered_map>
28#include <vector>
29
30#ifdef CESIUM_DEBUG_TILE_STATES
31#include <Cesium3DTilesSelection/DebugTileStateDatabase.h>
32#endif
33
34#include "Cesium3DTileset.generated.h"
35
36class UMaterialInterface;
37class ACesiumCartographicSelection;
39class UCesiumBoundingVolumePoolComponent;
41class UCesiumVoxelRendererComponent;
42class CesiumViewExtension;
43struct FCesiumCamera;
45
46namespace Cesium3DTiles {
48}
49
50namespace Cesium3DTilesSelection {
51class GltfModifier;
52class Tileset;
53class TilesetView;
55} // namespace Cesium3DTilesSelection
56
57/**
58 * The delegate for OnCesium3DTilesetLoadFailure, which is triggered when
59 * the tileset encounters a load error.
60 */
62 FCesium3DTilesetLoadFailure,
64
66 FCesiumSampleHeightMostDetailedCallback,
68 const TArray<FCesiumSampleHeightResult>&,
69 const TArray<FString>&);
70
71/**
72 * The delegate for the Acesium3DTileset::OnTilesetLoaded,
73 * which is triggered from UpdateLoadStatus
74 */
76
77CESIUMRUNTIME_API extern FCesium3DTilesetLoadFailure
79
80UENUM(BlueprintType)
81enum class ETilesetSource : uint8 {
82 /**
83 * The tileset will be loaded from Cesium Ion using the provided IonAssetID
84 * and IonAccessToken.
85 */
86 FromCesiumIon UMETA(DisplayName = "From Cesium Ion"),
87
88 /**
89 * The tileset will be loaded from the specified Url.
90 */
91 FromUrl UMETA(DisplayName = "From Url"),
92
93 /**
94 * The tileset will be loaded from the georeference ellipsoid.
95 */
96 FromEllipsoid UMETA(DisplayName = "From Ellipsoid")
97};
98
99UENUM(BlueprintType)
100enum class EApplyDpiScaling : uint8 { Yes, No, UseProjectDefault };
101
102UCLASS()
103class CESIUMRUNTIME_API ACesium3DTileset : public AActor {
104 GENERATED_BODY()
105
106public:
109
110private:
111 UPROPERTY(VisibleAnywhere, Category = "Cesium") USceneComponent* Root;
112
113 UPROPERTY(
114 Meta =
115 (AllowPrivateAccess,
116 DeprecatedProperty,
117 DeprecationMessage =
118 "Use the Mobility property on the RootComponent instead."))
119 TEnumAsByte<EComponentMobility::Type> Mobility_DEPRECATED =
120 EComponentMobility::Static;
121
122public:
123 UFUNCTION(BlueprintCallable, meta = (DeprecatedFunction))
124 EComponentMobility::Type GetMobility() const {
125 return this->RootComponent->Mobility;
126 }
127 UFUNCTION(BlueprintCallable, meta = (DeprecatedFunction))
128 void SetMobility(EComponentMobility::Type NewMobility);
129
130 /**
131 * @brief Initiates an asynchronous query for the height of this tileset at a
132 * list of cartographic positions, where the Longitude (X) and Latitude (Y)
133 * are given in degrees. The most detailed available tiles are used to
134 * determine each height.
135 *
136 * The height of the input positions is ignored, unless height sampling fails
137 * at that location. The output height is expressed in meters above the
138 * ellipsoid (usually WGS84), which should not be confused with a height above
139 * mean sea level.
140 *
141 * @param LongitudeLatitudeHeightArray The cartographic positions for which to
142 * sample heights. The Longitude (X) and Latitude (Y) are expressed in
143 * degrees, while Height (Z) is given in meters.
144 * @param OnHeightsSampled A callback that is invoked in the game thread when
145 * heights have been sampled for all positions.
146 */
148 const TArray<FVector>& LongitudeLatitudeHeightArray,
149 FCesiumSampleHeightMostDetailedCallback OnHeightsSampled);
150
151private:
152 /**
153 * The designated georeference actor controlling how the actor's
154 * coordinate system relates to the coordinate system in this Unreal Engine
155 * level.
156 *
157 * If this is null, the Tileset will find and use the first Georeference
158 * Actor in the level, or create one if necessary. To get the active/effective
159 * Georeference from Blueprints or C++, use ResolvedGeoreference instead.
160 */
161 UPROPERTY(
162 EditAnywhere,
163 BlueprintReadWrite,
164 BlueprintGetter = GetGeoreference,
165 BlueprintSetter = SetGeoreference,
166 Category = "Cesium",
167 Meta = (AllowPrivateAccess))
168 TSoftObjectPtr<ACesiumGeoreference> Georeference;
169
170 /**
171 * The resolved georeference used by this Tileset. This is not serialized
172 * because it may point to a Georeference in the PersistentLevel while this
173 * tileset is in a sublevel. If the Georeference property is specified,
174 * however then this property will have the same value.
175 *
176 * This property will be null before ResolveGeoreference is called.
177 */
178 UPROPERTY(
179 Transient,
180 VisibleAnywhere,
181 BlueprintReadOnly,
182 Category = "Cesium",
183 Meta = (AllowPrivateAccess))
184 ACesiumGeoreference* ResolvedGeoreference = nullptr;
185
186public:
187 /** @copydoc ACesium3DTileset::Georeference */
188 UFUNCTION(BlueprintCallable, Category = "Cesium")
189 TSoftObjectPtr<ACesiumGeoreference> GetGeoreference() const;
190
191 /** @copydoc ACesium3DTileset::Georeference */
192 UFUNCTION(BlueprintCallable, Category = "Cesium")
193 void SetGeoreference(TSoftObjectPtr<ACesiumGeoreference> NewGeoreference);
194
195 /**
196 * Resolves the Cesium Georeference to use with this Actor. Returns
197 * the value of the Georeference property if it is set. Otherwise, finds a
198 * Georeference in the World and returns it, creating it if necessary. The
199 * resolved Georeference is cached so subsequent calls to this function will
200 * return the same instance.
201 */
202 UFUNCTION(BlueprintCallable, Category = "Cesium")
204
205 /**
206 * Invalidates the cached resolved georeference, unsubscribing from it and
207 * setting it to null. The next time ResolveGeoreference is called, the
208 * Georeference will be re-resolved and re-subscribed.
209 */
210 UFUNCTION(BlueprintCallable, Category = "Cesium")
212
213private:
214 /**
215 * The actor managing this tileset's content attributions.
216 *
217 * If this is null, the Tileset will find and use the first Credit System
218 * Actor in the level, or create one if necessary. To get the active/effective
219 * Credit System from Blueprints or C++, use ResolvedCreditSystem instead.
220 */
221 UPROPERTY(
222 EditAnywhere,
223 BlueprintReadWrite,
224 BlueprintGetter = GetCreditSystem,
225 BlueprintSetter = SetCreditSystem,
226 Category = "Cesium",
227 Meta = (AllowPrivateAccess))
228 TSoftObjectPtr<ACesiumCreditSystem> CreditSystem;
229
230 /**
231 * The resolved Credit System used by this Tileset. This is not serialized
232 * because it may point to a Credit System in the PersistentLevel while this
233 * tileset is in a sublevel. If the CreditSystem property is specified,
234 * however then this property will have the same value.
235 *
236 * This property will be null before ResolveCreditSystem is called.
237 */
238 UPROPERTY(
239 Transient,
240 BlueprintReadOnly,
241 Category = "Cesium",
242 Meta = (AllowPrivateAccess))
243 ACesiumCreditSystem* ResolvedCreditSystem = nullptr;
244
245 /**
246 * The actor providing custom cameras for use with this Tileset.
247 *
248 * If this is null, the Tileset will find and use the first
249 * CesiumCameraManager Actor in the level, or create one if necessary. To get
250 * the active/effective Camera Manager from Blueprints or C++, use
251 * ResolvedCameraManager instead.
252 */
253 UPROPERTY(
254 EditAnywhere,
255 BlueprintReadWrite,
256 BlueprintGetter = GetCameraManager,
257 BlueprintSetter = SetCameraManager,
258 Category = "Cesium",
259 Meta = (AllowPrivateAccess))
260 TSoftObjectPtr<ACesiumCameraManager> CameraManager;
261
262 /**
263 * The resolved Camera Manager used by this Tileset. This is not serialized
264 * because it may point to a Camera Manager in the PersistentLevel while this
265 * tileset is in a sublevel. If the CameraManager property is specified,
266 * however then this property will have the same value.
267 *
268 * This property will be null before ResolveCameraManager is called.
269 */
270 UPROPERTY(
271 Transient,
272 BlueprintReadOnly,
273 Category = "Cesium",
274 Meta = (AllowPrivateAccess))
275 ACesiumCameraManager* ResolvedCameraManager = nullptr;
276
277 /**
278 * The bounding volume pool component that manages occlusion bounding volume
279 * proxies.
280 */
281 UPROPERTY(
282 Transient,
283 BlueprintReadOnly,
284 Category = "Cesium",
285 Meta = (AllowPrivateAccess))
286 UCesiumBoundingVolumePoolComponent* BoundingVolumePoolComponent = nullptr;
287
288 /**
289 * The custom view extension this tileset uses to pull renderer view
290 * information.
291 */
292 TSharedPtr<CesiumViewExtension, ESPMode::ThreadSafe> _cesiumViewExtension =
293 nullptr;
294
295public:
296 /** @copydoc ACesium3DTileset::CreditSystem */
297 UFUNCTION(BlueprintCallable, Category = "Cesium")
298 TSoftObjectPtr<ACesiumCreditSystem> GetCreditSystem() const;
299
300 /** @copydoc ACesium3DTileset::CreditSystem */
301 UFUNCTION(BlueprintCallable, Category = "Cesium")
302 void SetCreditSystem(TSoftObjectPtr<ACesiumCreditSystem> NewCreditSystem);
303
304 /**
305 * Resolves the Cesium Credit System to use with this Actor. Returns
306 * the value of the CreditSystem property if it is set. Otherwise, finds a
307 * Credit System in the World and returns it, creating it if necessary. The
308 * resolved Credit System is cached so subsequent calls to this function will
309 * return the same instance.
310 */
311 UFUNCTION(BlueprintCallable, Category = "Cesium")
313
314 /**
315 * Invalidates the cached resolved Credit System, setting it to null. The next
316 * time ResolveCreditSystem is called, the Credit System will be re-resolved.
317 */
318 UFUNCTION(BlueprintCallable, Category = "Cesium")
320
321 /**
322 * Whether or not to show this tileset's credits on screen.
323 */
324 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
326
327 /** @copydoc ACesium3DTileset::CameraManager */
328 UFUNCTION(BlueprintGetter, Category = "Cesium")
329 TSoftObjectPtr<ACesiumCameraManager> GetCameraManager() const;
330
331 /** @copydoc ACesium3DTileset::CameraManager */
332 UFUNCTION(BlueprintSetter, Category = "Cesium")
333 void SetCameraManager(TSoftObjectPtr<ACesiumCameraManager> NewCameraManager);
334
335 /**
336 * Resolves the Cesium Camera Manager to use with this Actor. Returns
337 * the value of the CameraManager property if it is set. Otherwise, finds a
338 * Camera Manager in the World and returns it, creating it if necessary. The
339 * resolved Camera Manager is cached so subsequent calls to this function will
340 * return the same instance.
341 */
342 UFUNCTION(BlueprintCallable, Category = "Cesium")
344
345 /**
346 * Invalidates the cached resolved Camera Manager, setting it to null. The
347 * next time ResolveCameraManager is called, the Camera Manager will be
348 * re-resolved.
349 */
350 UFUNCTION(BlueprintCallable, Category = "Cesium")
352
353 /**
354 * The maximum number of pixels of error when rendering this tileset.
355 *
356 * This is used to select an appropriate level-of-detail: A low value
357 * will cause many tiles with a high level of detail to be loaded,
358 * causing a finer visual representation of the tiles, but with a
359 * higher performance cost for loading and rendering. A higher value will
360 * cause a coarser visual representation, with lower performance
361 * requirements.
362 *
363 * When a tileset uses the older layer.json / quantized-mesh format rather
364 * than 3D Tiles, this value is effectively divided by 8.0. So the default
365 * value of 16.0 corresponds to the standard value for quantized-mesh terrain
366 * of 2.0.
367 */
368 UPROPERTY(
369 EditAnywhere,
370 BlueprintGetter = GetMaximumScreenSpaceError,
371 BlueprintSetter = SetMaximumScreenSpaceError,
372 Category = "Cesium|Level of Detail",
373 meta = (ClampMin = 0.0))
375
376 /**
377 * Scale Level-of-Detail by Display DPI. This increases the performance for
378 * mobile devices and high DPI screens.
379 */
380 UPROPERTY(
381 EditAnywhere,
382 BlueprintReadWrite,
383 Category = "Cesium|Level of Detail")
385
386 /**
387 * Whether to preload ancestor tiles.
388 *
389 * Setting this to true optimizes the zoom-out experience and provides more
390 * detail in newly-exposed areas when panning. The down side is that it
391 * requires loading more tiles.
392 */
393 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Loading")
394 bool PreloadAncestors = true;
395
396 /**
397 * Whether to preload sibling tiles.
398 *
399 * Setting this to true causes tiles with the same parent as a rendered tile
400 * to be loaded, even if they are culled. Setting this to true may provide a
401 * better panning experience at the cost of loading more tiles.
402 */
403 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Loading")
404 bool PreloadSiblings = true;
405
406 /**
407 * Whether to unrefine back to a parent tile when a child isn't done loading.
408 *
409 * When this is set to true, the tileset will guarantee that the tileset will
410 * never be rendered with holes in place of tiles that are not yet loaded,
411 * even though the tile that is rendered instead may have low resolution. When
412 * false, overall loading will be faster, but newly-visible parts of the
413 * tileset may initially be blank.
414 */
415 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Loading")
416 bool ForbidHoles = false;
417
418 /**
419 * The maximum number of tiles that may be loaded at once.
420 *
421 * When new parts of the tileset become visible, the tasks to load the
422 * corresponding tiles are put into a queue. This value determines how
423 * many of these tasks are processed at the same time. A higher value
424 * may cause the tiles to be loaded and rendered more quickly, at the
425 * cost of a higher network- and processing load.
426 */
427 UPROPERTY(
428 EditAnywhere,
429 BlueprintReadWrite,
430 Category = "Cesium|Tile Loading",
431 meta = (ClampMin = 0))
433
434 /**
435 * @brief The maximum number of bytes that may be cached.
436 *
437 * Note that this value, even if 0, will never
438 * cause tiles that are needed for rendering to be unloaded. However, if the
439 * total number of loaded bytes is greater than this value, tiles will be
440 * unloaded until the total is under this number or until only required tiles
441 * remain, whichever comes first.
442 */
443 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Loading")
444 int64 MaximumCachedBytes = 256 * 1024 * 1024;
445
446 /**
447 * The number of loading descendents a tile should allow before deciding to
448 * render itself instead of waiting.
449 *
450 * Setting this to 0 will cause each level of detail to be loaded
451 * successively. This will increase the overall loading time, but cause
452 * additional detail to appear more gradually. Setting this to a high value
453 * like 1000 will decrease the overall time until the desired level of detail
454 * is achieved, but this high-detail representation will appear at once, as
455 * soon as it is loaded completely.
456 */
457 UPROPERTY(
458 EditAnywhere,
459 BlueprintReadWrite,
460 Category = "Cesium|Tile Loading",
461 meta = (ClampMin = 0))
463
464 /**
465 * Whether to cull tiles that are outside the frustum.
466 *
467 * By default this is true, meaning that tiles that are not visible with the
468 * current camera configuration will be ignored. It can be set to false, so
469 * that these tiles are still considered for loading, refinement and
470 * rendering.
471 *
472 * This will cause more tiles to be loaded, but helps to avoid holes and
473 * provides a more consistent mesh, which may be helpful for physics.
474 *
475 * Note that this will always be disabled if UseLodTransitions is set to true.
476 */
477 UPROPERTY(
478 EditAnywhere,
479 BlueprintReadWrite,
480 Category = "Cesium|Tile Culling",
481 Meta = (EditCondition = "!UseLodTransitions", EditConditionHides))
483
484 /**
485 * Whether to cull tiles that are occluded by fog.
486 *
487 * This does not refer to the atmospheric fog of the Unreal Engine,
488 * but to an internal representation of fog: Depending on the height
489 * of the camera above the ground, tiles that are far away (close to
490 * the horizon) will be culled when this flag is enabled.
491 *
492 * Note that this will always be disabled if UseLodTransitions is set to true.
493 */
494 UPROPERTY(
495 EditAnywhere,
496 BlueprintReadWrite,
497 Category = "Cesium|Tile Culling",
498 Meta = (EditCondition = "!UseLodTransitions", EditConditionHides))
499 bool EnableFogCulling = true;
500
501 /**
502 * Whether a specified screen-space error should be enforced for tiles that
503 * are outside the frustum or hidden in fog.
504 *
505 * When "Enable Frustum Culling" and "Enable Fog Culling" are both true, tiles
506 * outside the view frustum or hidden in fog are effectively ignored, and so
507 * their level-of-detail doesn't matter. And in this scenario, this property
508 * is ignored.
509 *
510 * However, when either of those flags are false, these "would-be-culled"
511 * tiles continue to be processed, and the question arises of how to handle
512 * their level-of-detail. When this property is false, refinement terminates
513 * at these tiles, no matter what their current screen-space error. The tiles
514 * are available for physics, shadows, etc., but their level-of-detail may
515 * be very low.
516 *
517 * When set to true, these tiles are refined until they achieve the specified
518 * "Culled Screen Space Error". This allows control over the minimum quality
519 * of these would-be-culled tiles.
520 */
521 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Culling")
523
524 /**
525 * The screen-space error to be enforced for tiles that are outside the view
526 * frustum or hidden in fog.
527 *
528 * When "Enable Frustum Culling" and "Enable Fog Culling" are both true, tiles
529 * outside the view frustum or hidden in fog are effectively ignored, and so
530 * their level-of-detail doesn't matter. And in this scenario, this property
531 * is ignored.
532 *
533 * However, when either of those flags are false, these "would-be-culled"
534 * tiles continue to be processed, and the question arises of how to handle
535 * their level-of-detail. When "Enforce Culled Screen Space Error" is false,
536 * this property is ignored and refinement terminates at these tiles, no
537 * matter what their current screen-space error. The tiles are available for
538 * physics, shadows, etc., but their level-of-detail may be very low.
539 *
540 * When set to true, these tiles are refined until they achieve the
541 * screen-space error specified by this property.
542 */
543 UPROPERTY(
544 EditAnywhere,
545 BlueprintReadWrite,
546 Category = "Cesium|Tile Culling",
547 meta = (EditCondition = "EnforceCulledScreenSpaceError", ClampMin = 0.0))
549
550 // This mirrors
551 // UCesiumRuntimeSettings::EnableExperimentalOcclusionCullingFeature so that
552 // it can be used as an EditCondition.
553 UPROPERTY(Transient, VisibleDefaultsOnly, Category = "Cesium|Tile Occlusion")
555
556 /**
557 * Whether to cull tiles that are occluded.
558 *
559 * If this option is disabled, check that "Enable Experimental Occlusion
560 * Culling Feature" is enabled in the Plugins -> Cesium section of the Project
561 * Settings.
562 *
563 * When enabled, this feature will use Unreal's occlusion system to determine
564 * if tiles are actually visible on the screen. For tiles found to be
565 * occluded, the tile will not refine to show descendants, but it will still
566 * be rendered to avoid holes. This results in less tile loads and less GPU
567 * resource usage for dense, high-occlusion scenes like ground-level views in
568 * cities.
569 *
570 * This will not work for tilesets with poorly fit bounding volumes and cause
571 * more draw calls with very few extra culled tiles. When there is minimal
572 * occlusion in a scene, such as with terrain tilesets and applications
573 * focused on top-down views, this feature will yield minimal benefit and
574 * potentially cause needless overhead.
575 */
576 UPROPERTY(
577 EditAnywhere,
578 BlueprintGetter = GetEnableOcclusionCulling,
579 BlueprintSetter = SetEnableOcclusionCulling,
580 Category = "Cesium|Tile Occlusion",
581 meta = (EditCondition = "CanEnableOcclusionCulling"))
583
584 /**
585 * The number of CesiumBoundingVolumeComponents to use for querying the
586 * occlusion state of traversed tiles.
587 *
588 * Only applicable when EnableOcclusionCulling is enabled.
589 */
590 UPROPERTY(
591 EditAnywhere,
592 BlueprintGetter = GetOcclusionPoolSize,
593 BlueprintSetter = SetOcclusionPoolSize,
594 Category = "Cesium|Tile Occlusion",
595 meta =
596 (EditCondition =
597 "EnableOcclusionCulling && CanEnableOcclusionCulling",
598 ClampMin = "0",
599 ClampMax = "1000"))
600 int32 OcclusionPoolSize = 500;
601
602 /**
603 * Whether to wait for valid occlusion results before refining tiles.
604 *
605 * Only applicable when EnableOcclusionCulling is enabled. When this option
606 * is enabled, there may be small delays before tiles are refined, but there
607 * may be an overall performance advantage by avoiding loads of descendants
608 * that will be found to be occluded.
609 */
610 UPROPERTY(
611 EditAnywhere,
612 BlueprintGetter = GetDelayRefinementForOcclusion,
613 BlueprintSetter = SetDelayRefinementForOcclusion,
614 Category = "Cesium|Tile Occlusion",
615 meta =
616 (EditCondition =
617 "EnableOcclusionCulling && CanEnableOcclusionCulling"))
619
620 /**
621 * Refreshes this tileset, ensuring that all materials and other settings are
622 * applied. It is not usually necessary to invoke this, but when
623 * behind-the-scenes changes are made and not reflected in the tileset, this
624 * function can help.
625 */
626 UFUNCTION(CallInEditor, BlueprintCallable, Category = "Cesium")
628
629 /**
630 * Pauses level-of-detail and culling updates of this tileset.
631 */
632 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Debug")
634
635 /**
636 * If true, this tileset is ticked/updated in the editor. If false, is only
637 * ticked while playing (including Play-in-Editor).
638 */
639 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
640 bool UpdateInEditor = true;
641
642 /**
643 * If true, stats about tile selection are printed to the Output Log.
644 */
645 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
646 bool LogSelectionStats = false;
647
648 /**
649 * If true, logs stats on the assets in this tileset's shared asset system to
650 * the Output Log.
651 */
652 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
654
655 /**
656 * If true, draws debug text above each tile being rendered with information
657 * about that tile.
658 */
659 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
660 bool DrawTileInfo = false;
661
662 /**
663 * Define the collision profile for all the 3D tiles created inside this
664 * actor.
665 */
666 UPROPERTY(
667 EditAnywhere,
668 BlueprintReadOnly,
669 Category = "Collision",
670 meta = (ShowOnlyInnerProperties, SkipUCSModifiedProperties))
671 FBodyInstance BodyInstance;
672
673 /**
674 * A delegate that will be called whenever the tileset is fully loaded.
675 */
676 UPROPERTY(BlueprintAssignable, Category = "Cesium");
677 FCompletedLoadTrigger OnTilesetLoaded;
678
679 /**
680 * Use a dithering effect when transitioning between tiles of different LODs.
681 *
682 * When this is set to true, Frustrum Culling and Fog Culling are always
683 * disabled.
684 */
685 UPROPERTY(
686 EditAnywhere,
687 BlueprintGetter = GetUseLodTransitions,
688 BlueprintSetter = SetUseLodTransitions,
689 Category = "Cesium|Rendering")
690 bool UseLodTransitions = false;
691
692 /**
693 * How long dithered LOD transitions between different tiles should take, in
694 * seconds.
695 *
696 * Only relevant if UseLodTransitions is true.
697 */
698 UPROPERTY(
699 EditAnywhere,
700 BlueprintReadWrite,
701 Category = "Cesium|Rendering",
702 meta = (EditCondition = "UseLodTransitions", EditConditionHides))
704
705private:
706 UPROPERTY(BlueprintGetter = GetLoadProgress, Category = "Cesium")
707 float LoadProgress = 0.0f;
708
709 /**
710 * The type of source from which to load this tileset.
711 */
712 UPROPERTY(
713 EditAnywhere,
714 BlueprintGetter = GetTilesetSource,
715 BlueprintSetter = SetTilesetSource,
716 Category = "Cesium",
717 meta = (DisplayName = "Source"))
719
720 /**
721 * The URL of this tileset's "tileset.json" file.
722 *
723 * If this property is specified, the ion asset ID and token are ignored.
724 */
725 UPROPERTY(
726 EditAnywhere,
727 BlueprintGetter = GetUrl,
728 BlueprintSetter = SetUrl,
729 Category = "Cesium",
730 meta = (EditCondition = "TilesetSource==ETilesetSource::FromUrl"))
731 FString Url = "";
732
733 /**
734 * The ID of the Cesium ion asset to use.
735 *
736 * This property is ignored if the Url is specified.
737 */
738 UPROPERTY(
739 EditAnywhere,
740 BlueprintGetter = GetIonAssetID,
741 BlueprintSetter = SetIonAssetID,
742 Category = "Cesium",
743 meta =
744 (EditCondition = "TilesetSource==ETilesetSource::FromCesiumIon",
745 ClampMin = 0))
746 int64 IonAssetID;
747
748 /**
749 * The access token to use to access the Cesium ion resource.
750 */
751 UPROPERTY(
752 EditAnywhere,
753 BlueprintGetter = GetIonAccessToken,
754 BlueprintSetter = SetIonAccessToken,
755 Category = "Cesium",
756 meta = (EditCondition = "TilesetSource==ETilesetSource::FromCesiumIon"))
757 FString IonAccessToken;
758
759 UPROPERTY(
760 meta =
761 (DeprecatedProperty,
762 DeprecationMessage = "Use CesiumIonServer instead."))
763 FString IonAssetEndpointUrl_DEPRECATED;
764
765 /**
766 * The Cesium ion Server from which this tileset is loaded.
767 */
768 UPROPERTY(
769 EditAnywhere,
770 BlueprintGetter = GetCesiumIonServer,
771 BlueprintSetter = SetCesiumIonServer,
772 Category = "Cesium",
773 AdvancedDisplay,
774 meta = (EditCondition = "TilesetSource==ETilesetSource::FromCesiumIon"))
775 UCesiumIonServer* CesiumIonServer;
776
777 /**
778 * Headers to be attached to each request made for this tileset.
779 */
780 UPROPERTY(
781 EditAnywhere,
782 BlueprintGetter = GetRequestHeaders,
783 BlueprintSetter = SetRequestHeaders,
784 Category = "Cesium")
785 TMap<FString, FString> RequestHeaders;
786
787 /**
788 * Check if the Cesium ion token used to access this tileset is working
789 * correctly, and fix it if necessary.
790 */
791 UFUNCTION(CallInEditor, Category = "Cesium")
792 void TroubleshootToken();
793
794 /**
795 * Whether to generate physics meshes for this tileset.
796 *
797 * Disabling this option will improve the performance of tile loading, but it
798 * will no longer be possible to collide with the tileset since the physics
799 * meshes will not be created.
800 *
801 * Physics meshes cannot be generated for primitives containing points.
802 */
803 UPROPERTY(
804 EditAnywhere,
805 BlueprintGetter = GetCreatePhysicsMeshes,
806 BlueprintSetter = SetCreatePhysicsMeshes,
807 Category = "Cesium|Physics")
808 bool CreatePhysicsMeshes = true;
809
810 /**
811 * Whether to enable doubled-sided collisions (both front-facing and
812 * back-facing) on created physics meshes.
813 *
814 * Only relevant when CreatePhysicsMeshes is true.
815 */
816 UPROPERTY(
817 EditAnywhere,
818 BlueprintGetter = GetEnableDoubleSidedCollisions,
819 BlueprintSetter = SetEnableDoubleSidedCollisions,
820 Category = "Cesium|Physics",
821 meta = (EditCondition = "CreatePhysicsMeshes"))
822 bool EnableDoubleSidedCollisions = false;
823
824 /**
825 * Whether to generate navigation collisions for this tileset.
826 *
827 * Enabling this option creates collisions for navigation when a 3D Tiles
828 * tileset is loaded. It is recommended to set "Runtime Generation" to
829 * "Static" in the navigation mesh settings in the project settings, as
830 * collision calculations become very slow.
831 */
832 UPROPERTY(
833 EditAnywhere,
834 BlueprintGetter = GetCreateNavCollision,
835 BlueprintSetter = SetCreateNavCollision,
836 Category = "Cesium|Navigation")
837 bool CreateNavCollision = false;
838
839 /**
840 * Whether to always generate a correct tangent space basis for tiles that
841 * don't have them.
842 *
843 * Normally, a per-vertex tangent space basis is only required for glTF models
844 * with a normal map. However, a custom, user-supplied material may need a
845 * tangent space basis for other purposes. When this property is set to true,
846 * tiles lacking an explicit tangent vector will have one computed
847 * automatically using the MikkTSpace algorithm. When this property is false,
848 * load time will be improved by skipping the generation of the tangent
849 * vector, but the tangent space basis will be unreliable.
850 *
851 * Note that a tileset with "Enable Water Mask" set will include tangents
852 * for tiles containing water, regardless of the value of this property.
853 */
854 UPROPERTY(
855 EditAnywhere,
856 BlueprintGetter = GetAlwaysIncludeTangents,
857 BlueprintSetter = SetAlwaysIncludeTangents,
858 Category = "Cesium|Rendering")
859 bool AlwaysIncludeTangents = false;
860
861 /**
862 * Whether to generate smooth normals when normals are missing in the glTF.
863 *
864 * According to the Gltf spec: "When normals are not specified, client
865 * implementations should calculate flat normals." However, calculating flat
866 * normals requires duplicating vertices. This option allows the gltfs to be
867 * sent with explicit smooth normals when the original gltf was missing
868 * normals.
869 */
870 UPROPERTY(
871 EditAnywhere,
872 BlueprintGetter = GetGenerateSmoothNormals,
873 BlueprintSetter = SetGenerateSmoothNormals,
874 Category = "Cesium|Rendering")
875 bool GenerateSmoothNormals = false;
876
877 /**
878 * Whether to request and render the water mask.
879 *
880 * Currently only applicable for quantized-mesh tilesets that support the
881 * water mask extension.
882 */
883 UPROPERTY(
884 EditAnywhere,
885 BlueprintGetter = GetEnableWaterMask,
886 BlueprintSetter = SetEnableWaterMask,
887 Category = "Cesium|Rendering")
888 bool EnableWaterMask = false;
889
890 /**
891 * Whether to ignore the KHR_materials_unlit extension on the glTF tiles in
892 * this tileset, if it exists, and instead render with standard lighting and
893 * shadows. This property will have no effect if the tileset does not have any
894 * tiles that use this extension.
895 *
896 * The KHR_materials_unlit extension is often applied to photogrammetry
897 * tilesets because lighting and shadows are already baked into their
898 * textures.
899 */
900 UPROPERTY(
901 EditAnywhere,
902 BlueprintGetter = GetIgnoreKhrMaterialsUnlit,
903 BlueprintSetter = SetIgnoreKhrMaterialsUnlit,
904 Category = "Cesium|Rendering",
905 meta = (DisplayName = "Ignore KHR_materials_unlit"))
906 bool IgnoreKhrMaterialsUnlit = false;
907
908 /**
909 * Whether this tileset should receive decals.
910 */
911 UPROPERTY(
912 EditAnywhere,
913 BlueprintGetter = GetReceiveDecals,
914 BlueprintSetter = SetReceiveDecals,
915 Category = "Cesium|Rendering")
916 bool ReceiveDecals = true;
917
918 /**
919 * A custom Material to use to render opaque elements in this tileset, in
920 * order to implement custom visual effects.
921 *
922 * The custom material should generally be created by copying the Material
923 * Instance "MI_CesiumThreeOverlaysAndClipping" and customizing the copy as
924 * desired.
925 */
926 UPROPERTY(
927 EditAnywhere,
928 BlueprintGetter = GetMaterial,
929 BlueprintSetter = SetMaterial,
930 Category = "Cesium|Rendering")
931 UMaterialInterface* Material = nullptr;
932
933 /**
934 * A custom Material to use to render translucent elements of the tileset, in
935 * order to implement custom visual effects.
936 *
937 * The custom material should generally be created by copying the Material
938 * Instance "MI_CesiumThreeOverlaysAndClippingTranslucent" and customizing the
939 * copy as desired. Make sure that its Material Property Overrides -> Blend
940 * Mode is set to "Translucent".
941 */
942 UPROPERTY(
943 EditAnywhere,
944 BlueprintGetter = GetTranslucentMaterial,
945 BlueprintSetter = SetTranslucentMaterial,
946 Category = "Cesium|Rendering")
947 UMaterialInterface* TranslucentMaterial = nullptr;
948
949 /**
950 * A custom Material to use to render this tileset in areas where the
951 * watermask is, in order to implement custom visual effects.
952 * Currently only applicable for quantized-mesh tilesets that support the
953 * water mask extension.
954 *
955 * The custom material should generally be created by copying the Material
956 * Instance "MI_CesiumThreeOverlaysAndClippingAndWater" and customizing the
957 * copy as desired.
958 */
959 UPROPERTY(
960 EditAnywhere,
961 BlueprintGetter = GetWaterMaterial,
962 BlueprintSetter = SetWaterMaterial,
963 Category = "Cesium|Rendering")
964 UMaterialInterface* WaterMaterial = nullptr;
965
966 UPROPERTY(
967 EditAnywhere,
968 BlueprintGetter = GetCustomDepthParameters,
969 BlueprintSetter = SetCustomDepthParameters,
970 Category = "Rendering",
971 meta = (ShowOnlyInnerProperties))
972 FCustomDepthParameters CustomDepthParameters;
973
974 /**
975 * If this tileset contains points, their appearance can be configured with
976 * these point cloud shading parameters.
977 *
978 * These settings are not supported on mobile platforms.
979 */
980 UPROPERTY(
981 EditAnywhere,
982 BlueprintGetter = GetPointCloudShading,
983 BlueprintSetter = SetPointCloudShading,
984 Category = "Cesium|Rendering")
985 FCesiumPointCloudShading PointCloudShading;
986
987 /**
988 * Array of runtime virtual textures into which we draw the mesh for this
989 * actor. The material also needs to be set up to output to a virtual texture.
990 */
991 UPROPERTY(
992 EditAnywhere,
993 BlueprintGetter = GetRuntimeVirtualTextures,
994 BlueprintSetter = SetRuntimeVirtualTextures,
995 Category = "VirtualTexture",
996 meta = (DisplayName = "Draw in Virtual Textures"))
997 TArray<TObjectPtr<URuntimeVirtualTexture>> RuntimeVirtualTextures;
998
999 /** Controls if this component draws in the main pass as well as in the
1000 * virtual texture. You must refresh the Tileset after changing this value! */
1001 UPROPERTY(
1002 EditAnywhere,
1003 BlueprintGetter = GetVirtualTextureRenderPassType,
1004 Category = VirtualTexture,
1005 meta = (DisplayName = "Draw in Main Pass"))
1006 ERuntimeVirtualTextureMainPassType VirtualTextureRenderPassType =
1007 ERuntimeVirtualTextureMainPassType::Exclusive;
1008
1009 /**
1010 * Translucent objects with a lower sort priority draw behind objects with a
1011 * higher priority. Translucent objects with the same priority are rendered
1012 * from back-to-front based on their bounds origin. This setting is also used
1013 * to sort objects being drawn into a runtime virtual texture.
1014 *
1015 * Ignored if the object is not translucent. The default priority is zero.
1016 * Warning: This should never be set to a non-default value unless you know
1017 * what you are doing, as it will prevent the renderer from sorting correctly.
1018 * It is especially problematic on dynamic gameplay effects.
1019 */
1020 UPROPERTY(
1021 EditAnywhere,
1022 BlueprintGetter = GetTranslucencySortPriority,
1023 BlueprintSetter = SetTranslucencySortPriority,
1024 AdvancedDisplay,
1025 Category = Rendering)
1026 int32 TranslucencySortPriority;
1027
1028protected:
1029 UPROPERTY()
1031
1032public:
1033 UFUNCTION(BlueprintGetter, Category = "Cesium")
1034 float GetLoadProgress() const { return LoadProgress; }
1035
1036 UFUNCTION(BlueprintGetter, Category = "Cesium")
1038
1039 UFUNCTION(BlueprintSetter, Category = "Cesium")
1040 void SetUseLodTransitions(bool InUseLodTransitions);
1041
1042 UFUNCTION(BlueprintGetter, Category = "Cesium")
1043 ETilesetSource GetTilesetSource() const { return TilesetSource; }
1044
1045 UFUNCTION(BlueprintSetter, Category = "Cesium")
1047
1048 UFUNCTION(BlueprintGetter, Category = "Cesium")
1049 FString GetUrl() const { return Url; }
1050
1051 UFUNCTION(BlueprintSetter, Category = "Cesium")
1052 void SetUrl(const FString& InUrl);
1053
1054 UFUNCTION(BlueprintGetter, Category = "Cesium")
1055 TMap<FString, FString> GetRequestHeaders() const { return RequestHeaders; }
1056
1057 UFUNCTION(BlueprintSetter, Category = "Cesium")
1058 void SetRequestHeaders(const TMap<FString, FString>& InRequestHeaders);
1059
1060 UFUNCTION(BlueprintGetter, Category = "Cesium")
1061 int64 GetIonAssetID() const { return IonAssetID; }
1062
1063 UFUNCTION(BlueprintSetter, Category = "Cesium")
1064 void SetIonAssetID(int64 InAssetID);
1065
1066 UFUNCTION(BlueprintGetter, Category = "Cesium")
1067 FString GetIonAccessToken() const { return IonAccessToken; }
1068
1069 UFUNCTION(BlueprintSetter, Category = "Cesium")
1070 void SetIonAccessToken(const FString& InAccessToken);
1071
1072 UFUNCTION(BlueprintGetter, Category = "Cesium")
1073 UCesiumIonServer* GetCesiumIonServer() const { return CesiumIonServer; }
1074
1075 UFUNCTION(BlueprintGetter, Category = "VirtualTexture")
1076 TArray<URuntimeVirtualTexture*> GetRuntimeVirtualTextures() const {
1077 return RuntimeVirtualTextures;
1078 }
1079
1080 UFUNCTION(BlueprintSetter, Category = "VirtualTexture")
1082 TArray<URuntimeVirtualTexture*> InRuntimeVirtualTextures);
1083
1084 UFUNCTION(BlueprintGetter, Category = "VirtualTexture")
1085 ERuntimeVirtualTextureMainPassType GetVirtualTextureRenderPassType() const {
1086 return VirtualTextureRenderPassType;
1087 }
1088
1089 UFUNCTION(BlueprintGetter, Category = Rendering)
1090 int32 GetTranslucencySortPriority() { return TranslucencySortPriority; }
1091
1092 UFUNCTION(BlueprintSetter, Category = Rendering)
1093 void SetTranslucencySortPriority(int32 InTranslucencySortPriority);
1094
1095 UFUNCTION(BlueprintSetter, Category = "Cesium")
1097
1098 UFUNCTION(BlueprintGetter, Category = "Cesium")
1100
1101 UFUNCTION(BlueprintSetter, Category = "Cesium")
1102 void SetMaximumScreenSpaceError(double InMaximumScreenSpaceError);
1103
1104 UFUNCTION(BlueprintGetter, Category = "Cesium|Tile Culling|Experimental")
1106
1107 UFUNCTION(BlueprintSetter, Category = "Cesium|Tile Culling|Experimental")
1108 void SetEnableOcclusionCulling(bool bEnableOcclusionCulling);
1109
1110 UFUNCTION(BlueprintGetter, Category = "Cesium|Tile Culling|Experimental")
1111 int32 GetOcclusionPoolSize() const { return OcclusionPoolSize; }
1112
1113 UFUNCTION(BlueprintSetter, Category = "Cesium|Tile Culling|Experimental")
1114 void SetOcclusionPoolSize(int32 newOcclusionPoolSize);
1115
1116 UFUNCTION(BlueprintGetter, Category = "Cesium|Tile Culling|Experimental")
1120
1121 UFUNCTION(BlueprintSetter, Category = "Cesium|Tile Culling|Experimental")
1122 void SetDelayRefinementForOcclusion(bool bDelayRefinementForOcclusion);
1123
1124 UFUNCTION(BlueprintGetter, Category = "Cesium|Physics")
1125 bool GetCreatePhysicsMeshes() const { return CreatePhysicsMeshes; }
1126
1127 UFUNCTION(BlueprintSetter, Category = "Cesium|Physics")
1128 void SetCreatePhysicsMeshes(bool bCreatePhysicsMeshes);
1129
1130 UFUNCTION(BlueprintGetter, Category = "Cesium|Physics")
1132 return EnableDoubleSidedCollisions;
1133 }
1134
1135 UFUNCTION(BlueprintSetter, Category = "Cesium|Physics")
1136 void SetEnableDoubleSidedCollisions(bool bEnableDoubleSidedCollisions);
1137
1138 UFUNCTION(BlueprintGetter, Category = "Cesium|Navigation")
1139 bool GetCreateNavCollision() const { return CreateNavCollision; }
1140
1141 UFUNCTION(BlueprintSetter, Category = "Cesium|Navigation")
1142 void SetCreateNavCollision(bool bCreateNavCollision);
1143
1144 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1145 bool GetAlwaysIncludeTangents() const { return AlwaysIncludeTangents; }
1146
1147 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1148 void SetAlwaysIncludeTangents(bool bAlwaysIncludeTangents);
1149
1150 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1151 bool GetGenerateSmoothNormals() const { return GenerateSmoothNormals; }
1152
1153 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1154 void SetGenerateSmoothNormals(bool bGenerateSmoothNormals);
1155
1156 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1157 bool GetEnableWaterMask() const { return EnableWaterMask; }
1158
1159 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1160 void SetEnableWaterMask(bool bEnableMask);
1161
1162 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1163 bool GetIgnoreKhrMaterialsUnlit() const { return IgnoreKhrMaterialsUnlit; }
1164 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1165 void SetIgnoreKhrMaterialsUnlit(bool bIgnoreKhrMaterialsUnlit);
1166
1167 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1168 bool GetReceiveDecals() const { return ReceiveDecals; }
1169 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1170 void SetReceiveDecals(bool bReceiveDecals);
1171
1172 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1173 UMaterialInterface* GetMaterial() const { return Material; }
1174
1175 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1176 void SetMaterial(UMaterialInterface* InMaterial);
1177
1178 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1179 UMaterialInterface* GetTranslucentMaterial() const {
1180 return TranslucentMaterial;
1181 }
1182
1183 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1184 void SetTranslucentMaterial(UMaterialInterface* InMaterial);
1185
1186 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1187 UMaterialInterface* GetWaterMaterial() const { return WaterMaterial; }
1188
1189 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1190 void SetWaterMaterial(UMaterialInterface* InMaterial);
1191
1192 UFUNCTION(BlueprintGetter, Category = "Rendering")
1194 return CustomDepthParameters;
1195 }
1196
1197 UFUNCTION(BlueprintSetter, Category = "Rendering")
1199
1200 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1202 return PointCloudShading;
1203 }
1204
1205 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1207
1208 UFUNCTION(BlueprintCallable, Category = "Cesium|Rendering")
1210
1211 UFUNCTION(BlueprintCallable, Category = "Cesium|Rendering")
1213
1214 UFUNCTION(BlueprintCallable, Category = "Cesium|Rendering")
1216
1217 /**
1218 * This method is not supposed to be called by clients. It is currently
1219 * only required by the UnrealPrepareRendererResources.
1220 *
1221 * @internal
1222 * See {@link
1223 * UCesium3DTilesetRoot::GetCesiumTilesetToUnrealRelativeWorldTransform}.
1224 * @endinternal
1225 */
1227
1229 return this->_pTileset.Get();
1230 }
1232 return this->_pTileset.Get();
1233 }
1234
1235 // AActor overrides (some or most of them should be protected)
1236 virtual bool ShouldTickIfViewportsOnly() const override;
1237 virtual void Tick(float DeltaTime) override;
1238 virtual void BeginDestroy() override;
1239 virtual bool IsReadyForFinishDestroy() override;
1240 virtual void Destroyed() override;
1241 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
1242 virtual void PostLoad() override;
1243 virtual void Serialize(FArchive& Ar) override;
1244
1246
1247 // UObject overrides
1248#if WITH_EDITOR
1249 virtual void
1250 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
1251 virtual void PostEditChangeChainProperty(
1252 FPropertyChangedChainEvent& PropertyChangedChainEvent) override;
1253 virtual void PostEditUndo() override;
1254 virtual void PostEditImport() override;
1255#endif
1256
1257protected:
1258 // Called when the game starts or when spawned
1259 virtual void BeginPlay() override;
1260 virtual void OnConstruction(const FTransform& Transform) override;
1261
1262 /**
1263 * Called after the C++ constructor and after the properties have
1264 * been initialized, including those loaded from config.
1265 */
1266 void PostInitProperties() override;
1267
1268 virtual void NotifyHit(
1269 class UPrimitiveComponent* MyComp,
1270 AActor* Other,
1271 class UPrimitiveComponent* OtherComp,
1272 bool bSelfMoved,
1273 FVector HitLocation,
1274 FVector HitNormal,
1275 FVector NormalImpulse,
1276 const FHitResult& Hit) override;
1277
1278private:
1279 void LoadTileset();
1280 void DestroyTileset();
1281
1282 static Cesium3DTilesSelection::ViewState CreateViewStateFromViewParameters(
1283 const FCesiumCamera& camera,
1284 const glm::dmat4& unrealWorldToTileset,
1285 UCesiumEllipsoid* ellipsoid);
1286
1287 std::vector<FCesiumCamera> GetCameras() const;
1288 std::vector<FCesiumCamera> GetPlayerCameras() const;
1289 std::vector<FCesiumCamera> GetSceneCaptures() const;
1290
1291public:
1292 /**
1293 * Update the transforms of the glTF components based on the
1294 * the transform of the root component.
1295 *
1296 * This is supposed to be called during Tick, if the transform of
1297 * the root component has changed since the previous Tick.
1298 */
1300
1301 /**
1302 * Gets the glTF modifier, an optional extension class that can edit
1303 * each tile's glTF model after it has been loaded, before it can be
1304 * displayed.
1305 */
1306 const std::shared_ptr<Cesium3DTilesSelection::GltfModifier>&
1308
1309 /**
1310 * Sets the glTF modifier, an optional extension class that can edit
1311 * each tile's glTF model after it has been loaded, before it can be
1312 * displayed.
1313 *
1314 * Setting this property will refresh the tileset.
1315 */
1317 const std::shared_ptr<Cesium3DTilesSelection::GltfModifier>& Modifier);
1318
1319 /**
1320 * Gets the optional receiver of events related to the lifecycle of tiles
1321 * created by this tileset.
1322 */
1324
1325 /**
1326 * Sets a receiver of events related to the lifecycle of tiles
1327 * created by this tileset.
1328 *
1329 * The receiver will be notified of events such as tile load, unload, show,
1330 * and hide. The provided instance _must_ implement @ref
1331 * ICesium3DTilesetLifecycleEventReceiver, otherwise it will be as if nullptr
1332 * were passed.
1333 */
1334 void SetLifecycleEventReceiver(UObject* EventReceiver);
1335
1336private:
1337 /**
1338 * The event handler for ACesiumGeoreference::OnEllipsoidChanged.
1339 */
1340 UFUNCTION(CallInEditor)
1341 void HandleOnGeoreferenceEllipsoidChanged(
1342 UCesiumEllipsoid* OldEllipsoid,
1343 UCesiumEllipsoid* NewEllpisoid);
1344
1345 /**
1346 * Creates and attaches a \ref UCesiumVoxelRendererComponent for rendering
1347 * voxel data.
1348 */
1349 void
1351 VoxelExtension);
1352
1353 /**
1354 * Writes the values of all properties of this actor into the
1355 * TilesetOptions, to take them into account during the next
1356 * traversal.
1357 */
1358 void updateTilesetOptionsFromProperties();
1359
1360 /**
1361 * Update all the "_last..." fields of this instance based
1362 * on the given ViewUpdateResult, printing a log message
1363 * if any value changed.
1364 *
1365 * @param result The ViewUpdateREsult
1366 */
1367 void updateLastViewUpdateResultState(
1369
1370 /**
1371 * Creates the visual representations of the given tiles to
1372 * be rendered in the current frame.
1373 *
1374 * @param tiles The tiles
1375 */
1376 void showTilesToRender(
1377 const std::vector<Cesium3DTilesSelection::Tile::ConstPointer>& tiles);
1378
1379 /**
1380 * Will be called after the tileset is loaded or spawned, to register
1381 * a delegate that calls OnFocusEditorViewportOnThis when this
1382 * tileset is double-clicked
1383 */
1384 void AddFocusViewportDelegate();
1385
1386#if WITH_EDITOR
1387 std::vector<FCesiumCamera> GetEditorCameras() const;
1388
1389 /**
1390 * Will focus all viewports on this tileset.
1391 *
1392 * This is called when double-clicking the tileset in the World Outliner.
1393 * It will move the tileset into the center of the view, *even if* the
1394 * tileset was not visible before, and no geometry has been created yet
1395 * for the tileset: It solely operates on the tile bounding volume that
1396 * was given in the root tile.
1397 */
1398 void OnFocusEditorViewportOnThis();
1399
1400 void RuntimeSettingsChanged(
1401 UObject* pObject,
1402 struct FPropertyChangedEvent& changed);
1403#endif
1404
1405private:
1406 TUniquePtr<Cesium3DTilesSelection::Tileset> _pTileset;
1407 TWeakObjectPtr<UCesiumFeaturesMetadataComponent> _pFeaturesMetadataComponent;
1408 TWeakObjectPtr<UCesiumVoxelMetadataComponent> _pVoxelMetadataComponent;
1409
1410 bool _destroyOnNextTick;
1411
1412#ifdef CESIUM_DEBUG_TILE_STATES
1413 TUniquePtr<Cesium3DTilesSelection::DebugTileStateDatabase> _pStateDebug;
1414#endif
1415
1416 PRAGMA_DISABLE_DEPRECATION_WARNINGS
1417 std::optional<FMetadataDescription> _metadataDescription_DEPRECATED;
1418 PRAGMA_ENABLE_DEPRECATION_WARNINGS
1419
1420 /**
1421 * The voxel renderer component used to render voxel data. Only used for voxel
1422 * tilesets.
1423 */
1424 UCesiumVoxelRendererComponent* _pVoxelRendererComponent = nullptr;
1425
1426 // For debug output
1427 uint32_t _lastTilesRendered;
1428 uint32_t _lastWorkerThreadTileLoadQueueLength;
1429 uint32_t _lastMainThreadTileLoadQueueLength;
1430
1431 uint32_t _lastTilesVisited;
1432 uint32_t _lastCulledTilesVisited;
1433 uint32_t _lastTilesCulled;
1434 uint32_t _lastTilesOccluded;
1435 uint32_t _lastTilesWaitingForOcclusionResults;
1436 uint32_t _lastMaxDepthVisited;
1437
1438 std::chrono::high_resolution_clock::time_point _startTime;
1439
1440 bool _captureMovieMode;
1441 bool _beforeMoviePreloadAncestors;
1442 bool _beforeMoviePreloadSiblings;
1443 int32_t _beforeMovieLoadingDescendantLimit;
1444 bool _beforeMovieUseLodTransitions;
1445
1446 bool _scaleUsingDPI;
1447
1448 // This is used as a workaround for cesium-native#186
1449 //
1450 // The tiles that are no longer supposed to be rendered in the current
1451 // frame, according to ViewUpdateResult::tilesToHideThisFrame,
1452 // are kept in this list, and hidden in the NEXT frame, because some
1453 // internal occlusion culling information from Unreal might prevent
1454 // the tiles that are supposed to be rendered instead from appearing
1455 // immediately.
1456 //
1457 // If we find a way to clear the wrong occlusion information in the
1458 // Unreal Engine, then this field may be removed, and the
1459 // tilesToHideThisFrame may be hidden immediately.
1460 std::vector<Cesium3DTilesSelection::Tile::ConstPointer> _tilesToHideNextFrame;
1461
1462 int32 _tilesetsBeingDestroyed;
1463
1464 std::shared_ptr<Cesium3DTilesSelection::GltfModifier> _pGltfModifier;
1465
1466 // Make this visible to the garbage collector, but don't save/load/copy it.
1467 // Use UObject instead of TScriptInterface as suggested by
1468 // https://www.stevestreeting.com/2020/11/02/ue4-c-interfaces-hints-n-tips/,
1469 // even though this cannot be implemented through Blueprints for the moment
1470 // (see comment over UCesium3DTilesetLifecycleEventReceiver for instructions),
1471 // it's best being prepared for the future.
1472 UPROPERTY(Transient, DuplicateTransient, TextExportTransient)
1473 UObject* _pLifecycleEventReceiver;
1474
1477};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCompletedLoadTrigger)
The delegate for the Acesium3DTileset::OnTilesetLoaded, which is triggered from UpdateLoadStatus.
FCesium3DTilesetLoadFailure OnCesium3DTilesetLoadFailure
DECLARE_DELEGATE_ThreeParams(FCesiumSampleHeightMostDetailedCallback, ACesium3DTileset *, const TArray< FCesiumSampleHeightResult > &, const TArray< FString > &)
DECLARE_MULTICAST_DELEGATE_OneParam(FCesium3DTilesetLoadFailure, const FCesium3DTilesetLoadFailureDetails &)
The delegate for OnCesium3DTilesetLoadFailure, which is triggered when the tileset encounters a load ...
EApplyDpiScaling
ETilesetSource
@ UMETA
The tileset will be loaded from Cesium Ion using the provided IonAssetID and IonAccessToken.
@ FromCesiumIon
The raster overlay will load a GeoJsonDocument from Cesium ion.
@ FromUrl
The raster overlay will load a GeoJsonDocument from a URL.
@ Tileset
Height is interpreted relative to the surface of a 3D tileset.
virtual bool ShouldTickIfViewportsOnly() const override
TSoftObjectPtr< ACesiumCameraManager > GetCameraManager() const
The actor providing custom cameras for use with this Tileset.
bool PreloadAncestors
Whether to preload ancestor tiles.
FCompletedLoadTrigger OnTilesetLoaded
A delegate that will be called whenever the tileset is fully loaded.
void UpdateTransformFromCesium()
Update the transforms of the glTF components based on the the transform of the root component.
ACesiumCreditSystem * ResolveCreditSystem()
Resolves the Cesium Credit System to use with this Actor.
bool GetReceiveDecals() const
bool SuspendUpdate
Pauses level-of-detail and culling updates of this tileset.
int64 GetIonAssetID() const
void SetMaximumScreenSpaceError(double InMaximumScreenSpaceError)
FBodyInstance BodyInstance
Define the collision profile for all the 3D tiles created inside this actor.
bool GetCreateNavCollision() const
void InvalidateResolvedGeoreference()
Invalidates the cached resolved georeference, unsubscribing from it and setting it to null.
FCustomDepthParameters GetCustomDepthParameters() const
void SetReceiveDecals(bool bReceiveDecals)
void SetUrl(const FString &InUrl)
bool GetDelayRefinementForOcclusion() const
void SetEnableOcclusionCulling(bool bEnableOcclusionCulling)
bool EnableFrustumCulling
Whether to cull tiles that are outside the frustum.
bool GetEnableOcclusionCulling() const
bool EnableFogCulling
Whether to cull tiles that are occluded by fog.
bool GetCreatePhysicsMeshes() const
bool GetIgnoreKhrMaterialsUnlit() const
int32 GetTranslucencySortPriority()
void SetWaterMaterial(UMaterialInterface *InMaterial)
bool DrawTileInfo
If true, draws debug text above each tile being rendered with information about that tile.
TMap< FString, FString > GetRequestHeaders() const
int32 MaximumSimultaneousTileLoads
The maximum number of tiles that may be loaded at once.
void SetMaterial(UMaterialInterface *InMaterial)
void PostInitProperties() override
Called after the C++ constructor and after the properties have been initialized, including those load...
Cesium3DTilesSelection::Tileset * GetTileset()
void SetLifecycleEventReceiver(UObject *EventReceiver)
Sets a receiver of events related to the lifecycle of tiles created by this tileset.
ERuntimeVirtualTextureMainPassType GetVirtualTextureRenderPassType() const
EApplyDpiScaling ApplyDpiScaling
Scale Level-of-Detail by Display DPI.
void SetRuntimeVirtualTextures(TArray< URuntimeVirtualTexture * > InRuntimeVirtualTextures)
const glm::dmat4 & GetCesiumTilesetToUnrealRelativeWorldTransform() const
This method is not supposed to be called by clients.
void SetOcclusionPoolSize(int32 newOcclusionPoolSize)
bool ShowCreditsOnScreen
Whether or not to show this tileset's credits on screen.
virtual void BeginPlay() override
TSoftObjectPtr< ACesiumCreditSystem > GetCreditSystem() const
The actor managing this tileset's content attributions.
virtual bool IsReadyForFinishDestroy() override
friend class UCesiumGltfPointsComponent
bool UpdateInEditor
If true, this tileset is ticked/updated in the editor.
const Cesium3DTilesSelection::Tileset * GetTileset() const
void SetEnableWaterMask(bool bEnableMask)
bool EnforceCulledScreenSpaceError
Whether a specified screen-space error should be enforced for tiles that are outside the frustum or h...
void StopMovieSequencer()
void InvalidateResolvedCameraManager()
Invalidates the cached resolved Camera Manager, setting it to null.
ETilesetSource GetTilesetSource() const
virtual ~ACesium3DTileset()
const std::shared_ptr< Cesium3DTilesSelection::GltfModifier > & GetGltfModifier() const
Gets the glTF modifier, an optional extension class that can edit each tile's glTF model after it has...
void SetMobility(EComponentMobility::Type NewMobility)
UCesiumIonServer * GetCesiumIonServer() const
bool GetGenerateSmoothNormals() const
void SetIgnoreKhrMaterialsUnlit(bool bIgnoreKhrMaterialsUnlit)
ACesiumCameraManager * ResolveCameraManager()
Resolves the Cesium Camera Manager to use with this Actor.
virtual void Destroyed() override
bool EnableOcclusionCulling
Whether to cull tiles that are occluded.
void SetRequestHeaders(const TMap< FString, FString > &InRequestHeaders)
int32 OcclusionPoolSize
The number of CesiumBoundingVolumeComponents to use for querying the occlusion state of traversed til...
void SetIonAssetID(int64 InAssetID)
FCesiumPointCloudShading GetPointCloudShading() const
int32 LoadingDescendantLimit
The number of loading descendents a tile should allow before deciding to render itself instead of wai...
void SetGeoreference(TSoftObjectPtr< ACesiumGeoreference > NewGeoreference)
The designated georeference actor controlling how the actor's coordinate system relates to the coordi...
float LodTransitionLength
How long dithered LOD transitions between different tiles should take, in seconds.
void UpdateLoadStatus()
virtual void PostLoad() override
bool ForbidHoles
Whether to unrefine back to a parent tile when a child isn't done loading.
bool LogSharedAssetStats
If true, logs stats on the assets in this tileset's shared asset system to the Output Log.
void SetEnableDoubleSidedCollisions(bool bEnableDoubleSidedCollisions)
double MaximumScreenSpaceError
The maximum number of pixels of error when rendering this tileset.
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
void SetCreditSystem(TSoftObjectPtr< ACesiumCreditSystem > NewCreditSystem)
The actor managing this tileset's content attributions.
UMaterialInterface * GetMaterial() const
UMaterialInterface * GetWaterMaterial() const
void PlayMovieSequencer()
void SetCreateNavCollision(bool bCreateNavCollision)
void SetGenerateSmoothNormals(bool bGenerateSmoothNormals)
int32 GetOcclusionPoolSize() const
void InvalidateResolvedCreditSystem()
Invalidates the cached resolved Credit System, setting it to null.
void SetCreatePhysicsMeshes(bool bCreatePhysicsMeshes)
int64 MaximumCachedBytes
The maximum number of bytes that may be cached.
void PauseMovieSequencer()
friend class UnrealPrepareRendererResources
void SetPointCloudShading(FCesiumPointCloudShading InPointCloudShading)
virtual void OnConstruction(const FTransform &Transform) override
ACesiumGeoreference * ResolveGeoreference()
Resolves the Cesium Georeference to use with this Actor.
bool DelayRefinementForOcclusion
Whether to wait for valid occlusion results before refining tiles.
UMaterialInterface * GetTranslucentMaterial() const
void SetTranslucencySortPriority(int32 InTranslucencySortPriority)
FString GetIonAccessToken() const
void RefreshTileset()
Refreshes this tileset, ensuring that all materials and other settings are applied.
bool PreloadSiblings
Whether to preload sibling tiles.
void SetTranslucentMaterial(UMaterialInterface *InMaterial)
FString GetUrl() const
EComponentMobility::Type GetMobility() const
void SetIonAccessToken(const FString &InAccessToken)
double GetMaximumScreenSpaceError()
void SetTilesetSource(ETilesetSource InSource)
virtual void BeginDestroy() override
void SetUseLodTransitions(bool InUseLodTransitions)
void SampleHeightMostDetailed(const TArray< FVector > &LongitudeLatitudeHeightArray, FCesiumSampleHeightMostDetailedCallback OnHeightsSampled)
Initiates an asynchronous query for the height of this tileset at a list of cartographic positions,...
bool GetUseLodTransitions() const
virtual void Serialize(FArchive &Ar) override
TSoftObjectPtr< ACesiumGeoreference > GetGeoreference() const
The designated georeference actor controlling how the actor's coordinate system relates to the coordi...
void SetCesiumIonServer(UCesiumIonServer *Server)
ICesium3DTilesetLifecycleEventReceiver * GetLifecycleEventReceiver()
Gets the optional receiver of events related to the lifecycle of tiles created by this tileset.
bool UseLodTransitions
Use a dithering effect when transitioning between tiles of different LODs.
void SetGltfModifier(const std::shared_ptr< Cesium3DTilesSelection::GltfModifier > &Modifier)
Sets the glTF modifier, an optional extension class that can edit each tile's glTF model after it has...
bool LogSelectionStats
If true, stats about tile selection are printed to the Output Log.
void SetCameraManager(TSoftObjectPtr< ACesiumCameraManager > NewCameraManager)
The actor providing custom cameras for use with this Tileset.
double CulledScreenSpaceError
The screen-space error to be enforced for tiles that are outside the view frustum or hidden in fog.
TArray< URuntimeVirtualTexture * > GetRuntimeVirtualTextures() const
void SetAlwaysIncludeTangents(bool bAlwaysIncludeTangents)
bool GetEnableWaterMask() const
virtual void NotifyHit(class UPrimitiveComponent *MyComp, AActor *Other, class UPrimitiveComponent *OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult &Hit) override
bool GetAlwaysIncludeTangents() const
float GetLoadProgress() const
void SetDelayRefinementForOcclusion(bool bDelayRefinementForOcclusion)
void SetCustomDepthParameters(FCustomDepthParameters InCustomDepthParameters)
virtual void Tick(float DeltaTime) override
bool GetEnableDoubleSidedCollisions() const
Manages custom FCesiumCameras for all ACesium3DTilesets in the world.
Manages credits / atttribution for Cesium data sources.
Controls how global geospatial coordinates are mapped to coordinates in the Unreal Engine level.
An interface that receives events about the lifecycle of tiles in a Cesium3DTileset.
A component that can be added to Cesium3DTileset actors to dictate what feature ID sets or metadata t...
Defines a Cesium ion Server.
A camera description that ACesium3DTilesets can use to decide what tiles need to be loaded to suffici...
Options for adjusting how point clouds are rendered using 3D Tiles.