Cesium for Unreal 2.12.0
Loading...
Searching...
No Matches
CesiumSunSky.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CoreMinimal.h"
6
8#include "Components/DirectionalLightComponent.h"
9#include "Components/SkyAtmosphereComponent.h"
10#include "Components/SkyLightComponent.h"
11#include "Components/StaticMeshComponent.h"
12#include "Engine/DirectionalLight.h"
13#include "GameFramework/Actor.h"
14#include "CesiumSunSky.generated.h"
15
17
28UCLASS()
29class CESIUMRUNTIME_API ACesiumSunSky : public AActor {
30 GENERATED_BODY()
31
32public:
33 // Sets default values for this actor's properties
35
36 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Components)
37 USceneComponent* Scene;
38
39 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Components)
40 USkyLightComponent* SkyLight;
41
42 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Components)
43 UDirectionalLightComponent* DirectionalLight;
44
45 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Components)
46 USkyAtmosphereComponent* SkyAtmosphere;
47
51 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Components)
53
60 UPROPERTY(
61 EditAnywhere,
62 BlueprintReadWrite,
63 Category = "Cesium|Date and Time",
64 meta = (ClampMin = -12, ClampMax = 14))
65 double TimeZone = -5.0;
66
73 UPROPERTY(
74 EditAnywhere,
75 BlueprintReadWrite,
76 Category = "Cesium|Date and Time",
77 meta = (UIMin = 4, UIMax = 22, ClampMin = 0, ClampMax = 23.9999))
78 double SolarTime = 13.0;
79
86 UPROPERTY(
87 EditAnywhere,
88 BlueprintReadWrite,
89 Category = "Cesium|Date and Time",
90 meta = (ClampMin = 1, ClampMax = 31))
91 int32 Day = 21;
92
99 UPROPERTY(
100 EditAnywhere,
101 BlueprintReadWrite,
102 Category = "Cesium|Date and Time",
103 meta = (ClampMin = 1, ClampMax = 12))
104 int32 Month = 9;
105
112 UPROPERTY(
113 EditAnywhere,
114 BlueprintReadWrite,
115 Category = "Cesium|Date and Time",
116 meta = (UIMin = 1800, UIMax = 2200, ClampMin = 0, ClampMax = 4000))
117 int32 Year = 2019;
118
126 UPROPERTY(
127 BlueprintReadWrite,
128 Category = "Cesium|Date and Time",
129 meta = (ClampMin = -360, ClampMax = 360))
130 double NorthOffset = -90.0;
131
138 UPROPERTY(
139 EditAnywhere,
140 BlueprintReadWrite,
141 Category = "Cesium|Date and Time|Daylight Savings")
142 bool UseDaylightSavingTime = true;
143
144protected:
150 UPROPERTY(
151 BlueprintReadOnly,
152 Category = "Cesium",
153 BlueprintGetter = GetGeoreference,
154 Meta =
155 (DeprecatedProperty,
156 DeprecationMessage =
157 "Get the Georeference instance from the Globe Anchor Component instead."))
158 ACesiumGeoreference* Georeference_DEPRECATED;
159
164 UFUNCTION(BlueprintGetter, Category = "Cesium")
166
173 UPROPERTY(
174 EditAnywhere,
175 BlueprintReadWrite,
176 Category = "Cesium|Date and Time|Daylight Savings",
177 meta = (ClampMin = 1, ClampMax = 12),
178 meta = (EditCondition = "UseDaylightSavingTime"))
179 int32 DSTStartMonth = 3;
180
187 UPROPERTY(
188 EditAnywhere,
189 BlueprintReadWrite,
190 Category = "Cesium|Date and Time|Daylight Savings",
191 meta = (ClampMin = 1, ClampMax = 31),
192 meta = (EditCondition = "UseDaylightSavingTime"))
193 int32 DSTStartDay = 10;
194
201 UPROPERTY(
202 EditAnywhere,
203 BlueprintReadWrite,
204 Category = "Cesium|Date and Time|Daylight Savings",
205 meta = (ClampMin = 1, ClampMax = 12),
206 meta = (EditCondition = "UseDaylightSavingTime"))
207 int32 DSTEndMonth = 11;
208
215 UPROPERTY(
216 EditAnywhere,
217 BlueprintReadWrite,
218 Category = "Cesium|Date and Time|Daylight Savings",
219 meta = (ClampMin = 1, ClampMax = 31),
220 meta = (EditCondition = "UseDaylightSavingTime"))
221 int32 DSTEndDay = 3;
222
229 UPROPERTY(
230 EditAnywhere,
231 BlueprintReadWrite,
232 Category = "Cesium|Date and Time|Daylight Savings",
233 meta = (ClampMin = 0, ClampMax = 23),
234 meta = (EditCondition = "UseDaylightSavingTime"))
235 int32 DSTSwitchHour = 2;
236
242 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Atmosphere")
243 bool UpdateAtmosphereAtRuntime = true;
244
264 UPROPERTY(
265 EditAnywhere,
266 BlueprintReadWrite,
267 meta = (EditCondition = "UpdateAtmosphereAtRuntime"),
268 Category = "Cesium|Atmosphere")
269 double InscribedGroundThreshold = 30.0;
270
291 UPROPERTY(
292 EditAnywhere,
293 BlueprintReadWrite,
294 meta = (EditCondition = "UpdateAtmosphereAtRuntime"),
295 Category = "Cesium|Atmosphere")
296 double CircumscribedGroundThreshold = 100.0;
297
306 UPROPERTY(
307 EditAnywhere,
308 BlueprintReadWrite,
309 meta = (EditCondition = "UpdateAtmosphereAtRuntime"),
310 Category = "Cesium|Atmosphere")
311 double CircumscribedGroundHeight = 0.0;
312
320 UPROPERTY(
321 EditAnywhere,
322 BlueprintReadOnly,
323 interp,
324 Category = "Cesium|Atmosphere",
325 meta = (UIMin = 1.0, UIMax = 200.0, ClampMin = 0.1, SliderExponent = 2.0))
326 float AtmosphereHeight = 60.0f;
327
333 UPROPERTY(
334 EditAnywhere,
335 BlueprintReadOnly,
336 interp,
337 Category = "Cesium|Atmosphere",
338 meta =
339 (DisplayName = "Aerial Perspective View Distance Scale",
340 UIMin = 0.0,
341 UIMax = 3.0,
342 ClampMin = 0.0,
343 SliderExponent = 2.0))
344 float AerialPerspectiveViewDistanceScale = 1.0f;
345
351 UPROPERTY(
352 EditAnywhere,
353 BlueprintReadOnly,
354 interp,
355 Category = "Cesium|Atmosphere",
356 meta =
357 (UIMin = 0.01, UIMax = 20.0, ClampMin = 0.001, SliderExponent = 5.0))
358 float RayleighExponentialDistribution = 8.0f;
359
365 UPROPERTY(
366 EditAnywhere,
367 BlueprintReadOnly,
368 interp,
369 Category = "Cesium|Atmosphere",
370 meta =
371 (UIMin = 0.01, UIMax = 10.0, ClampMin = 0.001, SliderExponent = 5.0))
372 float MieExponentialDistribution = 1.2f;
373
378 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Sun")
379 bool UseLevelDirectionalLight = false;
380
384 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Sun")
385 ADirectionalLight* LevelDirectionalLight;
386
391 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sun")
392 double Elevation = 0.f;
393
398 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sun")
399 double CorrectedElevation = 0.f;
400
405 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sun")
406 double Azimuth = 0.f;
407
413 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Cesium|Mobile")
414 bool UseMobileRendering;
415
420 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Mobile")
421 TSubclassOf<AActor> SkySphereClass;
422
426 UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Cesium|Mobile")
427 AActor* SkySphereActor;
428
432 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Cesium|Mobile")
433 double MobileDirectionalLightIntensity = 6.f;
434
435public:
436 UFUNCTION(
437 CallInEditor,
438 BlueprintCallable,
439 BlueprintNativeEvent,
440 Category = "Cesium")
441 void UpdateSun();
442 void UpdateSun_Implementation();
443
444 UFUNCTION(CallInEditor, BlueprintCallable, Category = "Cesium")
445 void UpdateAtmosphereRadius();
446
451 UFUNCTION(BlueprintCallable, BlueprintPure, Category = Sun)
452 static void GetHMSFromSolarTime(
453 double InSolarTime,
454 int32& Hour,
455 int32& Minute,
456 int32& Second);
457
463 UFUNCTION(BlueprintCallable, BlueprintPure, Category = Sun)
464 bool IsDST(
465 bool DSTEnable,
466 int32 InDSTStartMonth,
467 int32 InDSTStartDay,
468 int32 InDSTEndMonth,
469 int32 InDSTEndDay,
470 int32 InDSTSwitchHour) const;
471
472 // Begin AActor Interface
478 virtual void OnConstruction(const FTransform& Transform) override;
479 // End AActor Interface
480
481protected:
490 UFUNCTION(BlueprintCallable, Category = "Cesium")
491 void
492 SetSkyAtmosphereGroundRadius(USkyAtmosphereComponent* Sky, double Radius);
493
497 UFUNCTION(BlueprintCallable, Category = "Mobile")
498 void UpdateSkySphere();
499
500 virtual void BeginPlay() override;
501 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
502 virtual void Serialize(FArchive& Ar) override;
503 virtual void Tick(float DeltaSeconds) override;
504 virtual void PostLoad() override;
505 virtual bool ShouldTickIfViewportsOnly() const override;
506
507#if WITH_EDITOR
508 virtual void
509 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
510#endif
511
512private:
513 void _spawnSkySphere();
514 double _computeScale() const;
515
516 // Sets Directional Light Component in Sky Sphere actor
517 void _setSkySphereDirectionalLight();
518
519 void _setSkyAtmosphereVisibility(bool bVisible);
520
521 // Determines whether mobile sky sphere will be spawned during OnConstruction.
522 bool _wantsSpawnMobileSkySphere;
523
524 void _handleTransformUpdated(
525 USceneComponent* InRootComponent,
526 EUpdateTransformFlags UpdateTransformFlags,
527 ETeleportType Teleport);
528
529 FDelegateHandle _transformUpdatedSubscription;
530};
Controls how global geospatial coordinates are mapped to coordinates in the Unreal Engine level.
A globe-aware sun sky actor.
This component can be added to a movable actor to anchor it to the globe and maintain precise placeme...
virtual void Serialize(FArchive &Ar) override
Handles reading, writing, and reference collecting using FArchive.
TSoftObjectPtr< ACesiumGeoreference > GetGeoreference() const
Gets the designated georeference actor controlling how the owning actor's coordinate system relates t...