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