diff --git a/DynObj.cpp b/DynObj.cpp
index 6e49fb7d..18784aeb 100644
--- a/DynObj.cpp
+++ b/DynObj.cpp
@@ -3807,9 +3807,26 @@ void TDynamicObject::Render()
}
else
{ // wersja Display Lists
- if (mdLowPolyInt)
- if (FreeFlyModeFlag ? true : !mdKabina || !bDisplayCab)
- mdLowPolyInt->Render(ObjSqrDist, ReplacableSkinID, iAlpha);
+ if( mdLowPolyInt ) {
+ // low poly interior
+ if( FreeFlyModeFlag ? true : !mdKabina || !bDisplayCab ) {
+ // enable cab light if needed
+ if( InteriorLightLevel > 0.0f ) {
+
+ // crude way to light the cabin, until we have something more complete in place
+ auto const cablight = InteriorLight * InteriorLightLevel;
+ ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, &cablight.x );
+ }
+
+ mdLowPolyInt->Render( ObjSqrDist, ReplacableSkinID, iAlpha );
+
+ if( InteriorLightLevel > 0.0f ) {
+ // reset the overall ambient
+ GLfloat ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, ambient );
+ }
+ }
+ }
mdModel->Render(ObjSqrDist, ReplacableSkinID, iAlpha);
if (mdLoad) // renderowanie nieprzezroczystego ładunku
mdLoad->Render(ObjSqrDist, ReplacableSkinID, iAlpha);
diff --git a/DynObj.h b/DynObj.h
index bda873a7..2c675cc0 100644
--- a/DynObj.h
+++ b/DynObj.h
@@ -140,11 +140,10 @@ class TAnim
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
-class TDynamicObject
-{ // klasa pojazdu
- private: // położenie pojazdu w świecie oraz parametry ruchu
+class TDynamicObject { // klasa pojazdu
+private: // położenie pojazdu w świecie oraz parametry ruchu
vector3 vPosition; // Ra: pozycja pojazdu liczona zaraz po przesunięciu
- vector3 vCoulpler[2]; // współrzędne sprzęgów do liczenia zderzeń czołowych
+ vector3 vCoulpler[ 2 ]; // współrzędne sprzęgów do liczenia zderzeń czołowych
vector3 vUp, vFront, vLeft; // wektory jednostkowe ustawienia pojazdu
int iDirection; // kierunek pojazdu względem czoła składu (1=zgodny,0=przeciwny)
TTrackShape ts; // parametry toru przekazywane do fizyki
@@ -156,10 +155,10 @@ class TDynamicObject
float fAxleDist; // rozstaw wózków albo osi do liczenia proporcji zacienienia
vector3 modelRot; // obrot pudła względem świata - do przeanalizowania, czy potrzebne!!!
// bool bCameraNear; //blisko kamer są potrzebne dodatkowe obliczenia szczegółów
- TDynamicObject * ABuFindNearestObject(TTrack *Track, TDynamicObject *MyPointer,
- int &CouplNr);
+ TDynamicObject * ABuFindNearestObject( TTrack *Track, TDynamicObject *MyPointer,
+ int &CouplNr );
- public: // parametry położenia pojazdu dostępne publicznie
+public: // parametry położenia pojazdu dostępne publicznie
std::string asTrack; // nazwa toru początkowego; wywalić?
std::string asDestination; // dokąd pojazd ma być kierowany "(stacja):(tor)"
matrix4x4 mMatrix; // macierz przekształcenia do renderowania modeli
@@ -175,12 +174,14 @@ class TDynamicObject
private:
// returns type of the nearest functional power source present in the trainset
- public: // modele składowe pojazdu
+public: // modele składowe pojazdu
TModel3d *mdModel; // model pudła
TModel3d *mdLoad; // model zmiennego ładunku
TModel3d *mdPrzedsionek; // model przedsionków dla EZT - może użyć mdLoad zamiast?
TModel3d *mdKabina; // model kabiny dla użytkownika; McZapkie-030303: to z train.h
TModel3d *mdLowPolyInt; // ABu 010305: wnetrze lowpoly
+ float3 InteriorLight{ 0.9f * 255.0f / 255.0f, 0.9f * 216.0f / 255.0f, 0.9f * 176.0f / 255.0f }; // tungsten light. TODO: allow definition of light type?
+ float InteriorLightLevel{ 0.0f }; // current level of interior lighting
float fShade; // zacienienie: 0:normalnie, -1:w ciemności, +1:dodatkowe światło (brak koloru?)
private: // zmienne i metody do animacji submodeli; Ra: sprzatam animacje w pojeździe
diff --git a/Globals.cpp b/Globals.cpp
index 8285f434..3e68f5e7 100644
--- a/Globals.cpp
+++ b/Globals.cpp
@@ -47,6 +47,7 @@ double Global::fOpenGL = 0.0; // wersja OpenGL - do sprawdzania obecności rozsz
bool Global::bOpenGL_1_5 = false; // czy są dostępne funkcje OpenGL 1.5
*/
double Global::fLuminance = 1.0; // jasność światła do automatycznego zapalania
+float Global::SunAngle = 0.0f;
int Global::iReCompile = 0; // zwiększany, gdy trzeba odświeżyć siatki
HWND Global::hWnd = NULL; // uchwyt okna
int Global::ScreenWidth = 1;
diff --git a/Globals.h b/Globals.h
index a9ca3c85..c46932e1 100644
--- a/Globals.h
+++ b/Globals.h
@@ -258,6 +258,7 @@ class Global
static bool bOpenGL_1_5; // czy są dostępne funkcje OpenGL 1.5
*/
static double fLuminance; // jasność światła do automatycznego zapalania
+ static float SunAngle; // angle of the sun relative to horizon
static int iMultiplayer; // blokada działania niektórych eventów na rzecz kominikacji
static HWND hWnd; // uchwyt okna
static int ScreenWidth; // current window dimensions. TODO: move it to renderer
diff --git a/Model3d.cpp b/Model3d.cpp
index eb55533d..3ac52358 100644
--- a/Model3d.cpp
+++ b/Model3d.cpp
@@ -742,7 +742,7 @@ void TSubModel::DisplayLists()
glNewList(uiDisplayList, GL_COMPILE);
GfxRenderer.Bind(0); // tekstury nie ma
glColorMaterial(GL_FRONT, GL_EMISSION);
- glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie blendowaly
+// glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie blendowaly
glBegin(GL_POINTS);
for (int i = 0; i < iNumVerts; i++)
{
@@ -751,7 +751,7 @@ void TSubModel::DisplayLists()
glVertex3fv(&Vertices[i].Point.x);
};
glEnd();
- glEnable(GL_LIGHTING);
+// glEnable(GL_LIGHTING);
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glMaterialfv(GL_FRONT, GL_EMISSION, emm2);
glEndList();
@@ -816,10 +816,13 @@ void TSubModel::InitialRotate(bool doit)
Vertices[i].Point.y = Vertices[i].Point.z;
Vertices[i].Point.z = t;
// wektory normalne również trzeba przekształcić, bo się źle oświetlają
- Vertices[i].Normal.x = -Vertices[i].Normal.x; // zmiana znaku X
- t = Vertices[i].Normal.y; // zamiana Y i Z
- Vertices[i].Normal.y = Vertices[i].Normal.z;
- Vertices[i].Normal.z = t;
+ if( eType != TP_STARS ) {
+ // gwiazdki mają kolory zamiast normalnych, to // ich wtedy nie ruszamy
+ Vertices[ i ].Normal.x = -Vertices[ i ].Normal.x; // zmiana znaku X
+ t = Vertices[ i ].Normal.y; // zamiana Y i Z
+ Vertices[ i ].Normal.y = Vertices[ i ].Normal.z;
+ Vertices[ i ].Normal.z = t;
+ }
}
if (Child)
Child->InitialRotate(doit); // potomne ewentualnie obrócimy
diff --git a/Train.cpp b/Train.cpp
index 66599599..ce35b35c 100644
--- a/Train.cpp
+++ b/Train.cpp
@@ -5001,6 +5001,40 @@ bool TTrain::Update( double const Deltatime )
btHaslerBrakes.Turn(DynamicObject->MoverParameters->BrakePress > 0.4); // ciśnienie w cylindrach
btHaslerCurrent.Turn(DynamicObject->MoverParameters->Im != 0.0); // prąd na silnikach
+ // calculate current level of interior illumination
+ // TODO: organize it along with rest of train update in a more sensible arrangement
+ switch( iCabLightFlag ) // Ra: uzeleżnic od napięcia w obwodzie sterowania
+ { // hunter-091012: uzaleznienie jasnosci od przetwornicy
+ case 0: {
+ //światło wewnętrzne zgaszone
+ DynamicObject->InteriorLightLevel = 0.0f;
+ break;
+ }
+ case 1: {
+ //światło wewnętrzne przygaszone (255 216 176)
+ if( mvOccupied->ConverterFlag == true ) {
+ // jasnosc dla zalaczonej przetwornicy
+ DynamicObject->InteriorLightLevel = 0.75f;
+ }
+ else {
+ DynamicObject->InteriorLightLevel = 0.375f;
+ }
+ break;
+ }
+ case 2: {
+ //światło wewnętrzne zapalone (255 216 176)
+ if( mvOccupied->ConverterFlag ==
+ true ) // jasnosc dla zalaczonej przetwornicy
+ {
+ DynamicObject->InteriorLightLevel = 1.0f;
+ }
+ else {
+ DynamicObject->InteriorLightLevel = 0.5f;
+ }
+ break;
+ }
+ }
+
m_updated = true;
return true; //(DynamicObject->Update(dt));
} // koniec update
diff --git a/World.cpp b/World.cpp
index 025857b8..e216d765 100644
--- a/World.cpp
+++ b/World.cpp
@@ -590,8 +590,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
Ground.Init(Global::SceneryFile, hDC);
// Global::tSinceStart= 0;
- Sun.init();
- Clouds.Init();
+ Environment.init();
WriteLog("Ground init OK");
if (Global::detonatoryOK)
{
@@ -1195,7 +1194,7 @@ bool TWorld::Update()
Global::fClockAngleDeg[4] = 36.0 * (GlobalTime->hh % 10); // jednostki godzin
Global::fClockAngleDeg[5] = 36.0 * (GlobalTime->hh / 10); // dziesiątki godzin
- Update_Lights();
+ Update_Environment();
} // koniec działań niewykonywanych podczas pauzy
// poprzednie jakoś tam działało
double dt = Timer::GetDeltaRenderTime(); // nie uwzględnia pauzowania ani mnożenia czasu
@@ -1433,7 +1432,7 @@ TWorld::Update_Camera( double const Deltatime ) {
}
}
-void TWorld::Update_Lights() {
+void TWorld::Update_Environment() {
#ifdef EU07_USE_OLD_LIGHTING_MODEL
@@ -1532,44 +1531,8 @@ void TWorld::Update_Lights() {
glFogfv( GL_FOG_COLOR, Global::FogColor ); // kolor mgły
}
#else
- Sun.update();
- auto const position = Sun.getPosition();
- // update skydome with current sun position
- SkyDome.Update( position );
- auto const skydomecolour = SkyDome.GetAverageColor();
- auto const skydomehsv = RGBtoHSV( skydomecolour );
- // update sunlight object
- Global::DayLight.position[0] = position.x;
- Global::DayLight.position[1] = position.y;
- Global::DayLight.position[2] = position.z;
-
- Global::DayLight.direction = -1.0 * Sun.getDirection();
-
- auto const intensity = std::min( 0.05f + Sun.getIntensity() + skydomehsv.z, 1.25f );
-
- Global::DayLight.diffuse[ 0 ] = intensity * 255.0f / 255.0f;
- Global::DayLight.diffuse[ 1 ] = intensity * 242.0f / 255.0f;
- Global::DayLight.diffuse[ 2 ] = intensity * 231.0f / 255.0f;
-// Global::DayLight.diffuse[ 3 ] = 1.0f;// std::min( 0.15f + intensity, 1.0f );
- Global::DayLight.ambient[ 0 ] = skydomecolour.x;
- Global::DayLight.ambient[ 1 ] = skydomecolour.y;
- Global::DayLight.ambient[ 2 ] = skydomecolour.z;
-/*
- Global::DayLight.ambient[ 0 ] = 155.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[ 3 ] = 1.0f;
-
- Global::fLuminance = intensity;
-
- Global::FogColor[ 0 ] = skydomecolour.x;
- Global::FogColor[ 1 ] = skydomecolour.y;
- Global::FogColor[ 2 ] = skydomecolour.z;
- glFogfv( GL_FOG_COLOR, Global::FogColor ); // kolor mgły
+ Environment.update();
#endif
-
- glClearColor( skydomecolour.x, skydomecolour.y, skydomecolour.z, 1.0f ); // kolor nieba
}
bool TWorld::Render()
@@ -1588,31 +1551,9 @@ bool TWorld::Render()
glLoadIdentity();
Camera.SetMatrix(); // ustawienie macierzy kamery względem początku scenerii
- if( !Global::bWireFrame ) { // bez nieba w trybie rysowania linii
-
- glDisable( GL_LIGHTING );
- glDisable( GL_FOG );
- glDisable( GL_DEPTH_TEST );
- glDepthMask( GL_FALSE );
- glPushMatrix();
- glTranslatef( Global::pCameraPosition.x, Global::pCameraPosition.y, Global::pCameraPosition.z );
-
- SkyDome.Render();
-// Clouds.Render();
-
-#ifdef EU07_USE_OLD_LIGHTING_MODEL
- glLightfv( GL_LIGHT0, GL_POSITION, Global::lightPos );
-#else
- Sun.render();
- Global::DayLight.apply_angle();
- Global::DayLight.apply_intensity();
-#endif
-
- glPopMatrix();
- glDepthMask( GL_TRUE );
- glEnable( GL_DEPTH_TEST );
- glEnable( GL_FOG );
- glEnable( GL_LIGHTING );
+ if( !Global::bWireFrame ) {
+ // bez nieba w trybie rysowania linii
+ Environment.render();
}
if (Global::bUseVBO)
@@ -1759,7 +1700,7 @@ TWorld::Render_Cab() {
float z = i * i * i * 0.01f;//25/4;
//float C = (36 - i*0.5)*0.005*(1.5 - sqrt(ddl));
float C = ( 36 - i*0.5 )*0.005*sqrt( ( 1 / sqrt( Global::fLuminance + 0.015 ) ) - 1 ) * frontlightstrength;
- glColor4f( C, C, C, 0.35f );// *frontlightstrength );
+ glColor4f( C, C, C, 1.0f );// *frontlightstrength );
glTexCoord2f( 0, 0 ); glVertex3f( -10 / 2 - 2 * i / 4, 6.0 + 0.3*z, 13 + 1.7*z / 3 );
glTexCoord2f( 1, 0 ); glVertex3f( 10 / 2 + 2 * i / 4, 6.0 + 0.3*z, 13 + 1.7*z / 3 );
glTexCoord2f( 1, 1 ); glVertex3f( 10 / 2 + 2 * i / 4, -5.0 - 0.5*z, 13 + 1.7*z / 3 );
@@ -1880,6 +1821,13 @@ TWorld::Render_Cab() {
glLightfv( GL_LIGHT0, GL_AMBIENT, ambientCabLight );
glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuseCabLight );
glLightfv( GL_LIGHT0, GL_SPECULAR, specularCabLight );
+#else
+ if( dynamic->InteriorLightLevel > 0.0f ) {
+
+ // crude way to light the cabin, until we have something more complete in place
+ auto const cablight = dynamic->InteriorLight * dynamic->InteriorLightLevel;
+ ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, &cablight.x );
+ }
#endif
if( Global::bUseVBO ) { // renderowanie z użyciem VBO
dynamic->mdKabina->RaRender( 0.0, dynamic->ReplacableSkinID, dynamic->iAlpha );
@@ -1895,6 +1843,12 @@ TWorld::Render_Cab() {
glLightfv( GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight );
glLightfv( GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight );
glLightfv( GL_LIGHT0, GL_SPECULAR, Global::specularDayLight );
+#else
+ if( dynamic->InteriorLightLevel > 0.0f ) {
+ // reset the overall ambient
+ GLfloat ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, ambient );
+ }
#endif
}
glPopMatrix();
@@ -2365,6 +2319,8 @@ TWorld::Render_UI() {
" " +
std::string( "S SEE NEN NWW SW" )
.substr( 1 + 2 * floor( fmod( 8 + ( Camera.Yaw + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 );
+ // current luminance level
+ OutText2 = "Light level: " + to_string( Global::fLuminance, 3 );
}
// OutText3= AnsiString(" Online documentation (PL, ENG, DE, soon CZ):
// http://www.eu07.pl");
@@ -3060,3 +3016,81 @@ void TWorld::CabChange(TDynamicObject *old, TDynamicObject *now)
Global::changeDynObj = now; // uruchomienie protezy
};
//---------------------------------------------------------------------------
+
+void
+world_environment::init() {
+
+ m_sun.init();
+ m_stars.init();
+ m_clouds.Init();
+}
+
+void
+world_environment::update() {
+
+ // move sun...
+ m_sun.update();
+ auto const position = m_sun.getPosition();
+ // ...update the global data to match new sun state...
+ Global::SunAngle = m_sun.getAngle();
+ Global::DayLight.position[ 0 ] = position.x;
+ Global::DayLight.position[ 1 ] = position.y;
+ Global::DayLight.position[ 2 ] = position.z;
+ Global::DayLight.direction = -1.0 * m_sun.getDirection();
+ // ...update skydome to match the current sun position as well...
+ m_skydome.Update( position );
+ // ...retrieve current sky colour and brightness...
+ auto const skydomecolour = m_skydome.GetAverageColor();
+ auto const skydomehsv = RGBtoHSV( skydomecolour );
+ auto const intensity = std::min( 0.05f + m_sun.getIntensity() + skydomehsv.z, 1.25f );
+ // ...update light colours and intensity.
+ // NOTE: intensity combines intensity of the sun and the light reflected by the sky dome
+ // it'd be more technically correct to have just the intensity of the sun here,
+ // but whether it'd _look_ better is something to be tested
+ Global::DayLight.diffuse[ 0 ] = intensity * 255.0f / 255.0f;
+ Global::DayLight.diffuse[ 1 ] = intensity * 242.0f / 255.0f;
+ Global::DayLight.diffuse[ 2 ] = intensity * 231.0f / 255.0f;
+
+ Global::DayLight.ambient[ 0 ] = skydomecolour.x;
+ Global::DayLight.ambient[ 1 ] = skydomecolour.y;
+ Global::DayLight.ambient[ 2 ] = skydomecolour.z;
+
+ Global::fLuminance = intensity;
+
+ // update the fog. setting it to match the average colour of the sky dome is cheap
+ // but quite effective way to make the distant items blend with background better
+ Global::FogColor[ 0 ] = skydomecolour.x;
+ Global::FogColor[ 1 ] = skydomecolour.y;
+ Global::FogColor[ 2 ] = skydomecolour.z;
+ ::glFogfv( GL_FOG_COLOR, Global::FogColor ); // kolor mgły
+
+ ::glClearColor( skydomecolour.x, skydomecolour.y, skydomecolour.z, 1.0f ); // kolor nieba
+}
+
+void
+world_environment::render() {
+
+ ::glDisable( GL_LIGHTING );
+ ::glDisable( GL_FOG );
+ ::glDisable( GL_DEPTH_TEST );
+ ::glDepthMask( GL_FALSE );
+ ::glPushMatrix();
+ ::glTranslatef( Global::pCameraPosition.x, Global::pCameraPosition.y, Global::pCameraPosition.z );
+
+ m_skydome.Render();
+ m_stars.render();
+// m_clouds.Render();
+
+ if( DebugModeFlag == true ) {
+ // mark sun position for easier debugging
+ m_sun.render();
+ }
+ Global::DayLight.apply_angle();
+ Global::DayLight.apply_intensity();
+
+ ::glPopMatrix();
+ ::glDepthMask( GL_TRUE );
+ ::glEnable( GL_DEPTH_TEST );
+ ::glEnable( GL_FOG );
+ ::glEnable( GL_LIGHTING );
+}
diff --git a/World.h b/World.h
index 7a409460..eb5f3dde 100644
--- a/World.h
+++ b/World.h
@@ -14,9 +14,25 @@ http://mozilla.org/MPL/2.0/.
#include "Ground.h"
#include "sky.h"
#include "sun.h"
+#include "stars.h"
#include "skydome.h"
#include "mczapkie/mover.h"
+// wrapper for environment elements -- sky, sun, stars, clouds etc
+class world_environment {
+
+public:
+ void init();
+ void update();
+ void render();
+
+private:
+ CSkyDome m_skydome;
+ cStars m_stars;
+ cSun m_sun;
+ TSky m_clouds;
+};
+
class TWorld
{
void InOutKey();
@@ -42,21 +58,19 @@ class TWorld
std::string OutText2;
std::string OutText3;
std::string OutText4;
- void Update_Lights();
+ void Update_Environment();
void Update_Camera( const double Deltatime );
bool Render();
void Render_Cab();
void Render_UI();
TCamera Camera;
TGround Ground;
+ world_environment Environment;
TTrain *Train;
TDynamicObject *pDynamicNearest;
bool Paused;
GLuint base; // numer DL dla znaków w napisach
texture_manager::size_type light; // numer tekstury dla smugi
- TSky Clouds;
- CSkyDome SkyDome;
- cSun Sun;
TEvent *KeyEvents[10]; // eventy wyzwalane z klawiaury
TMoverParameters *mvControlled; // wskaźnik na człon silnikowy, do wyświetlania jego parametrów
int iCheckFPS; // kiedy znów sprawdzić FPS, żeby wyłączać optymalizacji od razu do zera
@@ -72,5 +86,6 @@ class TWorld
void CreateE3D(std::string const &dir = "", bool dyn = false);
void CabChange(TDynamicObject *old, TDynamicObject *now);
};
+
//---------------------------------------------------------------------------
diff --git a/color.h b/color.h
index e3e879e8..68890616 100644
--- a/color.h
+++ b/color.h
@@ -7,9 +7,9 @@ float3
XYZtoRGB( float3 const &XYZ ) {
// M^-1 for Adobe RGB from http://www.brucelindbloom.com/Eqn_RGB_XYZ_Matrix.html
-// float const mi[ 3 ][ 3 ] = { 2.041369, -0.969266, 0.0134474, -0.5649464, 1.8760108, -0.1183897, -0.3446944, 0.041556, 1.0154096 };
+ float const mi[ 3 ][ 3 ] = { 2.041369, -0.969266, 0.0134474, -0.5649464, 1.8760108, -0.1183897, -0.3446944, 0.041556, 1.0154096 };
// m^-1 for sRGB:
- float const mi[ 3 ][ 3 ] = { 3.240479, -0.969256, 0.055648, -1.53715, 1.875991, -0.204043, -0.49853, 0.041556, 1.057311 };
+// float const mi[ 3 ][ 3 ] = { 3.240479, -0.969256, 0.055648, -1.53715, 1.875991, -0.204043, -0.49853, 0.041556, 1.057311 };
return float3{
XYZ.x*mi[ 0 ][ 0 ] + XYZ.y*mi[ 1 ][ 0 ] + XYZ.z*mi[ 2 ][ 0 ],
diff --git a/maszyna.vcxproj b/maszyna.vcxproj
index be008947..3cd10c56 100644
--- a/maszyna.vcxproj
+++ b/maszyna.vcxproj
@@ -126,6 +126,7 @@
+
Create
Create
@@ -191,6 +192,7 @@
+
diff --git a/maszyna.vcxproj.filters b/maszyna.vcxproj.filters
index 4b343051..e38ea0db 100644
--- a/maszyna.vcxproj.filters
+++ b/maszyna.vcxproj.filters
@@ -198,6 +198,9 @@
Source Files
+
+ Source Files
+
@@ -386,6 +389,9 @@
Header Files
+
+ Header Files
+
diff --git a/skydome.cpp b/skydome.cpp
index c84113c5..34c0d96f 100644
--- a/skydome.cpp
+++ b/skydome.cpp
@@ -1,16 +1,11 @@
-//******************************************************************************//
-// NightShine Engine //
-// Sky : Gradient SkyDome Class //
-//******************************************************************************//
-// sky gradient based on "A practical analytic model for daylight"
-// by A. J. Preetham Peter Shirley Brian Smits (University of Utah)
#include "stdafx.h"
#include "opengl/glew.h"
#include "skydome.h"
#include "color.h"
-//******************************************************************************//
+// sky gradient based on "A practical analytic model for daylight"
+// by A. J. Preetham Peter Shirley Brian Smits (University of Utah)
float CSkyDome::m_distributionluminance[ 5 ][ 2 ] = { // Perez distributions
{ 0.17872f , -1.46303f }, // a = darkening or brightening of the horizon
@@ -316,6 +311,7 @@ void CSkyDome::RebuildColors() {
color.z = 0.75f * std::max( color.z + m_sundirection.y, 0.075f );
color.x = 0.20f * color.z;
color.y = 0.65f * color.z;
+ color = color * ( 1.15f - vertex.y ); // simple gradient, darkening towards the top
}
// save
diff --git a/stars.cpp b/stars.cpp
new file mode 100644
index 00000000..451d6aa0
--- /dev/null
+++ b/stars.cpp
@@ -0,0 +1,28 @@
+
+#include "stdafx.h"
+#include "stars.h"
+#include "globals.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// cStars -- simple starfield model, simulating appearance of starry sky
+
+void
+cStars::init() {
+
+ m_stars.LoadFromFile( "models\\skydome_stars.t3d", false );
+}
+
+void
+cStars::render() {
+
+ ::glPushMatrix();
+
+ ::glRotatef( m_latitude, 1.0f, 0.0f, 0.0f ); // ustawienie osi OY na północ
+ ::glRotatef( -std::fmod( Global::fTimeAngleDeg, 360.0f ), 0.0f, 1.0f, 0.0f ); // obrót dobowy osi OX
+
+ ::glPointSize( 2.0f );
+ m_stars.Render( 1.0 );
+ ::glPointSize( 3.0f );
+
+ ::glPopMatrix();
+}
\ No newline at end of file
diff --git a/stars.h b/stars.h
new file mode 100644
index 00000000..d5eb7989
--- /dev/null
+++ b/stars.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "Model3d.h"
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// cStars -- simple starfield model, simulating appearance of starry sky
+
+class cStars {
+
+public:
+// types:
+
+// methods:
+ void init();
+ void render();
+
+// constructors:
+
+// deconstructor:
+
+// members:
+
+private:
+// types:
+
+// methods:
+
+// members:
+ float m_longitude{ 19.0f }; // geograpic coordinates hardcoded roughly to Poland location, for the time being
+ float m_latitude{ 52.0f };
+ TModel3d m_stars;
+};