16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-20 07:59:18 +02:00

Merge branch 'milek-dev' into gfx-work

This commit is contained in:
milek7
2018-07-18 13:51:11 +02:00
85 changed files with 3834 additions and 8300 deletions

24
sun.cpp
View File

@@ -4,6 +4,7 @@
#include "mtable.h"
#include "World.h"
#include "utilities.h"
#include "simulationtime.h"
//////////////////////////////////////////////////////////////////////////////////////////
// cSun -- class responsible for dynamic calculation of position and intensity of the Sun,
@@ -20,25 +21,17 @@ cSun::~cSun() { gluDeleteQuadric( sunsphere ); }
void
cSun::init() {
m_observer.timezone = -1.0 * simulation::Time.zone_bias();
sunsphere = gluNewQuadric();
gluQuadricNormals( sunsphere, GLU_SMOOTH );
#ifdef _WIN32
TIME_ZONE_INFORMATION timezoneinfo; // TODO: timezone dependant on geographic location
::GetTimeZoneInformation( &timezoneinfo );
m_observer.timezone = -timezoneinfo.Bias / 60.0f;
#elif __linux__
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
time_t local = mktime(localtime(&ts.tv_sec));
time_t utc = mktime(gmtime(&ts.tv_sec));
m_observer.timezone = (local - utc) / 3600.0f;
#endif
}
void
cSun::update() {
m_observer.temp = Global.AirTemperature;
move();
glm::vec3 position( 0.f, 0.f, -1.f );
position = glm::rotateX( position, glm::radians( static_cast<float>( m_body.elevref ) ) );
@@ -120,7 +113,7 @@ void cSun::move() {
if( m_observer.minute >= 0 ) { localtime.wMinute = m_observer.minute; }
if( m_observer.second >= 0 ) { localtime.wSecond = m_observer.second; }
double ut =
double localut =
localtime.wHour
+ localtime.wMinute / 60.0 // too low resolution, noticeable skips
+ localtime.wSecond / 3600.0; // good enough in normal circumstances
@@ -133,11 +126,10 @@ void cSun::move() {
+ 275 * localtime.wMonth / 9
+ localtime.wDay
- 730530
+ ( ut / 24.0 );
+ ( localut / 24.0 );
// Universal Coordinated (Greenwich standard) time
m_observer.utime = ut * 3600.0;
m_observer.utime = m_observer.utime / 3600.0 - m_observer.timezone;
m_observer.utime = localut - m_observer.timezone;
// perihelion longitude
m_body.phlong = 282.9404 + 4.70935e-5 * daynumber; // w
// orbit eccentricity