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

Merge branch 'tmj-dev'

This commit is contained in:
milek7
2018-02-16 15:25:53 +01:00
113 changed files with 4617 additions and 4057 deletions

46
sun.cpp
View File

@@ -2,8 +2,8 @@
#include "sun.h"
#include "Globals.h"
#include "mtable.h"
#include "usefull.h"
#include "World.h"
#include "utilities.h"
//////////////////////////////////////////////////////////////////////////////////////////
// cSun -- class responsible for dynamic calculation of position and intensity of the Sun,
@@ -40,11 +40,11 @@ void
cSun::update() {
move();
glm::vec3 position( 0.f, 0.f, -2000.f * Global::fDistanceFactor );
glm::vec3 position( 0.f, 0.f, -1.f );
position = glm::rotateX( position, glm::radians( static_cast<float>( m_body.elevref ) ) );
position = glm::rotateY( position, glm::radians( static_cast<float>( -m_body.hrang ) ) );
m_position = position;
m_position = glm::normalize( position );
}
void
@@ -52,21 +52,28 @@ cSun::render() {
::glColor4f( 255.f / 255.f, 242.f / 255.f, 231.f / 255.f, 1.f );
// debug line to locate the sun easier
::glBegin( GL_LINES );
::glVertex3fv( glm::value_ptr( m_position ) );
::glVertex3f( m_position.x, 0.f, m_position.z );
auto const position { m_position * 2000.f };
::glBegin( GL_LINES );
::glVertex3fv( glm::value_ptr( position ) );
::glVertex3f( position.x, 0.f, position.z );
::glEnd();
::glPushMatrix();
::glTranslatef( m_position.x, m_position.y, m_position.z );
::glTranslatef( position.x, position.y, position.z );
// radius is a result of scaling true distance down to 2km -- it's scaled by equal ratio
::gluSphere( sunsphere, m_body.distance * 9.359157, 12, 12 );
::glPopMatrix();
}
/*
glm::vec3
cSun::getPosition() {
return m_position * 1000.f * Global.fDistanceFactor;
}
*/
glm::vec3
cSun::getDirection() {
return glm::normalize( m_position );
return m_position;
}
float
@@ -74,7 +81,14 @@ cSun::getAngle() {
return (float)m_body.elevref;
}
// return current hour angle
double
cSun::getHourAngle() const {
return m_body.hrang;
}
float cSun::getIntensity() {
irradiance();
@@ -117,13 +131,15 @@ 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 = localtime.wHour
double ut =
localtime.wHour
+ localtime.wMinute / 60.0 // too low resolution, noticeable skips
+ localtime.wSecond / 3600.0; // good enough in normal circumstances
/*
+ localtime.wMilliseconds / 3600000.0; // for really smooth movement
*/
double daynumber = 367 * localtime.wYear
/*
+ localtime.wMilliseconds / 3600000.0; // for really smooth movement
*/
double daynumber =
367 * localtime.wYear
- 7 * ( localtime.wYear + ( localtime.wMonth + 9 ) / 12 ) / 4
+ 275 * localtime.wMonth / 9
+ localtime.wDay