Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Sun.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_SUN_H_
34#define DVD_SUN_H_
35
36//ref: https://gist.github.com/paulhayes/54a7aa2ee3cccad4d37bb65977eb19e2
37//ref: https://github.com/jarmol/suncalcs
38namespace Divide {
39 struct SunInfo
40 {
48 };
49
51 {
52 [[nodiscard]] static SunInfo CalculateSunPosition(const struct tm &dateTime, F32 latitude, F32 longitude);
53 [[nodiscard]] static D64 CorrectAngle(D64 angleInRadians) noexcept;
54 };
55
56 struct Sun
57 {
58 void SetLocation(F32 longitude, F32 latitude) noexcept;
59 void SetDate(struct tm &dateTime) noexcept;
60 SimpleTime GetTimeOfDay() const noexcept;
62
63 [[nodiscard]] const SunInfo& GetDetails() const;
64
65 [[nodiscard]] vec3<F32> GetSunPosition(F32 radius = 1.f) const;
66 private:
70 struct tm _dateTime {};
71 mutable bool _dirty = true;
72 };
73
75 {
76 FColour3 _rayleighColour = { 0.26f, 0.41f, 0.58f };
77 FColour3 _mieColour = { 0.63f, 0.77f, 0.92f };
78 vec2<F32> _cloudLayerMinMaxHeight = { 1500.f, 4000.f };
80 F32 _mie = 0.005f;
84 F32 _planetRadius = 6'371'000.f;
87 };
88} // namespace Divide
89
90#endif //DVD_SUN_H_
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
double D64
vec2< F32 > _cloudLayerMinMaxHeight
Definition: Sun.h:78
FColour3 _mieColour
Definition: Sun.h:77
F32 _turbidity
Definition: Sun.h:82
F32 _rayleigh
Definition: Sun.h:79
F32 _sunDiskSize
Definition: Sun.h:83
FColour3 _rayleighColour
Definition: Sun.h:76
F32 _cloudCoverage
Definition: Sun.h:85
F32 _cloudDensity
Definition: Sun.h:86
F32 _mieEccentricity
Definition: Sun.h:81
F32 _planetRadius
Definition: Sun.h:84
vec3< F32 > GetSunPosition(F32 radius=1.f) const
Definition: Sun.cpp:234
void SetLocation(F32 longitude, F32 latitude) noexcept
Definition: Sun.cpp:190
const SunInfo & GetDetails() const
Definition: Sun.cpp:225
SimpleLocation GetGeographicLocation() const noexcept
Definition: Sun.cpp:218
void SetDate(struct tm &dateTime) noexcept
Definition: Sun.cpp:201
SunInfo _cachedDetails
Definition: Sun.h:67
F32 _latitude
Definition: Sun.h:69
bool _dirty
Definition: Sun.h:71
SimpleTime GetTimeOfDay() const noexcept
Definition: Sun.cpp:211
F32 _longitude
Definition: Sun.h:68
Angle::RADIANS< F32 > azimuth
Definition: Sun.h:45
SimpleTime sunsetTime
Definition: Sun.h:42
Angle::DEGREES< F32 > declination
Definition: Sun.h:47
SimpleTime sunriseTime
Definition: Sun.h:41
Angle::RADIANS< F32 > altitude
Definition: Sun.h:44
SimpleTime noonTime
Definition: Sun.h:43
Angle::DEGREES< F32 > altitudeMax
Definition: Sun.h:46
static D64 CorrectAngle(D64 angleInRadians) noexcept
Definition: Sun.cpp:179
static SunInfo CalculateSunPosition(const struct tm &dateTime, F32 latitude, F32 longitude)
Definition: Sun.cpp:86