mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 07:39:19 +02:00
light beam strength based on number of active lights, \r recognition in the parser, proper (lack) of depth test for the UI
This commit is contained in:
53
World.cpp
53
World.cpp
@@ -1252,11 +1252,15 @@ bool TWorld::Update()
|
||||
|
||||
// przy 0.25 smuga gaśnie o 6:37 w Quarku, a mogłaby już 5:40
|
||||
// Ra 2014-12: przy 0.15 się skarżyli, że nie widać smug => zmieniłem na 0.25
|
||||
// changed light activation threshold to 0.5, paired with strength reduction in daylight
|
||||
if (Train) // jeśli nie usunięty
|
||||
Global::bSmudge =
|
||||
FreeFlyModeFlag ? false : ((Train->Dynamic()->fShade <= 0.0) ?
|
||||
(Global::fLuminance <= 0.25) :
|
||||
(Train->Dynamic()->fShade * Global::fLuminance <= 0.25));
|
||||
( FreeFlyModeFlag ?
|
||||
false :
|
||||
( Train->Dynamic()->fShade <= 0.0 ?
|
||||
(Global::fLuminance <= 0.5) :
|
||||
(Train->Dynamic()->fShade * Global::fLuminance <= 0.5) ) );
|
||||
|
||||
if (!Render())
|
||||
return false;
|
||||
|
||||
@@ -1496,6 +1500,7 @@ bool TWorld::Render()
|
||||
glColor3b(255, 255, 255);
|
||||
// glColor3b(255, 0, 255);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDepthFunc( GL_LEQUAL );
|
||||
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
|
||||
glLoadIdentity();
|
||||
Camera.SetMatrix(); // ustawienie macierzy kamery względem początku scenerii
|
||||
@@ -1575,20 +1580,36 @@ TWorld::Render_Cab() {
|
||||
// 1. warunek na smugę wyznaczyc wcześniej
|
||||
// 2. jeśli smuga włączona, nie renderować pojazdu użytkownika w DynObj
|
||||
// 3. jeśli smuga właczona, wyrenderować pojazd użytkownia po dodaniu smugi do sceny
|
||||
if( Train->Controlled()->Battery ) { // trochę na skróty z tą baterią
|
||||
auto const &frontlights = Train->Controlled()->iLights[ 0 ];
|
||||
float frontlightstrength = 0.f +
|
||||
( ( frontlights & 1 ) ? 0.3f : 0.f ) +
|
||||
( ( frontlights & 4 ) ? 0.3f : 0.f ) +
|
||||
( ( frontlights & 16 ) ? 0.3f : 0.f );
|
||||
frontlightstrength = std::max( frontlightstrength - Global::fLuminance, 0.0 );
|
||||
auto const &rearlights = Train->Controlled()->iLights[ 1 ];
|
||||
float rearlightstrength = 0.f +
|
||||
( ( rearlights & 1 ) ? 0.3f : 0.f ) +
|
||||
( ( rearlights & 4 ) ? 0.3f : 0.f ) +
|
||||
( ( rearlights & 16 ) ? 0.3f : 0.f );
|
||||
rearlightstrength = std::max( rearlightstrength - Global::fLuminance, 0.0 );
|
||||
|
||||
if( ( Train->Controlled()->Battery ) // trochę na skróty z tą baterią
|
||||
&& ( ( frontlightstrength > 0.f )
|
||||
|| ( rearlightstrength > 0.f ) ) ) {
|
||||
|
||||
if( Global::bOldSmudge == true ) {
|
||||
glBlendFunc( GL_ONE_MINUS_SRC_ALPHA, GL_ONE );
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
|
||||
// glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_DST_COLOR);
|
||||
// glBlendFunc(GL_SRC_ALPHA_SATURATE,GL_ONE);
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
glDisable( GL_LIGHTING );
|
||||
glDisable( GL_FOG );
|
||||
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
glBindTexture( GL_TEXTURE_2D, light ); // Select our texture
|
||||
glBegin( GL_QUADS );
|
||||
float fSmudge =
|
||||
dynamic->MoverParameters->DimHalf.y + 7; // gdzie zaczynać smugę
|
||||
if( Train->Controlled()->iLights[ 0 ] & 21 ) { // wystarczy jeden zapalony z przodu
|
||||
if( frontlightstrength > 0.f ) { // wystarczy jeden zapalony z przodu
|
||||
glColor4f( 1.0f, 1.0f, 1.0f, 0.5f * frontlightstrength );
|
||||
glTexCoord2f( 0, 0 );
|
||||
glVertex3f( 15.0, 0.0, +fSmudge ); // rysowanie względem położenia modelu
|
||||
glTexCoord2f( 1, 0 );
|
||||
@@ -1598,7 +1619,8 @@ TWorld::Render_Cab() {
|
||||
glTexCoord2f( 0, 1 );
|
||||
glVertex3f( 15.0, 2.5, 250.0 );
|
||||
}
|
||||
if( Train->Controlled()->iLights[ 1 ] & 21 ) { // wystarczy jeden zapalony z tyłu
|
||||
if( rearlightstrength > 0.f ) { // wystarczy jeden zapalony z tyłu
|
||||
glColor4f( 1.0f, 1.0f, 1.0f, 0.5f * rearlightstrength );
|
||||
glTexCoord2f( 0, 0 );
|
||||
glVertex3f( -15.0, 0.0, -fSmudge );
|
||||
glTexCoord2f( 1, 0 );
|
||||
@@ -1616,6 +1638,7 @@ TWorld::Render_Cab() {
|
||||
glEnable( GL_FOG );
|
||||
}
|
||||
else {
|
||||
|
||||
glBlendFunc( GL_DST_COLOR, GL_ONE );
|
||||
glDepthFunc( GL_GEQUAL );
|
||||
glAlphaFunc( GL_GREATER, 0.004 );
|
||||
@@ -1627,23 +1650,24 @@ TWorld::Render_Cab() {
|
||||
//float ddl = (0.15*Global::diffuseDayLight[0]+0.295*Global::diffuseDayLight[1]+0.055*Global::diffuseDayLight[2]); //0.24:0
|
||||
glBegin( GL_QUADS );
|
||||
float fSmudge = dynamic->MoverParameters->DimHalf.y + 7; // gdzie zaczynać smugę
|
||||
if( Train->Controlled()->iLights[ 0 ] & 21 ) { // wystarczy jeden zapalony z przodu
|
||||
if( frontlightstrength > 0.f ) { // wystarczy jeden zapalony z przodu
|
||||
|
||||
for( int i = 15; i <= 35; i++ ) {
|
||||
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 );
|
||||
glColor4f( C, C, C, 0.25f );
|
||||
float C = ( 36 - i*0.5 )*0.005*sqrt( ( 1 / sqrt( Global::fLuminance + 0.015 ) ) - 1 ) * frontlightstrength;
|
||||
glColor4f( C, C, C, 0.35f );// *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 );
|
||||
glTexCoord2f( 0, 1 ); glVertex3f( -10 / 2 - 2 * i / 4, -5.0 - 0.5*z, 13 + 1.7*z / 3 );
|
||||
}
|
||||
}
|
||||
if( Train->Controlled()->iLights[ 1 ] & 21 ) { // wystarczy jeden zapalony z tyłu
|
||||
if( rearlightstrength > 0.f ) { // wystarczy jeden zapalony z tyłu
|
||||
for( int i = 15; i <= 35; i++ ) {
|
||||
float z = i * i * i * 0.01f;//25/4;
|
||||
float C = ( 36 - i*0.5 )*0.005*sqrt( ( 1 / sqrt( Global::fLuminance + 0.015 ) ) - 1 );
|
||||
glColor4f( C, C, C, 0.25f );
|
||||
float C = ( 36 - i*0.5 )*0.005*sqrt( ( 1 / sqrt( Global::fLuminance + 0.015 ) ) - 1 ) * rearlightstrength;
|
||||
glColor4f( C, C, C, 0.35f );// *rearlightstrength );
|
||||
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 );
|
||||
@@ -1917,6 +1941,7 @@ TWorld::Render_UI() {
|
||||
Global::changeDynObj = NULL;
|
||||
}
|
||||
|
||||
glDepthFunc( GL_ALWAYS );
|
||||
glDisable( GL_LIGHTING );
|
||||
if( Controlled )
|
||||
SetWindowText( hWnd, Controlled->MoverParameters->Name.c_str() );
|
||||
|
||||
6
parser.h
6
parser.h
@@ -77,7 +77,7 @@ class cParser //: public std::stringstream
|
||||
{
|
||||
return !mStream->fail();
|
||||
};
|
||||
bool getTokens(int Count = 1, bool ToLower = true, const char *Break = "\n\t ;");
|
||||
bool getTokens(int Count = 1, bool ToLower = true, const char *Break = "\n\r\t ;");
|
||||
// returns percentage of file processed so far
|
||||
int getProgress() const;
|
||||
// add custom definition of text which should be ignored when retrieving tokens
|
||||
@@ -85,9 +85,9 @@ class cParser //: public std::stringstream
|
||||
|
||||
private:
|
||||
// methods:
|
||||
std::string readToken(bool ToLower = true, const char *Break = "\n\t ;");
|
||||
std::string readToken(bool ToLower = true, const char *Break = "\n\r\t ;");
|
||||
std::string readQuotes( char const Quote = '\"' );
|
||||
std::string readComment( std::string const &Break = "\n\t ;" );
|
||||
std::string readComment( std::string const &Break = "\n\r\t ;" );
|
||||
// std::string trtest;
|
||||
bool findQuotes( std::string &String );
|
||||
bool trimComments( std::string &String );
|
||||
|
||||
Reference in New Issue
Block a user