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

selected pantograph control switches, minor bug fixes

This commit is contained in:
tmj-fstate
2017-07-01 12:36:19 +02:00
parent 49aad85597
commit 534a49b636
10 changed files with 209 additions and 86 deletions

View File

@@ -150,16 +150,21 @@ double TGauge::GetValue() const {
return ( fValue - fOffset ) / fScale; return ( fValue - fOffset ) / fScale;
} }
void TGauge::Update() void TGauge::Update() {
{
float dt = Timer::GetDeltaTime(); float dt = Timer::GetDeltaTime();
if( ( fFriction > 0 ) && ( dt < 0.5 * fFriction ) ) { if( ( fFriction > 0 ) && ( dt < 0.5 * fFriction ) ) {
// McZapkie-281102: zabezpieczenie przed oscylacjami dla dlugich czasow // McZapkie-281102: zabezpieczenie przed oscylacjami dla dlugich czasow
fValue += dt * ( fDesiredValue - fValue ) / fFriction; fValue += dt * ( fDesiredValue - fValue ) / fFriction;
} }
else else {
fValue = fDesiredValue; fValue = fDesiredValue;
if (SubModel) }
if( std::abs( fDesiredValue - fValue ) <= 0.001 ) {
// close enough, we can stop updating the model
fValue = fDesiredValue; // set it exactly as requested just in case it matters
}
if( SubModel )
{ // warunek na wszelki wypadek, gdyby się submodel nie podłączył { // warunek na wszelki wypadek, gdyby się submodel nie podłączył
TSubModel *sm; TSubModel *sm;
switch (eType) switch (eType)

View File

@@ -102,7 +102,7 @@ int TSubModel::SeekFaceNormal(std::vector<unsigned int> const &Masks, int const
// pętla po trójkątach, od trójkąta (f) // pętla po trójkątach, od trójkąta (f)
if( Masks[ faceidx ] & Mask ) { if( Masks[ faceidx ] & Mask ) {
// jeśli wspólna maska powierzchni // jeśli wspólna maska powierzchni
for( int vertexidx = 0; vertexidx < 2; ++vertexidx ) { for( int vertexidx = 0; vertexidx < 3; ++vertexidx ) {
if( Vertices[ 3 * faceidx + vertexidx ].position == Position ) { if( Vertices[ 3 * faceidx + vertexidx ].position == Position ) {
return 3 * faceidx + vertexidx; return 3 * faceidx + vertexidx;
} }
@@ -370,11 +370,27 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
// transformation matrix // transformation matrix
fMatrix = new float4x4(); fMatrix = new float4x4();
readMatrix(parser, *fMatrix); // wczytanie transform readMatrix(parser, *fMatrix); // wczytanie transform
if (!fMatrix->IdentityIs()) if( !fMatrix->IdentityIs() ) {
iFlags |= 0x8000; // transform niejedynkowy - trzeba go przechować iFlags |= 0x8000; // transform niejedynkowy - trzeba go przechować
if( std::abs( Det( *fMatrix ) - 1.0f ) > 0.01f ) { // check the scaling
ErrorLog( "Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factor: " + to_string( Det( *fMatrix ), 2 ) + ")" ); auto const matrix = glm::make_mat4( fMatrix->readArray() );
m_normalizenormals = true; glm::vec3 const scale{
glm::length( glm::vec3( glm::column( matrix, 0 ) ) ),
glm::length( glm::vec3( glm::column( matrix, 1 ) ) ),
glm::length( glm::vec3( glm::column( matrix, 2 ) ) ) };
if( ( std::abs( scale.x - 1.0f ) > 0.01 )
|| ( std::abs( scale.y - 1.0f ) > 0.01 )
|| ( std::abs( scale.z - 1.0f ) > 0.01 ) ) {
ErrorLog(
"Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factors: "
+ to_string( scale.x, 2 ) + ", "
+ to_string( scale.y, 2 ) + ", "
+ to_string( scale.z, 2 ) + ")" );
m_normalizenormals = (
( ( std::abs( scale.x - scale.y ) < 0.01f ) && ( std::abs( scale.y - scale.z ) < 0.01f ) ) ?
rescale :
normalize );
}
} }
if (eType < TP_ROTATOR) if (eType < TP_ROTATOR)
{ // wczytywanie wierzchołków { // wczytywanie wierzchołków
@@ -1538,7 +1554,7 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
auto normallength = glm::length2( vertex.normal ); auto normallength = glm::length2( vertex.normal );
if( ( false == submodel.m_normalizenormals ) if( ( false == submodel.m_normalizenormals )
&& ( std::abs( normallength - 1.0f ) > 0.01f ) ) { && ( std::abs( normallength - 1.0f ) > 0.01f ) ) {
submodel.m_normalizenormals = true; submodel.m_normalizenormals = TSubModel::normalize; // we don't know if uniform scaling would suffice
WriteLog( "Bad model: non-unit normal vector(s) encountered during sub-model geometry deserialization" ); WriteLog( "Bad model: non-unit normal vector(s) encountered during sub-model geometry deserialization" );
} }
} }
@@ -1694,13 +1710,26 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
iFlags &= ~0x0200; // wczytano z pliku binarnego (nie jest właścicielem tablic) iFlags &= ~0x0200; // wczytano z pliku binarnego (nie jest właścicielem tablic)
if( ( fMatrix != nullptr ) if( fMatrix != nullptr ) {
&& ( std::abs( Det( *fMatrix ) - 1.0f ) > 0.01f ) ) { auto const matrix = glm::make_mat4( fMatrix->readArray() );
// check whether we need to enable normal vectors normalization for this submodel glm::vec3 const scale {
ErrorLog( "Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factor: " + to_string( Det( *fMatrix ), 2 ) + ")" ); glm::length( glm::vec3( glm::column( matrix, 0 ) ) ),
m_normalizenormals = true; glm::length( glm::vec3( glm::column( matrix, 1 ) ) ),
glm::length( glm::vec3( glm::column( matrix, 2 ) ) ) };
if( ( std::abs( scale.x - 1.0f ) > 0.01 )
|| ( std::abs( scale.y - 1.0f ) > 0.01 )
|| ( std::abs( scale.z - 1.0f ) > 0.01 ) ) {
ErrorLog(
"Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factors: "
+ to_string( scale.x, 2 ) + ", "
+ to_string( scale.y, 2 ) + ", "
+ to_string( scale.z, 2 ) + ")" );
m_normalizenormals = (
( ( std::abs( scale.x - scale.y ) < 0.01f ) && ( std::abs( scale.y - scale.z ) < 0.01f ) ) ?
rescale :
normalize );
}
} }
}; };
void TModel3d::LoadFromBinFile(std::string const &FileName, bool dynamic) void TModel3d::LoadFromBinFile(std::string const &FileName, bool dynamic)

View File

@@ -58,6 +58,13 @@ class TSubModel
friend class TModel3d; // temporary workaround. TODO: clean up class content/hierarchy friend class TModel3d; // temporary workaround. TODO: clean up class content/hierarchy
friend class TDynamicObject; // temporary etc friend class TDynamicObject; // temporary etc
public:
enum normalization {
none = 0,
rescale,
normalize
};
private: private:
int iNext{ NULL }; int iNext{ NULL };
int iChild{ NULL }; int iChild{ NULL };
@@ -96,7 +103,7 @@ private:
f4Diffuse { 1.0f,1.0f,1.0f,1.0f }, f4Diffuse { 1.0f,1.0f,1.0f,1.0f },
f4Specular { 0.0f,0.0f,0.0f,1.0f }, f4Specular { 0.0f,0.0f,0.0f,1.0f },
f4Emision { 1.0f,1.0f,1.0f,1.0f }; f4Emision { 1.0f,1.0f,1.0f,1.0f };
bool m_normalizenormals { false }; // indicates vectors need to be normalized due to scaling etc normalization m_normalizenormals { normalization::none }; // indicates vectors need to be normalized due to scaling etc
float fWireSize { 0.0f }; // nie używane, ale wczytywane float fWireSize { 0.0f }; // nie używane, ale wczytywane
float fSquareMaxDist { 10000.0f * 10000.0f }; float fSquareMaxDist { 10000.0f * 10000.0f };
float fSquareMinDist { 0.0f }; float fSquareMinDist { 0.0f };

View File

@@ -815,7 +815,7 @@ texture_manager::bind( texture_handle const Texture ) {
#ifndef EU07_DEFERRED_TEXTURE_UPLOAD #ifndef EU07_DEFERRED_TEXTURE_UPLOAD
// NOTE: we could bind dedicated 'error' texture here if the id isn't valid // NOTE: we could bind dedicated 'error' texture here if the id isn't valid
::glBindTexture( GL_TEXTURE_2D, texture(Texture).id ); ::glBindTexture( GL_TEXTURE_2D, texture(Texture).id );
m_activetexture = texture(Texture).id; m_activetexture = Texture;
#else #else
if( texture( Texture ).bind() == resource_state::good ) { if( texture( Texture ).bind() == resource_state::good ) {
m_activetexture = Texture; m_activetexture = Texture;

138
Train.cpp
View File

@@ -1225,25 +1225,29 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
// sound feedback // sound feedback
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
// visual feedback // visual feedback
if( Train->ggPantFrontButton.SubModel ) {
Train->ggPantFrontButton.UpdateValue( 1.0 ); Train->ggPantFrontButton.UpdateValue( 1.0 );
} // NOTE: currently we animate the selectable pantograph control based on standard key presses
if( Train->ggPantFrontButtonOff.SubModel != nullptr ) { // TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedButton.UpdateValue( 1.0 );
// pantograph control can have two-button setup // pantograph control can have two-button setup
Train->ggPantFrontButtonOff.UpdateValue( 0.0 ); Train->ggPantFrontButtonOff.UpdateValue( 0.0 );
} // NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedDownButton.UpdateValue( 0.0 );
} }
} }
} }
else { else {
// ...or turn off // ...or turn off
if( ( Train->mvOccupied->PantSwitchType == "impulse" ) if( Train->mvOccupied->PantSwitchType == "impulse" ) {
&& ( Train->ggPantFrontButtonOff.SubModel == nullptr ) ) { if( ( Train->ggPantFrontButtonOff.SubModel == nullptr )
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it // with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
// then another control has to be used (like pantographlowerall) // then another control has to be used (like pantographlowerall)
// TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels // TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels
return; return;
} }
}
Train->mvControlled->PantFrontSP = false; Train->mvControlled->PantFrontSP = false;
if( false == Train->mvControlled->PantFront( false ) ) { if( false == Train->mvControlled->PantFront( false ) ) {
@@ -1252,8 +1256,14 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
// visual feedback // visual feedback
Train->ggPantFrontButton.UpdateValue( 0.0 ); Train->ggPantFrontButton.UpdateValue( 0.0 );
// NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedButton.UpdateValue( 0.0 );
// pantograph control can have two-button setup // pantograph control can have two-button setup
Train->ggPantFrontButtonOff.UpdateValue( 1.0 ); Train->ggPantFrontButtonOff.UpdateValue( 1.0 );
// NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedDownButton.UpdateValue( 1.0 );
} }
} }
} }
@@ -1264,9 +1274,10 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
if( Train->ggPantFrontButton.GetValue() > 0.35 ) { if( Train->ggPantFrontButton.GetValue() > 0.35 ) {
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
} }
if( Train->ggPantFrontButton.SubModel ) {
Train->ggPantFrontButton.UpdateValue( 0.0 ); Train->ggPantFrontButton.UpdateValue( 0.0 );
} // NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedButton.UpdateValue( 0.0 );
// also the switch off button, in cabs which have it // also the switch off button, in cabs which have it
if( Train->ggPantFrontButtonOff.GetValue() > 0.35 ) { if( Train->ggPantFrontButtonOff.GetValue() > 0.35 ) {
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
@@ -1274,6 +1285,11 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const
if( Train->ggPantFrontButtonOff.SubModel ) { if( Train->ggPantFrontButtonOff.SubModel ) {
Train->ggPantFrontButtonOff.UpdateValue( 0.0 ); Train->ggPantFrontButtonOff.UpdateValue( 0.0 );
} }
if( Train->ggPantSelectedDownButton.SubModel ) {
// NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedDownButton.UpdateValue( 0.0 );
}
} }
} }
} }
@@ -1290,25 +1306,29 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
// sound feedback // sound feedback
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
// visual feedback // visual feedback
if( Train->ggPantRearButton.SubModel ) {
Train->ggPantRearButton.UpdateValue( 1.0 ); Train->ggPantRearButton.UpdateValue( 1.0 );
} // NOTE: currently we animate the selectable pantograph control based on standard key presses
if( Train->ggPantRearButtonOff.SubModel != nullptr ) { // TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedButton.UpdateValue( 1.0 );
// pantograph control can have two-button setup // pantograph control can have two-button setup
Train->ggPantRearButtonOff.UpdateValue( 0.0 ); Train->ggPantRearButtonOff.UpdateValue( 0.0 );
} // NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedDownButton.UpdateValue( 0.0 );
} }
} }
} }
else { else {
// ...or turn off // ...or turn off
if( ( Train->mvOccupied->PantSwitchType == "impulse" ) if( Train->mvOccupied->PantSwitchType == "impulse" ) {
&& ( Train->ggPantRearButtonOff.SubModel == nullptr ) ) { if( ( Train->ggPantRearButtonOff.SubModel == nullptr )
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it // with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
// then another control has to be used (like pantographlowerall) // then another control has to be used (like pantographlowerall)
// TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels // TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels
return; return;
} }
}
Train->mvControlled->PantRearSP = false; Train->mvControlled->PantRearSP = false;
if( false == Train->mvControlled->PantRear( false ) ) { if( false == Train->mvControlled->PantRear( false ) ) {
@@ -1317,8 +1337,14 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
// visual feedback // visual feedback
Train->ggPantRearButton.UpdateValue( 0.0 ); Train->ggPantRearButton.UpdateValue( 0.0 );
// NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedButton.UpdateValue( 0.0 );
// pantograph control can have two-button setup // pantograph control can have two-button setup
Train->ggPantRearButtonOff.UpdateValue( 1.0 ); Train->ggPantRearButtonOff.UpdateValue( 1.0 );
// NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedDownButton.UpdateValue( 1.0 );
} }
} }
} }
@@ -1329,9 +1355,10 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
if( Train->ggPantRearButton.GetValue() > 0.35 ) { if( Train->ggPantRearButton.GetValue() > 0.35 ) {
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
} }
if( Train->ggPantRearButton.SubModel ) {
Train->ggPantRearButton.UpdateValue( 0.0 ); Train->ggPantRearButton.UpdateValue( 0.0 );
} // NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedButton.UpdateValue( 0.0 );
// also the switch off button, in cabs which have it // also the switch off button, in cabs which have it
if( Train->ggPantRearButtonOff.GetValue() > 0.35 ) { if( Train->ggPantRearButtonOff.GetValue() > 0.35 ) {
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
@@ -1339,6 +1366,11 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &
if( Train->ggPantRearButtonOff.SubModel ) { if( Train->ggPantRearButtonOff.SubModel ) {
Train->ggPantRearButtonOff.UpdateValue( 0.0 ); Train->ggPantRearButtonOff.UpdateValue( 0.0 );
} }
if( Train->ggPantSelectedDownButton.SubModel ) {
// NOTE: currently we animate the selectable pantograph control based on standard key presses
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
Train->ggPantSelectedDownButton.UpdateValue( 0.0 );
}
} }
} }
} }
@@ -1400,7 +1432,8 @@ void TTrain::OnCommand_pantographcompressoractivate( TTrain *Train, command_data
void TTrain::OnCommand_pantographlowerall( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_pantographlowerall( TTrain *Train, command_data const &Command ) {
if( Train->ggPantAllDownButton.SubModel == nullptr ) { if( ( Train->ggPantAllDownButton.SubModel == nullptr )
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
// TODO: expand definition of cab controls so we can know if the control is present without testing for presence of 3d switch // TODO: expand definition of cab controls so we can know if the control is present without testing for presence of 3d switch
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_PRESS ) {
WriteLog( "Lower All Pantographs switch is missing, or wasn't defined" ); WriteLog( "Lower All Pantographs switch is missing, or wasn't defined" );
@@ -1423,6 +1456,9 @@ void TTrain::OnCommand_pantographlowerall( TTrain *Train, command_data const &Co
} }
// visual feedback // visual feedback
Train->ggPantAllDownButton.UpdateValue( 1.0 ); Train->ggPantAllDownButton.UpdateValue( 1.0 );
if( Train->ggPantSelectedDownButton.SubModel != nullptr ) {
Train->ggPantSelectedDownButton.UpdateValue( 1.0 );
}
} }
else if( Command.action == GLFW_RELEASE ) { else if( Command.action == GLFW_RELEASE ) {
// release the button // release the button
@@ -1436,6 +1472,9 @@ void TTrain::OnCommand_pantographlowerall( TTrain *Train, command_data const &Co
*/ */
// visual feedback // visual feedback
Train->ggPantAllDownButton.UpdateValue( 0.0 ); Train->ggPantAllDownButton.UpdateValue( 0.0 );
if( Train->ggPantSelectedDownButton.SubModel != nullptr ) {
Train->ggPantSelectedDownButton.UpdateValue( 0.0 );
}
} }
} }
@@ -4830,15 +4869,10 @@ bool TTrain::Update( double const Deltatime )
// NBMX wrzesien 2003 - drzwi // NBMX wrzesien 2003 - drzwi
ggDoorLeftButton.Update(); ggDoorLeftButton.Update();
ggDoorRightButton.Update(); ggDoorRightButton.Update();
ggDepartureSignalButton.Update(); ggDoorSignallingButton.Update();
// NBMX dzwignia sprezarki // NBMX dzwignia sprezarki
ggCompressorButton.Update(); ggCompressorButton.Update();
ggCompressorLocalButton.Update(); ggCompressorLocalButton.Update();
ggMainButton.Update();
ggRadioButton.Update();
ggConverterButton.Update();
ggConverterLocalButton.Update();
ggConverterOffButton.Update();
#ifdef EU07_USE_OLD_COMMAND_SYSTEM #ifdef EU07_USE_OLD_COMMAND_SYSTEM
if( ( ( DynamicObject->iLights[ 0 ] ) == 0 ) && ( ( DynamicObject->iLights[ 1 ] ) == 0 ) ) if( ( ( DynamicObject->iLights[ 0 ] ) == 0 ) && ( ( DynamicObject->iLights[ 1 ] ) == 0 ) )
@@ -4989,15 +5023,6 @@ bool TTrain::Update( double const Deltatime )
} }
ggDimHeadlightsButton.Update(); ggDimHeadlightsButton.Update();
//--------- //---------
// Winger 010304 - pantografy
// NOTE: shouldn't the pantograph updates check whether it's front or rear cabin?
ggPantFrontButton.Update();
ggPantRearButton.Update();
ggPantFrontButtonOff.Update();
ggTrainHeatingButton.Update();
ggSignallingButton.Update();
ggDoorSignallingButton.Update();
// Winger 020304 - ogrzewanie
// hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy
if ((((mvControlled->EngineType == ElectricSeriesMotor) && (mvControlled->Mains == true) && if ((((mvControlled->EngineType == ElectricSeriesMotor) && (mvControlled->Mains == true) &&
(mvControlled->ConvOvldFlag == false)) || (mvControlled->ConvOvldFlag == false)) ||
@@ -5813,10 +5838,15 @@ bool TTrain::Update( double const Deltatime )
ggStLinOffButton.Update(); ggStLinOffButton.Update();
ggRadioButton.Update(); ggRadioButton.Update();
ggDepartureSignalButton.Update(); ggDepartureSignalButton.Update();
ggPantFrontButton.Update(); ggPantFrontButton.Update();
ggPantRearButton.Update(); ggPantRearButton.Update();
ggPantSelectedButton.Update();
ggPantFrontButtonOff.Update(); ggPantFrontButtonOff.Update();
ggPantRearButtonOff.Update(); ggPantRearButtonOff.Update();
ggPantSelectedDownButton.Update();
ggPantAllDownButton.Update();
ggUpperLightButton.Update(); ggUpperLightButton.Update();
ggLeftLightButton.Update(); ggLeftLightButton.Update();
ggRightLightButton.Update(); ggRightLightButton.Update();
@@ -5829,8 +5859,8 @@ bool TTrain::Update( double const Deltatime )
ggRearLeftEndLightButton.Update(); ggRearLeftEndLightButton.Update();
ggRearRightEndLightButton.Update(); ggRearRightEndLightButton.Update();
//------------ //------------
ggPantAllDownButton.Update();
ggConverterButton.Update(); ggConverterButton.Update();
ggConverterLocalButton.Update();
ggConverterOffButton.Update(); ggConverterOffButton.Update();
ggTrainHeatingButton.Update(); ggTrainHeatingButton.Update();
ggSignallingButton.Update(); ggSignallingButton.Update();
@@ -6630,7 +6660,6 @@ void TTrain::SetLights()
// clears state of all cabin controls // clears state of all cabin controls
void TTrain::clear_cab_controls() void TTrain::clear_cab_controls()
{ {
ggMainCtrl.Clear(); ggMainCtrl.Clear();
ggMainCtrlAct.Clear(); ggMainCtrlAct.Clear();
ggScndCtrl.Clear(); ggScndCtrl.Clear();
@@ -6670,7 +6699,10 @@ void TTrain::clear_cab_controls()
ggConverterButton.Clear(); ggConverterButton.Clear();
ggPantFrontButton.Clear(); ggPantFrontButton.Clear();
ggPantRearButton.Clear(); ggPantRearButton.Clear();
ggPantSelectedButton.Clear();
ggPantFrontButtonOff.Clear(); ggPantFrontButtonOff.Clear();
ggPantRearButtonOff.Clear();
ggPantSelectedDownButton.Clear();
ggPantAllDownButton.Clear(); ggPantAllDownButton.Clear();
ggZbS.Clear(); ggZbS.Clear();
ggI1B.Clear(); ggI1B.Clear();
@@ -6787,6 +6819,16 @@ void TTrain::set_cab_controls() {
( mvControlled->PantFrontUp ? ( mvControlled->PantFrontUp ?
0.0 : 0.0 :
1.0 ) ); 1.0 ) );
// NOTE: currently we animate the selectable pantograph control for both pantographs
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
ggPantSelectedButton.PutValue(
( mvControlled->PantFrontUp ?
1.0 :
0.0 ) );
ggPantSelectedDownButton.PutValue(
( mvControlled->PantFrontUp ?
0.0 :
1.0 ) );
} }
if( mvOccupied->PantSwitchType != "impulse" ) { if( mvOccupied->PantSwitchType != "impulse" ) {
ggPantRearButton.PutValue( ggPantRearButton.PutValue(
@@ -6797,6 +6839,16 @@ void TTrain::set_cab_controls() {
( mvControlled->PantRearUp ? ( mvControlled->PantRearUp ?
0.0 : 0.0 :
1.0 ) ); 1.0 ) );
// NOTE: currently we animate the selectable pantograph control for both pantographs
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
ggPantSelectedButton.PutValue(
( mvControlled->PantRearUp ?
1.0 :
0.0 ) );
ggPantSelectedDownButton.PutValue(
( mvControlled->PantRearUp ?
0.0 :
1.0 ) );
} }
// converter // converter
if( mvOccupied->ConvSwitchType != "impulse" ) { if( mvOccupied->ConvSwitchType != "impulse" ) {
@@ -7397,16 +7449,22 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
ggPantFrontButtonOff.Load(Parser, DynamicObject->mdKabina); ggPantFrontButtonOff.Load(Parser, DynamicObject->mdKabina);
} }
else if( Label == "pantrearoff_sw:" ) { else if( Label == "pantrearoff_sw:" ) {
// patyk przedni w dol // rear pant down
ggPantRearButtonOff.Load( Parser, DynamicObject->mdKabina ); ggPantRearButtonOff.Load( Parser, DynamicObject->mdKabina );
} }
else if( Label == "pantalloff_sw:" ) else if( Label == "pantalloff_sw:" ) {
{ // both pantographs down
// patyk przedni w dol
ggPantAllDownButton.Load(Parser, DynamicObject->mdKabina); ggPantAllDownButton.Load(Parser, DynamicObject->mdKabina);
} }
else if (Label == "trainheating_sw:") else if( Label == "pantselected_sw:" ) {
{ // operate selected pantograph(s)
ggPantSelectedButton.Load( Parser, DynamicObject->mdKabina );
}
else if( Label == "pantselectedoff_sw:" ) {
// operate selected pantograph(s)
ggPantSelectedDownButton.Load( Parser, DynamicObject->mdKabina );
}
else if (Label == "trainheating_sw:") {
// grzanie skladu // grzanie skladu
ggTrainHeatingButton.Load(Parser, DynamicObject->mdKabina); ggTrainHeatingButton.Load(Parser, DynamicObject->mdKabina);
} }

View File

@@ -285,6 +285,8 @@ public: // reszta może by?publiczna
TGauge ggPantFrontButtonOff; // EZT TGauge ggPantFrontButtonOff; // EZT
TGauge ggPantRearButtonOff; TGauge ggPantRearButtonOff;
TGauge ggPantAllDownButton; TGauge ggPantAllDownButton;
TGauge ggPantSelectedButton;
TGauge ggPantSelectedDownButton;
// Winger 020304 - wlacznik ogrzewania // Winger 020304 - wlacznik ogrzewania
TGauge ggTrainHeatingButton; TGauge ggTrainHeatingButton;
TGauge ggSignallingButton; TGauge ggSignallingButton;

View File

@@ -360,7 +360,7 @@ opengl_renderer::Bind( texture_handle const Texture ) {
m_textures.bind( Texture ); m_textures.bind( Texture );
} }
opengl_texture & opengl_texture const &
opengl_renderer::Texture( texture_handle const Texture ) { opengl_renderer::Texture( texture_handle const Texture ) {
return m_textures.texture( Texture ); return m_textures.texture( Texture );
@@ -758,9 +758,15 @@ opengl_renderer::Render( TSubModel *Submodel ) {
// renderowanie obiektów OpenGL // renderowanie obiektów OpenGL
if( Submodel->iAlpha & Submodel->iFlags & 0x1F ) // rysuj gdy element nieprzezroczysty if( Submodel->iAlpha & Submodel->iFlags & 0x1F ) // rysuj gdy element nieprzezroczysty
{ {
if( true == Submodel->m_normalizenormals ) { switch( Submodel->m_normalizenormals ) {
::glEnable( GL_NORMALIZE ); case TSubModel::normalize: {
::glEnable( GL_NORMALIZE ); break; }
case TSubModel::rescale: {
::glEnable( GL_RESCALE_NORMAL ); break; }
default: {
break; }
} }
// material configuration: // material configuration:
// textures... // textures...
if( Submodel->TextureID < 0 ) if( Submodel->TextureID < 0 )
@@ -794,8 +800,13 @@ opengl_renderer::Render( TSubModel *Submodel ) {
// restore default (lack of) brightness // restore default (lack of) brightness
::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr( colors::none ) ); ::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr( colors::none ) );
} }
if( true == Submodel->m_normalizenormals ) { switch( Submodel->m_normalizenormals ) {
::glDisable( GL_NORMALIZE ); case TSubModel::normalize: {
::glDisable( GL_NORMALIZE ); break; }
case TSubModel::rescale: {
::glDisable( GL_RESCALE_NORMAL ); break; }
default: {
break; }
} }
} }
} }
@@ -1217,8 +1228,13 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
// renderowanie obiektów OpenGL // renderowanie obiektów OpenGL
if( Submodel->iAlpha & Submodel->iFlags & 0x2F ) // rysuj gdy element przezroczysty if( Submodel->iAlpha & Submodel->iFlags & 0x2F ) // rysuj gdy element przezroczysty
{ {
if( true == Submodel->m_normalizenormals ) { switch( Submodel->m_normalizenormals ) {
::glEnable( GL_NORMALIZE ); case TSubModel::normalize: {
::glEnable( GL_NORMALIZE ); break; }
case TSubModel::rescale: {
::glEnable( GL_RESCALE_NORMAL ); break; }
default: {
break; }
} }
// textures... // textures...
if( Submodel->TextureID < 0 ) { // zmienialne skóry if( Submodel->TextureID < 0 ) { // zmienialne skóry
@@ -1250,8 +1266,13 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
// restore default (lack of) brightness // restore default (lack of) brightness
::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr( colors::none ) ); ::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr( colors::none ) );
} }
if( true == Submodel->m_normalizenormals ) { switch( Submodel->m_normalizenormals ) {
::glDisable( GL_NORMALIZE ); case TSubModel::normalize: {
::glDisable( GL_NORMALIZE ); break; }
case TSubModel::rescale: {
::glDisable( GL_RESCALE_NORMAL ); break; }
default: {
break; }
} }
} }
} }

View File

@@ -158,7 +158,7 @@ public:
GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true ); GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true );
void void
Bind( texture_handle const Texture ); Bind( texture_handle const Texture );
opengl_texture & opengl_texture const &
Texture( texture_handle const Texture ); Texture( texture_handle const Texture );
// members // members

View File

@@ -84,6 +84,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/epsilon.hpp> #include <glm/gtc/epsilon.hpp>
#include <glm/gtx/rotate_vector.hpp> #include <glm/gtx/rotate_vector.hpp>

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 17 #define VERSION_MAJOR 17
#define VERSION_MINOR 628 #define VERSION_MINOR 630
#define VERSION_REVISION 0 #define VERSION_REVISION 0