mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 17:29:18 +02:00
support for config-specified day of the year
This commit is contained in:
13
Globals.cpp
13
Globals.cpp
@@ -552,18 +552,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
std::tm *localtime = std::localtime(&timenow);
|
std::tm *localtime = std::localtime(&timenow);
|
||||||
Global::fMoveLight = localtime->tm_yday + 1; // numer bieżącego dnia w roku
|
Global::fMoveLight = localtime->tm_yday + 1; // numer bieżącego dnia w roku
|
||||||
}
|
}
|
||||||
if (fMoveLight > 0.f) // tu jest nadal zwiększone o 1
|
// TODO: calculate lights single time here for static setup. or get rid of static setup
|
||||||
{ // obliczenie deklinacji wg:
|
|
||||||
// http://naturalfrequency.com/Tregenza_Sharples/Daylight_Algorithms/algorithm_1_11.htm
|
|
||||||
// Spencer J W Fourier series representation of the position of the sun Search 2 (5)
|
|
||||||
// 172 (1971)
|
|
||||||
Global::fMoveLight =
|
|
||||||
M_PI / 182.5 * (Global::fMoveLight - 1.0); // numer dnia w postaci kąta
|
|
||||||
fSunDeclination =
|
|
||||||
0.006918 - 0.3999120 * std::cos(fMoveLight) + 0.0702570 * std::sin(fMoveLight) -
|
|
||||||
0.0067580 * std::cos(2 * fMoveLight) + 0.0009070 * std::sin(2 * fMoveLight) -
|
|
||||||
0.0026970 * std::cos(3 * fMoveLight) + 0.0014800 * std::sin(3 * fMoveLight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (token == "smoothtraction")
|
else if (token == "smoothtraction")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -505,6 +505,11 @@ opengl_texture::set_filtering() {
|
|||||||
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||||
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
||||||
|
|
||||||
|
if( GLEW_EXT_texture_filter_anisotropic ) {
|
||||||
|
// anisotropic filtering
|
||||||
|
::glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0f );
|
||||||
|
}
|
||||||
|
|
||||||
bool sharpen{ false };
|
bool sharpen{ false };
|
||||||
for( auto const &trait : traits ) {
|
for( auto const &trait : traits ) {
|
||||||
|
|
||||||
|
|||||||
@@ -1513,14 +1513,14 @@ void TWorld::Update_Lights() {
|
|||||||
Global::DayLight.position[2] = position.z;
|
Global::DayLight.position[2] = position.z;
|
||||||
auto const direction = -1.0 * Sun.getDirection();
|
auto const direction = -1.0 * Sun.getDirection();
|
||||||
Global::DayLight.direction = direction;
|
Global::DayLight.direction = direction;
|
||||||
auto const intensity = std::min( 2.0f * Sun.getIntensity(), 1.0f );
|
auto const intensity = std::min( 2.0f * Sun.getIntensity(), 1.25f );
|
||||||
|
|
||||||
Global::DayLight.diffuse[ 0 ] = 255.0 / 255.0 * intensity;
|
Global::DayLight.diffuse[ 0 ] = 255.0 / 255.0 * intensity;
|
||||||
Global::DayLight.diffuse[ 1 ] = 242.0 / 255.0 * intensity;
|
Global::DayLight.diffuse[ 1 ] = 242.0 / 255.0 * intensity;
|
||||||
Global::DayLight.diffuse[ 2 ] = 231.0 / 255.0 * intensity;
|
Global::DayLight.diffuse[ 2 ] = 231.0 / 255.0 * intensity;
|
||||||
// Global::DayLight.diffuse[ 3 ] = 1.0f;// std::min( 0.15f + intensity, 1.0f );
|
// Global::DayLight.diffuse[ 3 ] = 1.0f;// std::min( 0.15f + intensity, 1.0f );
|
||||||
Global::DayLight.ambient[ 0 ] = 205.0 / 255.0 * intensity * 0.75f;
|
Global::DayLight.ambient[ 0 ] = 155.0 / 255.0 * intensity * 0.75f;
|
||||||
Global::DayLight.ambient[ 1 ] = 217.0 / 255.0 * intensity * 0.75f;
|
Global::DayLight.ambient[ 1 ] = 192.0 / 255.0 * intensity * 0.75f;
|
||||||
Global::DayLight.ambient[ 2 ] = 231.0 / 255.0 * intensity * 0.75f;
|
Global::DayLight.ambient[ 2 ] = 231.0 / 255.0 * intensity * 0.75f;
|
||||||
// Global::DayLight.ambient[ 3 ] = 1.0f;
|
// Global::DayLight.ambient[ 3 ] = 1.0f;
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ cParser::~cParser()
|
|||||||
// methods
|
// methods
|
||||||
bool cParser::getTokens(int Count, bool ToLower, const char *Break)
|
bool cParser::getTokens(int Count, bool ToLower, const char *Break)
|
||||||
{
|
{
|
||||||
|
tokens.clear(); // emulates old parser behaviour. TODO, TBD: allow manual reset?
|
||||||
/*
|
/*
|
||||||
if (LoadTraction==true)
|
if (LoadTraction==true)
|
||||||
trtest="niemaproblema"; //wczytywać
|
trtest="niemaproblema"; //wczytywać
|
||||||
|
|||||||
20
sun.cpp
20
sun.cpp
@@ -285,13 +285,33 @@ int cSun::yearday( int Day, const int Month, const int Year ) {
|
|||||||
return Day;
|
return Day;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cSun::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday ) {
|
||||||
|
|
||||||
|
WORD daytab[ 2 ][ 13 ] = {
|
||||||
|
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
|
||||||
|
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
|
||||||
|
};
|
||||||
|
|
||||||
|
int leap = ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 );
|
||||||
|
WORD idx = 1;
|
||||||
|
while( (idx < 13) && ( Yearday <= daytab[ leap ][ idx ] )) {
|
||||||
|
|
||||||
|
++idx;
|
||||||
|
}
|
||||||
|
Month = idx + 1;
|
||||||
|
Day = Yearday - daytab[ leap ][ idx ];
|
||||||
|
}
|
||||||
|
|
||||||
// obtains current time for calculations
|
// obtains current time for calculations
|
||||||
void
|
void
|
||||||
cSun::time( SYSTEMTIME *Time ) {
|
cSun::time( SYSTEMTIME *Time ) {
|
||||||
|
|
||||||
::GetLocalTime( Time );
|
::GetLocalTime( Time );
|
||||||
// NOTE: we're currently using local time to determine day/month/year
|
// NOTE: we're currently using local time to determine day/month/year
|
||||||
|
if( Global::fMoveLight > 0.0 ) {
|
||||||
// TODO: enter scenario-defined day/month/year instead.
|
// TODO: enter scenario-defined day/month/year instead.
|
||||||
|
daymonth( Time->wDay, Time->wMonth, Time->wYear, static_cast<WORD>(Global::fMoveLight) );
|
||||||
|
}
|
||||||
Time->wHour = GlobalTime->hh;
|
Time->wHour = GlobalTime->hh;
|
||||||
Time->wMinute = GlobalTime->mm;
|
Time->wMinute = GlobalTime->mm;
|
||||||
Time->wSecond = std::floor( GlobalTime->mr );
|
Time->wSecond = std::floor( GlobalTime->mr );
|
||||||
|
|||||||
2
sun.h
2
sun.h
@@ -54,6 +54,8 @@ protected:
|
|||||||
void irradiance();
|
void irradiance();
|
||||||
// calculates day of year from given date
|
// calculates day of year from given date
|
||||||
int yearday( int Day, int const Month, int const Year );
|
int yearday( int Day, int const Month, int const Year );
|
||||||
|
// calculates day and month from given day of year
|
||||||
|
void daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday );
|
||||||
// obtains current time for calculations
|
// obtains current time for calculations
|
||||||
void time( SYSTEMTIME *Time );
|
void time( SYSTEMTIME *Time );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user