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

build 181001. texture size definition, fog influence on skydome, minor vehicle logic bug fixes

This commit is contained in:
tmj-fstate
2018-10-01 15:54:46 +02:00
parent 467d46eba2
commit 913541bbee
14 changed files with 142 additions and 80 deletions

View File

@@ -962,7 +962,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// perform loading/unloading // perform loading/unloading
auto const platformside = static_cast<int>( std::floor( std::abs( sSpeedTable[ i ].evEvent->input_value( 2 ) ) ) ) % 10; auto const platformside = static_cast<int>( std::floor( std::abs( sSpeedTable[ i ].evEvent->input_value( 2 ) ) ) ) % 10;
auto const exchangetime = simulation::Station.update_load( pVehicles[ 0 ], *TrainParams, platformside ); auto const exchangetime = std::max( 5.0, simulation::Station.update_load( pVehicles[ 0 ], *TrainParams, platformside ) );
WaitingSet( std::max( -fStopTime, exchangetime ) ); // na końcu rozkładu się ustawia 60s i tu by było skrócenie WaitingSet( std::max( -fStopTime, exchangetime ) ); // na końcu rozkładu się ustawia 60s i tu by było skrócenie
if( TrainParams->CheckTrainLatency() < 0.0 ) { if( TrainParams->CheckTrainLatency() < 0.0 ) {

View File

@@ -3971,9 +3971,15 @@ void TDynamicObject::RenderSounds() {
sSmallCompressor.stop(); sSmallCompressor.stop();
} }
// heating sound // heater sound
if( MoverParameters->Heating ) { if( ( true == MoverParameters->Heating )
sHeater.play( sound_flags::exclusive | sound_flags::looping ); && ( std::abs( MoverParameters->enrot ) > 0.01 ) ) {
// TBD: check whether heating should depend on 'engine rotations' for electric vehicles
sHeater
.pitch( true == sHeater.is_combined() ?
std::abs( MoverParameters->enrot ) * 60.f * 0.01f :
1.f )
.play( sound_flags::exclusive | sound_flags::looping );
} }
else { else {
sHeater.stop(); sHeater.stop();
@@ -3997,8 +4003,7 @@ void TDynamicObject::RenderSounds() {
} }
else if( quantizedratiochange < 0 ) { else if( quantizedratiochange < 0 ) {
m_brakecylinderpistonrecede m_brakecylinderpistonrecede
.pitch( .pitch( true == m_brakecylinderpistonrecede.is_combined() ?
true == m_brakecylinderpistonrecede.is_combined() ?
quantizedratio * 0.01f : quantizedratio * 0.01f :
m_brakecylinderpistonrecede.m_frequencyoffset + m_brakecylinderpistonrecede.m_frequencyfactor * 1.f ) m_brakecylinderpistonrecede.m_frequencyoffset + m_brakecylinderpistonrecede.m_frequencyfactor * 1.f )
.play(); .play();

View File

@@ -1570,11 +1570,12 @@ void TMoverParameters::OilPumpCheck( double const Timestep ) {
OilPump.is_active = ( OilPump.is_active = (
( true == Battery ) ( true == Battery )
&& ( false == Mains )
&& ( false == OilPump.is_disabled ) && ( false == OilPump.is_disabled )
&& ( ( OilPump.is_active ) && ( ( OilPump.is_active )
|| ( OilPump.start_type == start_t::manual ? ( OilPump.is_enabled ) : || ( OilPump.start_type == start_t::manual ? ( OilPump.is_enabled ) :
OilPump.start_type == start_t::automatic ? ( dizel_startup || Mains ) : OilPump.start_type == start_t::automatic ? ( dizel_startup ) :
OilPump.start_type == start_t::manualwithautofallback ? ( OilPump.is_enabled || dizel_startup || Mains ) : OilPump.start_type == start_t::manualwithautofallback ? ( OilPump.is_enabled || dizel_startup ) :
false ) ) ); // shouldn't ever get this far but, eh false ) ) ); // shouldn't ever get this far but, eh
auto const maxrevolutions { auto const maxrevolutions {
@@ -2642,7 +2643,6 @@ bool TMoverParameters::MainSwitch( bool const State, range_t const Notify )
Mains = false; Mains = false;
// potentially knock out the pumps if their switch doesn't force them on // potentially knock out the pumps if their switch doesn't force them on
WaterPump.is_active &= WaterPump.is_enabled; WaterPump.is_active &= WaterPump.is_enabled;
OilPump.is_active &= OilPump.is_enabled;
FuelPump.is_active &= FuelPump.is_enabled; FuelPump.is_active &= FuelPump.is_enabled;
} }
@@ -4765,7 +4765,7 @@ double TMoverParameters::TractionForce( double dt ) {
Voltage = 0; Voltage = 0;
// przekazniki bocznikowania, kazdy inny dla kazdej pozycji // przekazniki bocznikowania, kazdy inny dla kazdej pozycji
if ((MainCtrlPos == 0) || (ShuntMode)) if ((MainCtrlPos == 0) || (ShuntMode) || (false==Mains))
ScndCtrlPos = 0; ScndCtrlPos = 0;
else { else {
@@ -9305,7 +9305,6 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
Mains = false; Mains = false;
// potentially knock out the pumps if their switch doesn't force them on // potentially knock out the pumps if their switch doesn't force them on
WaterPump.is_active &= WaterPump.is_enabled; WaterPump.is_active &= WaterPump.is_enabled;
OilPump.is_active &= OilPump.is_enabled;
FuelPump.is_active &= FuelPump.is_enabled; FuelPump.is_active &= FuelPump.is_enabled;
} }
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );

View File

@@ -135,7 +135,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
iVboPtr = Pos; // pozycja w VBO iVboPtr = Pos; // pozycja w VBO
*/ */
if (!parser.expectToken("type:")) if (!parser.expectToken("type:"))
Error("Model type parse failure!"); ErrorLog("Bad model: expected submodel type definition not found while loading model \"" + Model->NameGet() + "\"" );
{ {
std::string type = parser.getToken<std::string>(); std::string type = parser.getToken<std::string>();
if (type == "mesh") if (type == "mesh")
@@ -1225,8 +1225,10 @@ bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic)
} }
*/ */
auto const name { FileName }; auto const name { FileName };
// cache the file name, in case someone wants it later
m_filename = name;
asBinary = name + ".e3d"; asBinary = name + ".e3d";
if (FileExists(asBinary)) if (FileExists(asBinary))
{ {
LoadFromBinFile(asBinary, dynamic); LoadFromBinFile(asBinary, dynamic);
@@ -1244,8 +1246,6 @@ bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic)
} }
} }
} }
// cache the file name, in case someone wants it later
m_filename = name;
bool const result = bool const result =
Root ? (iSubModelsCount > 0) : false; // brak pliku albo problem z wczytaniem Root ? (iSubModelsCount > 0) : false; // brak pliku albo problem z wczytaniem
if (false == result) if (false == result)

View File

@@ -32,6 +32,10 @@ void render_task::run() {
::glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); ::glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
::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, Global.AnisotropicFiltering );
}
::glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -1.0 ); ::glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -1.0 );
// build texture // build texture
::glTexImage2D( ::glTexImage2D(

119
Track.cpp
View File

@@ -1254,8 +1254,10 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
case tt_Normal: case tt_Normal:
if (m_material2) if (m_material2)
{ // podsypka z podkładami jest tylko dla zwykłego toru { // podsypka z podkładami jest tylko dla zwykłego toru
// potentially retrieve texture length override from the assigned material
auto const texturelength { texture_length( m_material2 ) };
gfx::basic_vertex bpts1[ 8 ]; // punkty głównej płaszczyzny nie przydają się do robienia boków gfx::basic_vertex bpts1[ 8 ]; // punkty głównej płaszczyzny nie przydają się do robienia boków
if( fTexLength == 4.f ) { if( texturelength == 4.f ) {
// stare mapowanie z różną gęstością pikseli i oddzielnymi teksturami na każdy profil // stare mapowanie z różną gęstością pikseli i oddzielnymi teksturami na każdy profil
auto const normalx = std::cos( glm::radians( 75.f ) ); auto const normalx = std::cos( glm::radians( 75.f ) );
auto const normaly = std::sin( glm::radians( 75.f ) ); auto const normaly = std::sin( glm::radians( 75.f ) );
@@ -1318,7 +1320,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
} }
else { else {
// mapowanie proporcjonalne do powierzchni, rozmiar w poprzek określa fTexLength // mapowanie proporcjonalne do powierzchni, rozmiar w poprzek określa fTexLength
auto const max = fTexRatio2 * fTexLength; // szerokość proporcjonalna do długości auto const max = fTexRatio2 * texturelength; // szerokość proporcjonalna do długości
auto const map11 = max > 0.f ? (fHTW + side) / max : 0.25f; // załamanie od strony 1 auto const map11 = max > 0.f ? (fHTW + side) / max : 0.25f; // załamanie od strony 1
auto const map12 = max > 0.f ? (fHTW + side + hypot1) / max : 0.5f; // brzeg od strony 1 auto const map12 = max > 0.f ? (fHTW + side + hypot1) / max : 0.5f; // brzeg od strony 1
if (iTrapezoid) { if (iTrapezoid) {
@@ -1383,7 +1385,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
} }
} }
gfx::vertex_array vertices; gfx::vertex_array vertices;
Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid ? -4 : 4, fTexLength); Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid ? -4 : 4, texturelength);
if( ( Bank != 0 ) && ( true == Geometry2.empty() ) ) { if( ( Bank != 0 ) && ( true == Geometry2.empty() ) ) {
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
} }
@@ -1394,20 +1396,21 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
} }
if (m_material1) if (m_material1)
{ // szyny - generujemy dwie, najwyżej rysować się będzie jedną { // szyny - generujemy dwie, najwyżej rysować się będzie jedną
auto const texturelength { texture_length( m_material1 ) };
gfx::vertex_array vertices; gfx::vertex_array vertices;
if( ( Bank != 0 ) && ( true == Geometry1.empty() ) ) { if( ( Bank != 0 ) && ( true == Geometry1.empty() ) ) {
Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength ); Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, texturelength );
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); // reuse the scratchpad vertices.clear(); // reuse the scratchpad
Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength ); Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, texturelength );
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
} }
if( ( Bank == 0 ) && ( false == Geometry1.empty() ) ) { if( ( Bank == 0 ) && ( false == Geometry1.empty() ) ) {
// special variant, replace existing data for a turntable track // special variant, replace existing data for a turntable track
Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength ); Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, texturelength );
GfxRenderer.Replace( vertices, Geometry1[ 0 ] ); GfxRenderer.Replace( vertices, Geometry1[ 0 ] );
vertices.clear(); // reuse the scratchpad vertices.clear(); // reuse the scratchpad
Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength ); Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, texturelength );
GfxRenderer.Replace( vertices, Geometry1[ 1 ] ); GfxRenderer.Replace( vertices, Geometry1[ 1 ] );
} }
} }
@@ -1452,28 +1455,30 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
{ // nowa wersja z SPKS, ale odwrotnie lewa/prawa { // nowa wersja z SPKS, ale odwrotnie lewa/prawa
gfx::vertex_array vertices; gfx::vertex_array vertices;
if( m_material1 ) { if( m_material1 ) {
auto const texturelength { texture_length( m_material1 ) };
// fixed parts // fixed parts
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, fTexLength ); SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, texturelength );
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, fTexLength, 1.0, bladelength ); SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, texturelength, 1.0, bladelength );
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
// left blade // left blade
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, fTexLength, 1.0, 0, bladelength, SwitchExtension->fOffset2 ); SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, texturelength, 1.0, 0, bladelength, SwitchExtension->fOffset2 );
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
if( m_material2 ) { if( m_material2 ) {
auto const texturelength { texture_length( m_material2 ) };
// fixed parts // fixed parts
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, fTexLength ); SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, texturelength );
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, fTexLength, 1.0, bladelength ); SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, texturelength, 1.0, bladelength );
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
// right blade // right blade
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, fTexLength, 1.0, 0, bladelength, -fMaxOffset + SwitchExtension->fOffset1 ); SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, texturelength, 1.0, 0, bladelength, -fMaxOffset + SwitchExtension->fOffset1 );
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
@@ -1482,28 +1487,30 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
{ // lewa działa lepiej niż prawa { // lewa działa lepiej niż prawa
gfx::vertex_array vertices; gfx::vertex_array vertices;
if( m_material1 ) { if( m_material1 ) {
auto const texturelength { texture_length( m_material1 ) };
// fixed parts // fixed parts
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, fTexLength ); // lewa szyna normalna cała SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, texturelength ); // lewa szyna normalna cała
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, fTexLength, 1.0, bladelength ); // prawa szyna za iglicą SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, texturelength, 1.0, bladelength ); // prawa szyna za iglicą
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
// right blade // right blade
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, fTexLength, 1.0, 0, bladelength, -SwitchExtension->fOffset2 ); SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, texturelength, 1.0, 0, bladelength, -SwitchExtension->fOffset2 );
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
if( m_material2 ) { if( m_material2 ) {
auto const texturelength { texture_length( m_material2 ) };
// fixed parts // fixed parts
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, fTexLength ); // prawa szyna normalnie cała SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, texturelength ); // prawa szyna normalnie cała
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, fTexLength, 1.0, bladelength ); // lewa szyna za iglicą SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, texturelength, 1.0, bladelength ); // lewa szyna za iglicą
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
// left blade // left blade
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, fTexLength, 1.0, 0, bladelength, fMaxOffset - SwitchExtension->fOffset1 ); SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, texturelength, 1.0, 0, bladelength, fMaxOffset - SwitchExtension->fOffset1 );
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
@@ -1521,10 +1528,8 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
gfx::basic_vertex bpts1[4]; // punkty głównej płaszczyzny przydają się do robienia boków gfx::basic_vertex bpts1[4]; // punkty głównej płaszczyzny przydają się do robienia boków
if (m_material1 || m_material2) { if (m_material1 || m_material2) {
// punkty się przydadzą, nawet jeśli nawierzchni nie ma // punkty się przydadzą, nawet jeśli nawierzchni nie ma
/* auto const texturelength { texture_length( m_material1 ) };
double max=2.0*(fHTW>fHTW2?fHTW:fHTW2); //z szerszej strony jest 100% auto const max = fTexRatio1 * texturelength; // test: szerokość proporcjonalna do długości
*/
auto const max = fTexRatio1 * fTexLength; // test: szerokość proporcjonalna do długości
auto const map1 = max > 0.f ? fHTW / max : 0.5f; // obcięcie tekstury od strony 1 auto const map1 = max > 0.f ? fHTW / max : 0.5f; // obcięcie tekstury od strony 1
auto const map2 = max > 0.f ? fHTW2 / max : 0.5f; // obcięcie tekstury od strony 2 auto const map2 = max > 0.f ? fHTW2 / max : 0.5f; // obcięcie tekstury od strony 2
if (iTrapezoid) { if (iTrapezoid) {
@@ -1561,12 +1566,14 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
} }
if (m_material1) // jeśli podana była tekstura, generujemy trójkąty if (m_material1) // jeśli podana była tekstura, generujemy trójkąty
{ // tworzenie trójkątów nawierzchni szosy { // tworzenie trójkątów nawierzchni szosy
auto const texturelength { texture_length( m_material1 ) };
gfx::vertex_array vertices; gfx::vertex_array vertices;
Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid ? -2 : 2, fTexLength); Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid ? -2 : 2, texturelength);
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
} }
if (m_material2) if (m_material2)
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?) { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?)
auto const texturelength { texture_length( m_material2 ) };
gfx::basic_vertex gfx::basic_vertex
rpts1[6], rpts1[6],
rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony
@@ -1629,7 +1636,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
// mapowanie propocjonalne do szerokości chodnika // mapowanie propocjonalne do szerokości chodnika
// krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy // krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy
auto const d = -fTexHeight1 / 3.75f; // krawężnik o wysokości 150mm jest pochylony 40mm auto const d = -fTexHeight1 / 3.75f; // krawężnik o wysokości 150mm jest pochylony 40mm
auto const max = fTexRatio2 * fTexLength; // test: szerokość proporcjonalna do długości auto const max = fTexRatio2 * texturelength; // test: szerokość proporcjonalna do długości
auto const map1l = ( auto const map1l = (
max > 0.f ? max > 0.f ?
side / max : side / max :
@@ -1726,24 +1733,24 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
// odcinka // odcinka
if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) { if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) {
Segment->RenderLoft( vertices, m_origin, rpts1, -3, fTexLength ); // tylko jeśli jest z prawej Segment->RenderLoft( vertices, m_origin, rpts1, -3, texturelength ); // tylko jeśli jest z prawej
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
Segment->RenderLoft( vertices, m_origin, rpts2, -3, fTexLength ); // tylko jeśli jest z lewej Segment->RenderLoft( vertices, m_origin, rpts2, -3, texturelength ); // tylko jeśli jest z lewej
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
} }
else { // pobocza zwykłe, brak przechyłki else { // pobocza zwykłe, brak przechyłki
if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) { if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) {
Segment->RenderLoft( vertices, m_origin, rpts1, 3, fTexLength ); Segment->RenderLoft( vertices, m_origin, rpts1, 3, texturelength );
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
Segment->RenderLoft( vertices, m_origin, rpts2, 3, fTexLength ); Segment->RenderLoft( vertices, m_origin, rpts2, 3, texturelength );
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
@@ -1803,7 +1810,8 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
gfx::basic_vertex bpts1[4]; // punkty głównej płaszczyzny przydają się do robienia boków gfx::basic_vertex bpts1[4]; // punkty głównej płaszczyzny przydają się do robienia boków
if (m_material1 || m_material2) // punkty się przydadzą, nawet jeśli nawierzchni nie ma if (m_material1 || m_material2) // punkty się przydadzą, nawet jeśli nawierzchni nie ma
{ // double max=2.0*(fHTW>fHTW2?fHTW:fHTW2); //z szerszej strony jest 100% { // double max=2.0*(fHTW>fHTW2?fHTW:fHTW2); //z szerszej strony jest 100%
auto const max = fTexRatio1 * fTexLength; // test: szerokość proporcjonalna do długości auto const texturelength { texture_length( m_material1 ) };
auto const max = fTexRatio1 * texturelength; // test: szerokość proporcjonalna do długości
auto const map1 = max > 0.f ? fHTW / max : 0.5f; // obcięcie tekstury od strony 1 auto const map1 = max > 0.f ? fHTW / max : 0.5f; // obcięcie tekstury od strony 1
auto const map2 = max > 0.f ? fHTW2 / max : 0.5f; // obcięcie tekstury od strony 2 auto const map2 = max > 0.f ? fHTW2 / max : 0.5f; // obcięcie tekstury od strony 2
// if (iTrapezoid) //trapez albo przechyłki // if (iTrapezoid) //trapez albo przechyłki
@@ -1833,6 +1841,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
// ale pobocza renderują się później, więc nawierzchnia nie załapuje się na renderowanie w swoim czasie // ale pobocza renderują się później, więc nawierzchnia nie załapuje się na renderowanie w swoim czasie
if( m_material2 ) if( m_material2 )
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?) { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?)
auto const texturelength { texture_length( m_material2 ) };
gfx::basic_vertex gfx::basic_vertex
rpts1[6], rpts1[6],
rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony
@@ -1896,7 +1905,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
// mapowanie propocjonalne do szerokości chodnika // mapowanie propocjonalne do szerokości chodnika
// krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy // krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy
auto const d = -fTexHeight1 / 3.75f; // krawężnik o wysokości 150mm jest pochylony 40mm auto const d = -fTexHeight1 / 3.75f; // krawężnik o wysokości 150mm jest pochylony 40mm
auto const max = fTexRatio2 * fTexLength; // test: szerokość proporcjonalna do długości auto const max = fTexRatio2 * texturelength; // test: szerokość proporcjonalna do długości
auto const map1l = ( auto const map1l = (
max > 0.f ? max > 0.f ?
side / max : side / max :
@@ -1976,22 +1985,22 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
if (SwitchExtension->iRoads == 4) if (SwitchExtension->iRoads == 4)
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render );
if( true == render ) { if( true == render ) {
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
SwitchExtension->Segments[ 3 ]->RenderLoft( vertices, m_origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); SwitchExtension->Segments[ 3 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render );
if( true == render ) { if( true == render ) {
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
SwitchExtension->Segments[ 4 ]->RenderLoft( vertices, m_origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); SwitchExtension->Segments[ 4 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render );
if( true == render ) { if( true == render ) {
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
SwitchExtension->Segments[ 5 ]->RenderLoft( vertices, m_origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); SwitchExtension->Segments[ 5 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render );
if( true == render ) { if( true == render ) {
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
@@ -2001,17 +2010,17 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
else { else {
// punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P2 do P4 SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); // z P2 do P4
if( true == render ) { if( true == render ) {
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P4 do P3=P1 (odwrócony) SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); // z P4 do P3=P1 (odwrócony)
if( true == render ) { if( true == render ) {
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
} }
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P1 do P2 SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); // z P1 do P2
if( true == render ) { if( true == render ) {
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
vertices.clear(); vertices.clear();
@@ -2028,6 +2037,7 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
} }
if( m_material1 ) { if( m_material1 ) {
auto const texturelength { texture_length( m_material1 ) };
gfx::vertex_array vertices; gfx::vertex_array vertices;
// jeśli podana tekstura nawierzchni // jeśli podana tekstura nawierzchni
// we start with a vertex in the middle... // we start with a vertex in the middle...
@@ -2039,8 +2049,8 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
glm::vec3{ 0.0f, 1.0f, 0.0f }, glm::vec3{ 0.0f, 1.0f, 0.0f },
glm::vec2{ 0.5f, 0.5f } ); glm::vec2{ 0.5f, 0.5f } );
// ...and add one extra vertex to close the fan... // ...and add one extra vertex to close the fan...
u = ( SwitchExtension->vPoints[ 0 ].x - oxz.x + m_origin.x ) / fTexLength; u = ( SwitchExtension->vPoints[ 0 ].x - oxz.x + m_origin.x ) / texturelength;
v = ( SwitchExtension->vPoints[ 0 ].z - oxz.z + m_origin.z ) / ( fTexRatio1 * fTexLength ); v = ( SwitchExtension->vPoints[ 0 ].z - oxz.z + m_origin.z ) / ( fTexRatio1 * texturelength );
vertices.emplace_back( vertices.emplace_back(
glm::vec3 { glm::vec3 {
SwitchExtension->vPoints[ 0 ].x, SwitchExtension->vPoints[ 0 ].x,
@@ -2054,8 +2064,8 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
// ...then draw the precalculated rest // ...then draw the precalculated rest
for (int i = pointcount + SwitchExtension->iRoads - 1; i >= 0; --i) { for (int i = pointcount + SwitchExtension->iRoads - 1; i >= 0; --i) {
// mapowanie we współrzędnych scenerii // mapowanie we współrzędnych scenerii
u = ( SwitchExtension->vPoints[ i ].x - oxz.x + m_origin.x ) / fTexLength; u = ( SwitchExtension->vPoints[ i ].x - oxz.x + m_origin.x ) / texturelength;
v = ( SwitchExtension->vPoints[ i ].z - oxz.z + m_origin.z ) / ( fTexRatio1 * fTexLength ); v = ( SwitchExtension->vPoints[ i ].z - oxz.z + m_origin.z ) / ( fTexRatio1 * texturelength );
vertices.emplace_back( vertices.emplace_back(
glm::vec3 { glm::vec3 {
SwitchExtension->vPoints[ i ].x, SwitchExtension->vPoints[ i ].x,
@@ -2507,28 +2517,32 @@ TTrack * TTrack::RaAnimate()
if (SwitchExtension->RightSwitch) if (SwitchExtension->RightSwitch)
{ // nowa wersja z SPKS, ale odwrotnie lewa/prawa { // nowa wersja z SPKS, ale odwrotnie lewa/prawa
if( m_material1 ) { if( m_material1 ) {
auto const texturelength { texture_length( m_material1 ) };
// left blade // left blade
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, fTexLength, 1.0, 0, bladelength, SwitchExtension->fOffset2 ); SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, texturelength, 1.0, 0, bladelength, SwitchExtension->fOffset2 );
GfxRenderer.Replace( vertices, Geometry1[ 2 ] ); GfxRenderer.Replace( vertices, Geometry1[ 2 ] );
vertices.clear(); vertices.clear();
} }
if( m_material2 ) { if( m_material2 ) {
auto const texturelength { texture_length( m_material2 ) };
// right blade // right blade
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, fTexLength, 1.0, 0, bladelength, -fMaxOffset + SwitchExtension->fOffset1 ); SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, texturelength, 1.0, 0, bladelength, -fMaxOffset + SwitchExtension->fOffset1 );
GfxRenderer.Replace( vertices, Geometry2[ 2 ] ); GfxRenderer.Replace( vertices, Geometry2[ 2 ] );
vertices.clear(); vertices.clear();
} }
} }
else { // lewa działa lepiej niż prawa else { // lewa działa lepiej niż prawa
if( m_material1 ) { if( m_material1 ) {
auto const texturelength { texture_length( m_material1 ) };
// right blade // right blade
SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, fTexLength, 1.0, 0, bladelength, -SwitchExtension->fOffset2 ); SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, texturelength, 1.0, 0, bladelength, -SwitchExtension->fOffset2 );
GfxRenderer.Replace( vertices, Geometry1[ 2 ] ); GfxRenderer.Replace( vertices, Geometry1[ 2 ] );
vertices.clear(); vertices.clear();
} }
if( m_material2 ) { if( m_material2 ) {
auto const texturelength { texture_length( m_material2 ) };
// left blade // left blade
SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, fTexLength, 1.0, 0, bladelength, fMaxOffset - SwitchExtension->fOffset1 ); SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, texturelength, 1.0, 0, bladelength, fMaxOffset - SwitchExtension->fOffset1 );
GfxRenderer.Replace( vertices, Geometry2[ 2 ] ); GfxRenderer.Replace( vertices, Geometry2[ 2 ] );
vertices.clear(); vertices.clear();
} }
@@ -2868,6 +2882,19 @@ TTrack::export_as_text_( std::ostream &Output ) const {
<< "\n"; << "\n";
} }
float
TTrack::texture_length( material_handle const Material ) {
if( Material == null_handle ) {
return fTexLength;
}
auto const texturelength { GfxRenderer.Material( Material ).size.y };
return (
texturelength < 0.f ?
fTexLength :
texturelength );
}
void TTrack::MovedUp1(float const dh) void TTrack::MovedUp1(float const dh)
{ // poprawienie przechyłki wymaga wydłużenia podsypki { // poprawienie przechyłki wymaga wydłużenia podsypki
fTexHeight1 += dh; fTexHeight1 += dh;

View File

@@ -298,7 +298,8 @@ private:
void deserialize_( std::istream &Input ); void deserialize_( std::istream &Input );
// export() subclass details, sends basic content of the class in legacy (text) format to provided stream // export() subclass details, sends basic content of the class in legacy (text) format to provided stream
void export_as_text_( std::ostream &Output ) const; void export_as_text_( std::ostream &Output ) const;
// returns texture length for specified material
float texture_length( material_handle const Material );
}; };

View File

@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
#include "material.h" #include "material.h"
#include "renderer.h" #include "renderer.h"
#include "utilities.h" #include "utilities.h"
#include "sn_utils.h"
#include "globals.h" #include "globals.h"
bool bool
@@ -73,6 +74,12 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
priority2 = Priority; priority2 = Priority;
} }
} }
else if( key == "size:" ) {
Input.getTokens( 2 );
Input
>> size.x
>> size.y;
}
else { else {
auto const value { Input.getToken<std::string>( true, "\n\r\t ;" ) }; auto const value { Input.getToken<std::string>( true, "\n\r\t ;" ) };
if( value == "{" ) { if( value == "{" ) {

View File

@@ -24,6 +24,7 @@ struct opengl_material {
bool has_alpha { false }; // alpha state, calculated from presence of alpha in texture1 bool has_alpha { false }; // alpha state, calculated from presence of alpha in texture1
std::string name; std::string name;
glm::vec2 size { -1.f, -1.f }; // 'physical' size of bound texture, in meters
// constructors // constructors
opengl_material() = default; opengl_material() = default;

View File

@@ -57,6 +57,10 @@ public:
translate( glm::vec3 const &Translation ) { translate( glm::vec3 const &Translation ) {
m_stack.top() = glm::translate( m_stack.top(), Translation ); m_stack.top() = glm::translate( m_stack.top(), Translation );
upload(); } upload(); }
void
scale( glm::vec3 const &Scale ) {
m_stack.top() = glm::scale( m_stack.top(), Scale );
upload(); }
void void
multiply( glm::mat4 const &Matrix ) { multiply( glm::mat4 const &Matrix ) {
m_stack.top() *= Matrix; m_stack.top() *= Matrix;
@@ -133,9 +137,9 @@ public:
m_stacks[ m_mode ].rotate( m_stacks[ m_mode ].rotate(
static_cast<float>(glm::radians(Angle)), static_cast<float>(glm::radians(Angle)),
glm::vec3( glm::vec3(
static_cast<float>(X), static_cast<float>( X ),
static_cast<float>(Y), static_cast<float>( Y ),
static_cast<float>(Z) ) ); } static_cast<float>( Z ) ) ); }
template <typename Type_> template <typename Type_>
void void
translate( Type_ const X, Type_ const Y, Type_ const Z ) { translate( Type_ const X, Type_ const Y, Type_ const Z ) {
@@ -145,6 +149,14 @@ public:
static_cast<float>( Y ), static_cast<float>( Y ),
static_cast<float>( Z ) ) ); } static_cast<float>( Z ) ) ); }
template <typename Type_> template <typename Type_>
void
scale( Type_ const X, Type_ const Y, Type_ const Z ) {
m_stacks[ m_mode ].scale(
glm::vec3(
static_cast<float>( X ),
static_cast<float>( Y ),
static_cast<float>( Z ) ) ); }
template <typename Type_>
void void
multiply( Type_ const *Matrix ) { multiply( Type_ const *Matrix ) {
m_stacks[ m_mode ].multiply( m_stacks[ m_mode ].multiply(
@@ -204,7 +216,8 @@ extern opengl_matrices OpenGLMatrices;
#define glRotatef OpenGLMatrices.rotate #define glRotatef OpenGLMatrices.rotate
#define glTranslated OpenGLMatrices.translate #define glTranslated OpenGLMatrices.translate
#define glTranslatef OpenGLMatrices.translate #define glTranslatef OpenGLMatrices.translate
// NOTE: no scale override as we aren't using it anywhere #define glScaled OpenGLMatrices.scale
#define glScalef OpenGLMatrices.scale
#define glMultMatrixd OpenGLMatrices.multiply #define glMultMatrixd OpenGLMatrices.multiply
#define glMultMatrixf OpenGLMatrices.multiply #define glMultMatrixf OpenGLMatrices.multiply
#define glOrtho OpenGLMatrices.ortho #define glOrtho OpenGLMatrices.ortho

View File

@@ -1433,9 +1433,12 @@ opengl_renderer::Render( world_environment *Environment ) {
::glDisable( GL_LIGHTING ); ::glDisable( GL_LIGHTING );
::glDisable( GL_DEPTH_TEST ); ::glDisable( GL_DEPTH_TEST );
::glDepthMask( GL_FALSE ); ::glDepthMask( GL_FALSE );
::glPushMatrix();
// skydome // skydome
// drawn with 500m radius to blend in if the fog range is low
::glPushMatrix();
::glScalef( 500.f, 500.f, 500.f );
Environment->m_skydome.Render(); Environment->m_skydome.Render();
::glPopMatrix();
// stars // stars
if( Environment->m_stars.m_stars != nullptr ) { if( Environment->m_stars.m_stars != nullptr ) {
// setup // setup
@@ -1450,12 +1453,6 @@ opengl_renderer::Render( world_environment *Environment ) {
::glPopMatrix(); ::glPopMatrix();
} }
// celestial bodies // celestial bodies
float const duskfactor = 1.0f - clamp( std::abs( Environment->m_sun.getAngle() ), 0.0f, 12.0f ) / 12.0f;
glm::vec3 suncolor = interpolate(
glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ),
glm::vec3( 235.0f / 255.0f, 140.0f / 255.0f, 36.0f / 255.0f ),
duskfactor );
if( DebugModeFlag == true ) { if( DebugModeFlag == true ) {
// mark sun position for easier debugging // mark sun position for easier debugging
Environment->m_sun.render(); Environment->m_sun.render();
@@ -1470,10 +1467,17 @@ opengl_renderer::Render( world_environment *Environment ) {
::glBlendFunc( GL_SRC_ALPHA, GL_ONE ); ::glBlendFunc( GL_SRC_ALPHA, GL_ONE );
auto const &modelview = OpenGLMatrices.data( GL_MODELVIEW ); auto const &modelview = OpenGLMatrices.data( GL_MODELVIEW );
auto const fogfactor { clamp<float>( Global.fFogEnd / 2000.f, 0.f, 1.f ) }; // stronger fog reduces opacity of the celestial bodies
float const duskfactor = 1.0f - clamp( std::abs( Environment->m_sun.getAngle() ), 0.0f, 12.0f ) / 12.0f;
glm::vec3 suncolor = interpolate(
glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ),
glm::vec3( 235.0f / 255.0f, 140.0f / 255.0f, 36.0f / 255.0f ),
duskfactor );
// sun // sun
{ {
Bind_Texture( m_suntexture ); Bind_Texture( m_suntexture );
::glColor4f( suncolor.x, suncolor.y, suncolor.z, clamp( 1.5f - Global.Overcast, 0.f, 1.f ) ); ::glColor4f( suncolor.x, suncolor.y, suncolor.z, clamp( 1.5f - Global.Overcast, 0.f, 1.f ) * fogfactor );
auto const sunvector = Environment->m_sun.getDirection(); auto const sunvector = Environment->m_sun.getDirection();
auto const sunposition = modelview * glm::vec4( sunvector.x, sunvector.y, sunvector.z, 1.0f ); auto const sunposition = modelview * glm::vec4( sunvector.x, sunvector.y, sunvector.z, 1.0f );
@@ -1495,14 +1499,15 @@ opengl_renderer::Render( world_environment *Environment ) {
{ {
Bind_Texture( m_moontexture ); Bind_Texture( m_moontexture );
glm::vec3 mooncolor( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ); glm::vec3 mooncolor( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f );
// fade the moon if it's near the sun in the sky, especially during the day
::glColor4f( ::glColor4f(
mooncolor.r, mooncolor.g, mooncolor.b, mooncolor.r, mooncolor.g, mooncolor.b,
// fade the moon if it's near the sun in the sky, especially during the day
std::max<float>( std::max<float>(
0.f, 0.f,
1.0 1.0
- 0.5 * Global.fLuminance - 0.5 * Global.fLuminance
- 0.65 * std::max( 0.f, glm::dot( Environment->m_sun.getDirection(), Environment->m_moon.getDirection() ) ) ) ); - 0.65 * std::max( 0.f, glm::dot( Environment->m_sun.getDirection(), Environment->m_moon.getDirection() ) ) )
* fogfactor );
auto const moonposition = modelview * glm::vec4( Environment->m_moon.getDirection(), 1.0f ); auto const moonposition = modelview * glm::vec4( Environment->m_moon.getDirection(), 1.0f );
::glPushMatrix(); ::glPushMatrix();
@@ -1563,7 +1568,6 @@ opengl_renderer::Render( world_environment *Environment ) {
::glDisable( GL_LIGHTING ); ::glDisable( GL_LIGHTING );
} }
::glPopMatrix();
::glDepthMask( GL_TRUE ); ::glDepthMask( GL_TRUE );
::glEnable( GL_DEPTH_TEST ); ::glEnable( GL_DEPTH_TEST );
::glEnable( GL_LIGHTING ); ::glEnable( GL_LIGHTING );

View File

@@ -62,8 +62,8 @@ void
world_environment::compute_weather() const { world_environment::compute_weather() const {
Global.Weather = ( Global.Weather = (
Global.Overcast < 0.25 ? "clear:" : Global.Overcast <= 0.25 ? "clear:" :
Global.Overcast < 1.0 ? "cloudy:" : Global.Overcast <= 1.0 ? "cloudy:" :
( Global.Season != "winter:" ? ( Global.Season != "winter:" ?
"rain:" : "rain:" :
"snow:" ) ); "snow:" ) );

View File

@@ -51,6 +51,7 @@ basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Sch
if( parameters.LoadType.name.empty() ) { if( parameters.LoadType.name.empty() ) {
// (try to) set the cargo type for empty cars // (try to) set the cargo type for empty cars
parameters.LoadAmount = 0.f; // safety measure against edge cases
parameters.AssignLoad( "passengers" ); parameters.AssignLoad( "passengers" );
} }

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 18 #define VERSION_MAJOR 18
#define VERSION_MINOR 928 #define VERSION_MINOR 1001
#define VERSION_REVISION 0 #define VERSION_REVISION 0