Hey,
i’ve decided to give the Unreal Engine a try so that i’ve started working on a plugin the few last weeks, which can be used to compute the positions of various planets in relation to a given position (latitude & longitude) on eath. I’m sure that there are already plugins/extensions available for this purpose but i’ve wanted to try it out by myself (learning by doing).
So far i’ve come up with a C++/C++17 (needed for the necessary precision: double instead of float) plugin which provides the following features:
Position on earth
First of all the positions of the planets are being computed in relation to a given reference position on earth. The first step is setting a valid geo-location (latitude/longitude). This can be done in two ways:
- a custom latitude/longitude,
- a latitude/longitude out of ~120 predefined cities around the world
Time on earth
Besides the position on earth, the positions of the planets ultimately depend on the chosen time on earth.
To make the handling of time zones more convinient for the user, i’ve integrated the fantastic work of GitHub - evansiroky/timezone-boundary-builder: A tool to extract data from Open Street Map (OSM) to build the boundaries of the world's timezones. to determine the time zone.
Combined with the date & time library provided by GitHub - HowardHinnant/date: A date and time library based on the C++11/14/17 <chrono> header the plugin can automatically determine the IANA time zone ID & the UTC hour offset for a given position on earth.
All you have to do is to provide a time zone bundle asset, which contains all the needed information. Such a bundle contains several different information:
- The converted / processed data from the Timezone Boundary Builder
- Selected files from Time Zone Database to be able to compute the UTC hour offset
The plugin comes already with a fully featured time zone bundle asset, which can be used in the following way:
To disable the automatic time zone detection simply clear the “Time Zone Data” and set a custom UTC hour offset
Planetary positions
After setting-up the reference position and the time on earth, the planetary positions can finally be computed. Currently the plugin only supports computations for the moon and the sun. There are a few confgurations for both “planets”
The computation of the sun provides following data:
- Azimuthal coordinates (hour angle, altitude, azimuth)
- Obliquity of the ecliptic
- True longitude
- Mean longitude
- Mean anomaly
- Right ascension
- Declination
- GMST / GMST0 / LST (local sidereal time)
- Local time for the sunset
- Local time for the sunrise Local time for the solar noon
- “Behaviour” of the sun: normal (has sunrise/sunset), always below the horizon, always above the horizon
The computation of the moon provides quite similar data:
- Azimuthal coordinates (hour angle, altitude, azimuth)
- Obliquity of the ecliptic
- True longitude
- Mean longitude
- Mean anomaly
- Right ascension
- Declination
Use in projects
To acutally use the C++ modules i’ve implemented a example day-night-cycle blueprint. In addition to the previously show configurations there are few more regarding the actual simulation setup and the simple debug interface:
During simulation the time & date will automatically increased or decreased, depending on the sign of the simulation speed.
Download (Beta!)