16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 19:49:19 +02:00

build 180210. light source angle calculation tweak

This commit is contained in:
tmj-fstate
2018-02-10 19:54:22 +01:00
parent 0c880f3d4e
commit 6d3ce4908f
4 changed files with 32 additions and 13 deletions

View File

@@ -118,10 +118,11 @@ void cMoon::move() {
if( m_observer.second >= 0 ) { localtime.wSecond = m_observer.second; } 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.wMinute / 60.0; // too low resolution, noticeable skips
+ localtime.wSecond / 3600.0; // good enough in normal circumstances // NOTE: finer resolution disabled to reduce shadow crawl in current implementation
/* /*
+ localtime.wMilliseconds / 3600000.0; // for really smooth movement + localtime.wSecond / 3600.0 // good enough in normal circumstances
+ localtime.wMilliseconds / 3600000.0; // for really smooth movement
*/ */
double daynumber = 367 * localtime.wYear double daynumber = 367 * localtime.wYear
- 7 * ( localtime.wYear + ( localtime.wMonth + 9 ) / 12 ) / 4 - 7 * ( localtime.wYear + ( localtime.wMonth + 9 ) / 12 ) / 4

28
sun.cpp
View File

@@ -50,7 +50,7 @@ void
cSun::update() { cSun::update() {
move(); 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::rotateX( position, glm::radians( static_cast<float>( m_body.elevref ) ) );
position = glm::rotateY( position, glm::radians( static_cast<float>( -m_body.hrang ) ) ); position = glm::rotateY( position, glm::radians( static_cast<float>( -m_body.hrang ) ) );
@@ -72,11 +72,17 @@ cSun::render() {
::gluSphere( sunsphere, m_body.distance * 9.359157, 12, 12 ); ::gluSphere( sunsphere, m_body.distance * 9.359157, 12, 12 );
::glPopMatrix(); ::glPopMatrix();
} }
/*
glm::vec3
cSun::getPosition() {
return m_position * 1000.f * Global.fDistanceFactor;
}
*/
glm::vec3 glm::vec3
cSun::getDirection() { cSun::getDirection() {
return glm::normalize( m_position ); return m_position;
} }
float float
@@ -84,7 +90,14 @@ cSun::getAngle() {
return (float)m_body.elevref; return (float)m_body.elevref;
} }
// return current hour angle
double
cSun::getHourAngle() const {
return m_body.hrang;
}
float cSun::getIntensity() { float cSun::getIntensity() {
irradiance(); irradiance();
@@ -128,10 +141,11 @@ void cSun::move() {
if( m_observer.second >= 0 ) { localtime.wSecond = m_observer.second; } 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.wMinute / 60.0; // too low resolution, noticeable skips
+ localtime.wSecond / 3600.0; // good enough in normal circumstances // NOTE: finer resolution disabled to reduce shadow crawl in current implementation
/* /*
+ localtime.wMilliseconds / 3600000.0; // for really smooth movement + localtime.wSecond / 3600.0 // good enough in normal circumstances
+ localtime.wMilliseconds / 3600000.0; // for really smooth movement
*/ */
double daynumber = 367 * localtime.wYear double daynumber = 367 * localtime.wYear
- 7 * ( localtime.wYear + ( localtime.wMonth + 9 ) / 12 ) / 4 - 7 * ( localtime.wYear + ( localtime.wMonth + 9 ) / 12 ) / 4

8
sun.h
View File

@@ -18,13 +18,17 @@ public:
void init(); void init();
void update(); void update();
void render(); void render();
/*
// returns location of the sun in the 3d scene // returns location of the sun in the 3d scene
glm::vec3 getPosition() { return m_position; } glm::vec3 getPosition();
*/
// returns vector pointing at the sun // returns vector pointing at the sun
glm::vec3 getDirection(); glm::vec3 getDirection();
// returns current elevation above horizon // returns current elevation above horizon
float getAngle(); float getAngle();
// returns current intensity of the sun // return current hour angle
double getHourAngle() const;
// returns current intensity of the sun
float getIntensity(); float getIntensity();
// sets current time, overriding one acquired from the system clock // sets current time, overriding one acquired from the system clock
void setTime( int const Hour, int const Minute, int const Second ); void setTime( int const Hour, int const Minute, int const Second );

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 18 #define VERSION_MAJOR 18
#define VERSION_MINOR 202 #define VERSION_MINOR 210
#define VERSION_REVISION 0 #define VERSION_REVISION 0