mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 19:49:19 +02:00
build 170515. added converter start parameters, partial unification for traction render paths, minor fixes for multi-unit cab instruments
This commit is contained in:
14
DynObj.cpp
14
DynObj.cpp
@@ -2458,14 +2458,14 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
// opuszczenie pantografów przy niskim ciśnieniu
|
// opuszczenie pantografów przy niskim ciśnieniu
|
||||||
/*
|
/*
|
||||||
// NOTE: disabled, the pantographs drop by themseleves when the pantograph tank pressure gets low enough
|
// NOTE: disabled, the pantographs drop by themseleves when the pantograph tank pressure gets low enough
|
||||||
MoverParameters->PantFront( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
|
MoverParameters->PantFront( false, ( MoverParameters->TrainType == dt_EZT ? range::unit : range::local ) );
|
||||||
MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
|
MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? range::unit : range::local ) );
|
||||||
*/
|
*/
|
||||||
if( MoverParameters->TrainType != dt_EZT ) {
|
if( MoverParameters->TrainType != dt_EZT ) {
|
||||||
// pressure switch safety measure -- open the line breaker, unless there's alternate source of traction voltage
|
// pressure switch safety measure -- open the line breaker, unless there's alternate source of traction voltage
|
||||||
if( MoverParameters->GetTrainsetVoltage() < 0.5 * MoverParameters->EnginePowerSource.MaxVoltage ) {
|
if( MoverParameters->GetTrainsetVoltage() < 0.5 * MoverParameters->EnginePowerSource.MaxVoltage ) {
|
||||||
// TODO: check whether line breaker should be open EMU-wide
|
// TODO: check whether line breaker should be open EMU-wide
|
||||||
MoverParameters->MainSwitch( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
|
MoverParameters->MainSwitch( false, ( MoverParameters->TrainType == dt_EZT ? range::unit : range::local ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2473,7 +2473,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
// and prevents their activation until pressure switch is set again
|
// and prevents their activation until pressure switch is set again
|
||||||
MoverParameters->PantPressLockActive = true;
|
MoverParameters->PantPressLockActive = true;
|
||||||
// TODO: separate 'heating allowed' from actual heating flag, so we can disable it here without messing up heating toggle
|
// TODO: separate 'heating allowed' from actual heating flag, so we can disable it here without messing up heating toggle
|
||||||
MoverParameters->ConverterSwitch( false, command_range::unit );
|
MoverParameters->ConverterSwitch( false, range::unit );
|
||||||
}
|
}
|
||||||
// mark the pressure switch as spent
|
// mark the pressure switch as spent
|
||||||
MoverParameters->PantPressSwitchActive = false;
|
MoverParameters->PantPressSwitchActive = false;
|
||||||
@@ -2936,7 +2936,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
&& ( MoverParameters->EngineType != DieselEngine )
|
&& ( MoverParameters->EngineType != DieselEngine )
|
||||||
&& ( MoverParameters->EngineType != WheelsDriven ) )
|
&& ( MoverParameters->EngineType != WheelsDriven ) )
|
||||||
{ // jeśli bateria wyłączona, a nie diesel ani drezyna reczna
|
{ // jeśli bateria wyłączona, a nie diesel ani drezyna reczna
|
||||||
if( MoverParameters->MainSwitch( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) ) ) {
|
if( MoverParameters->MainSwitch( false, ( MoverParameters->TrainType == dt_EZT ? range::unit : range::local ) ) ) {
|
||||||
// wyłączyć zasilanie
|
// wyłączyć zasilanie
|
||||||
// NOTE: we turn off entire EMU, but only the affected unit for other multi-unit consists
|
// NOTE: we turn off entire EMU, but only the affected unit for other multi-unit consists
|
||||||
MoverParameters->EventFlag = true;
|
MoverParameters->EventFlag = true;
|
||||||
@@ -2945,8 +2945,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
// TODO: have this dependant on .fiz-driven flag
|
// TODO: have this dependant on .fiz-driven flag
|
||||||
// NOTE: moved to pantspeed calculation part a little later in the function. all remarks and todo still apply
|
// NOTE: moved to pantspeed calculation part a little later in the function. all remarks and todo still apply
|
||||||
/*
|
/*
|
||||||
MoverParameters->PantFront( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
|
MoverParameters->PantFront( false, ( MoverParameters->TrainType == dt_EZT ? range::unit : range::local ) );
|
||||||
MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
|
MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? range::unit : range::local ) );
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
54
Ground.cpp
54
Ground.cpp
@@ -285,8 +285,7 @@ void TGroundNode::MoveMe(vector3 pPosition)
|
|||||||
void TGroundNode::RaRenderVBO()
|
void TGroundNode::RaRenderVBO()
|
||||||
{ // renderowanie z domyslnego bufora VBO
|
{ // renderowanie z domyslnego bufora VBO
|
||||||
glColor3ub(Diffuse[0], Diffuse[1], Diffuse[2]);
|
glColor3ub(Diffuse[0], Diffuse[1], Diffuse[2]);
|
||||||
if (TextureID)
|
GfxRenderer.Bind( TextureID ); // Ustaw aktywną teksturę
|
||||||
GfxRenderer.Bind(TextureID); // Ustaw aktywną teksturę
|
|
||||||
glDrawArrays(iType, iVboPtr, iNumVerts); // Narysuj naraz wszystkie trójkąty
|
glDrawArrays(iType, iVboPtr, iNumVerts); // Narysuj naraz wszystkie trójkąty
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2248,31 +2247,19 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
|||||||
case GL_LINES:
|
case GL_LINES:
|
||||||
case GL_LINE_STRIP:
|
case GL_LINE_STRIP:
|
||||||
case GL_LINE_LOOP: {
|
case GL_LINE_LOOP: {
|
||||||
parser->getTokens( 3 );
|
parser->getTokens( 4 );
|
||||||
*parser >> tmp->Diffuse[ 0 ] >> tmp->Diffuse[ 1 ] >> tmp->Diffuse[ 2 ];
|
*parser
|
||||||
// tmp->Diffuse[0]=Parser->GetNextSymbol().ToDouble()/255;
|
>> tmp->Diffuse[ 0 ]
|
||||||
// tmp->Diffuse[1]=Parser->GetNextSymbol().ToDouble()/255;
|
>> tmp->Diffuse[ 1 ]
|
||||||
// tmp->Diffuse[2]=Parser->GetNextSymbol().ToDouble()/255;
|
>> tmp->Diffuse[ 2 ]
|
||||||
parser->getTokens();
|
>> tmp->fLineThickness;
|
||||||
*parser >> tmp->fLineThickness;
|
|
||||||
TempVerts.clear();
|
TempVerts.clear();
|
||||||
TGroundVertex vertex;
|
TGroundVertex vertex;
|
||||||
i = 0;
|
i = 0;
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
do {
|
do {
|
||||||
str = token;
|
vertex.Point.x = std::atof( token.c_str() );
|
||||||
/*
|
|
||||||
TempVerts[ i ].Point.x = atof( str.c_str() );
|
|
||||||
parser->getTokens( 2 );
|
|
||||||
*parser >> TempVerts[ i ].Point.y >> TempVerts[ i ].Point.z;
|
|
||||||
TempVerts[ i ].Point.RotateZ( aRotate.z / 180 * M_PI );
|
|
||||||
TempVerts[ i ].Point.RotateX( aRotate.x / 180 * M_PI );
|
|
||||||
TempVerts[ i ].Point.RotateY( aRotate.y / 180 * M_PI );
|
|
||||||
TempVerts[ i ].Point += pOrigin;
|
|
||||||
tmp->pCenter += TempVerts[ i ].Point;
|
|
||||||
*/
|
|
||||||
vertex.Point.x = std::atof( str.c_str() );
|
|
||||||
parser->getTokens( 2 );
|
parser->getTokens( 2 );
|
||||||
*parser
|
*parser
|
||||||
>> vertex.Point.y
|
>> vertex.Point.y
|
||||||
@@ -2328,27 +2315,19 @@ TSubRect * TGround::GetSubRect(int iCol, int iRow)
|
|||||||
TEvent * TGround::FindEvent(const std::string &asEventName)
|
TEvent * TGround::FindEvent(const std::string &asEventName)
|
||||||
{
|
{
|
||||||
auto const lookup = m_eventmap.find( asEventName );
|
auto const lookup = m_eventmap.find( asEventName );
|
||||||
return
|
return (
|
||||||
lookup != m_eventmap.end() ?
|
lookup != m_eventmap.end() ?
|
||||||
lookup->second :
|
lookup->second :
|
||||||
nullptr;
|
nullptr );
|
||||||
/* //powolna wyszukiwarka
|
|
||||||
for (TEvent *Current=RootEvent;Current;Current=Current->Next2)
|
|
||||||
{
|
|
||||||
if (Current->asName==asEventName)
|
|
||||||
return Current;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEvent * TGround::FindEventScan( std::string const &asEventName )
|
TEvent * TGround::FindEventScan( std::string const &asEventName )
|
||||||
{ // wyszukanie eventu z opcją utworzenia niejawnego dla komórek skanowanych
|
{ // wyszukanie eventu z opcją utworzenia niejawnego dla komórek skanowanych
|
||||||
auto const lookup = m_eventmap.find( asEventName );
|
auto const lookup = m_eventmap.find( asEventName );
|
||||||
auto e =
|
auto e = (
|
||||||
lookup != m_eventmap.end() ?
|
lookup != m_eventmap.end() ?
|
||||||
lookup->second :
|
lookup->second :
|
||||||
nullptr;
|
nullptr );
|
||||||
if (e)
|
if (e)
|
||||||
return e; // jak istnieje, to w porządku
|
return e; // jak istnieje, to w porządku
|
||||||
if (asEventName.rfind(":scan") != std::string::npos) // jeszcze może być event niejawny
|
if (asEventName.rfind(":scan") != std::string::npos) // jeszcze może być event niejawny
|
||||||
@@ -4290,11 +4269,6 @@ bool TGround::CheckQuery()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGround::OpenGLUpdate(HDC hDC)
|
|
||||||
{
|
|
||||||
SwapBuffers(hDC); // swap buffers (double buffering)
|
|
||||||
};
|
|
||||||
|
|
||||||
void TGround::UpdatePhys(double dt, int iter)
|
void TGround::UpdatePhys(double dt, int iter)
|
||||||
{ // aktualizacja fizyki stałym krokiem: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń
|
{ // aktualizacja fizyki stałym krokiem: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń
|
||||||
for (TGroundNode *Current = nRootOfType[TP_TRACTIONPOWERSOURCE]; Current;
|
for (TGroundNode *Current = nRootOfType[TP_TRACTIONPOWERSOURCE]; Current;
|
||||||
|
|||||||
3
Ground.h
3
Ground.h
@@ -293,8 +293,6 @@ class TGround
|
|||||||
TGroundNode *nRootOfType[TP_LAST]; // tablica grupująca obiekty, przyspiesza szukanie
|
TGroundNode *nRootOfType[TP_LAST]; // tablica grupująca obiekty, przyspiesza szukanie
|
||||||
// TGroundNode *nLastOfType[TP_LAST]; //ostatnia
|
// TGroundNode *nLastOfType[TP_LAST]; //ostatnia
|
||||||
TSubRect srGlobal; // zawiera obiekty globalne (na razie wyzwalacze czasowe)
|
TSubRect srGlobal; // zawiera obiekty globalne (na razie wyzwalacze czasowe)
|
||||||
int hh = 0,
|
|
||||||
mm = 0; // ustawienia czasu
|
|
||||||
// int tracks,tracksfar; //liczniki torów
|
// int tracks,tracksfar; //liczniki torów
|
||||||
typedef std::unordered_map<std::string, TEvent *> event_map;
|
typedef std::unordered_map<std::string, TEvent *> event_map;
|
||||||
event_map m_eventmap;
|
event_map m_eventmap;
|
||||||
@@ -374,7 +372,6 @@ class TGround
|
|||||||
void TrackJoin(TGroundNode *Current);
|
void TrackJoin(TGroundNode *Current);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OpenGLUpdate(HDC hDC);
|
|
||||||
void RaTriangleDivider(TGroundNode *node);
|
void RaTriangleDivider(TGroundNode *node);
|
||||||
void Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam);
|
void Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||||
bool PROBLEND;
|
bool PROBLEND;
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ static int const ctrain_passenger = 16; //mostek przejściowy
|
|||||||
static int const ctrain_scndpneumatic = 32; //przewody 8 atm (żółte; zasilanie powietrzem)
|
static int const ctrain_scndpneumatic = 32; //przewody 8 atm (żółte; zasilanie powietrzem)
|
||||||
static int const ctrain_heating = 64; //przewody ogrzewania WN
|
static int const ctrain_heating = 64; //przewody ogrzewania WN
|
||||||
static int const ctrain_depot = 128; //nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna
|
static int const ctrain_depot = 128; //nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna
|
||||||
|
// possible coupling types; can be combined
|
||||||
enum coupling {
|
enum coupling {
|
||||||
faux = 0x0,
|
faux = 0x0,
|
||||||
coupler = 0x1,
|
coupler = 0x1,
|
||||||
@@ -150,11 +151,16 @@ enum coupling {
|
|||||||
heating = 0x40,
|
heating = 0x40,
|
||||||
permanent = 0x80
|
permanent = 0x80
|
||||||
};
|
};
|
||||||
/*! przesylanie komend sterujacych*/
|
// possible effect ranges for control commands; exclusive
|
||||||
enum command_range {
|
enum range {
|
||||||
local,
|
local,
|
||||||
unit,
|
unit,
|
||||||
consist
|
consist
|
||||||
|
};
|
||||||
|
// start method for devices; exclusive
|
||||||
|
enum start {
|
||||||
|
manual,
|
||||||
|
automatic
|
||||||
};
|
};
|
||||||
/*typ hamulca elektrodynamicznego*/
|
/*typ hamulca elektrodynamicznego*/
|
||||||
static int const dbrake_none = 0;
|
static int const dbrake_none = 0;
|
||||||
@@ -842,9 +848,14 @@ public:
|
|||||||
bool PantCompFlag = false; /*!o czy wlaczona sprezarka pantografow*/
|
bool PantCompFlag = false; /*!o czy wlaczona sprezarka pantografow*/
|
||||||
bool CompressorAllow = false; /*! zezwolenie na uruchomienie sprezarki NBMX*/
|
bool CompressorAllow = false; /*! zezwolenie na uruchomienie sprezarki NBMX*/
|
||||||
bool CompressorGovernorLock{ false }; // indicates whether compressor pressure switch was activated due to reaching cut-out pressure
|
bool CompressorGovernorLock{ false }; // indicates whether compressor pressure switch was activated due to reaching cut-out pressure
|
||||||
bool ConverterFlag = false ; /*! czy wlaczona przetwornica NBMX*/
|
// TODO converter parameters, for when we start cleaning up mover parameters
|
||||||
|
start ConverterStart{ manual }; // whether converter is started manually, or by other means
|
||||||
|
float ConverterStartDelay{ 0.0f }; // delay (in seconds) before the converter is started, once its activation conditions are met
|
||||||
|
double ConverterStartDelayTimer{ 0.0 }; // helper, for tracking whether converter start delay passed
|
||||||
bool ConverterAllow = false; /*zezwolenie na prace przetwornicy NBMX*/
|
bool ConverterAllow = false; /*zezwolenie na prace przetwornicy NBMX*/
|
||||||
int BrakeCtrlPos = -2; /*nastawa hamulca zespolonego*/
|
bool ConverterFlag = false; /*! czy wlaczona przetwornica NBMX*/
|
||||||
|
|
||||||
|
int BrakeCtrlPos = -2; /*nastawa hamulca zespolonego*/
|
||||||
double BrakeCtrlPosR = 0.0; /*nastawa hamulca zespolonego - plynna dla FV4a*/
|
double BrakeCtrlPosR = 0.0; /*nastawa hamulca zespolonego - plynna dla FV4a*/
|
||||||
double BrakeCtrlPos2 = 0.0; /*nastawa hamulca zespolonego - kapturek dla FV4a*/
|
double BrakeCtrlPos2 = 0.0; /*nastawa hamulca zespolonego - kapturek dla FV4a*/
|
||||||
int LocalBrakePos = 0; /*nastawa hamulca indywidualnego*/
|
int LocalBrakePos = 0; /*nastawa hamulca indywidualnego*/
|
||||||
@@ -1045,7 +1056,7 @@ public:
|
|||||||
|
|
||||||
bool AddPulseForce(int Multipler);/*dla drezyny*/
|
bool AddPulseForce(int Multipler);/*dla drezyny*/
|
||||||
|
|
||||||
bool Sandbox( bool const State, int const Notify = command_range::consist );/*wlacza/wylacza sypanie piasku*/
|
bool Sandbox( bool const State, int const Notify = range::consist );/*wlacza/wylacza sypanie piasku*/
|
||||||
|
|
||||||
/*! zbijanie czuwaka/SHP*/
|
/*! zbijanie czuwaka/SHP*/
|
||||||
void SSReset(void);
|
void SSReset(void);
|
||||||
@@ -1101,12 +1112,12 @@ public:
|
|||||||
|
|
||||||
/*--funkcje dla lokomotyw*/
|
/*--funkcje dla lokomotyw*/
|
||||||
bool DirectionBackward(void);/*! kierunek ruchu*/
|
bool DirectionBackward(void);/*! kierunek ruchu*/
|
||||||
bool MainSwitch( bool const State, int const Notify = command_range::consist );/*! wylacznik glowny*/
|
bool MainSwitch( bool const State, int const Notify = range::consist );/*! wylacznik glowny*/
|
||||||
bool ConverterSwitch( bool State, int const Notify = command_range::consist );/*! wl/wyl przetwornicy*/
|
bool ConverterSwitch( bool State, int const Notify = range::consist );/*! wl/wyl przetwornicy*/
|
||||||
bool CompressorSwitch( bool State, int const Notify = command_range::consist );/*! wl/wyl sprezarki*/
|
bool CompressorSwitch( bool State, int const Notify = range::consist );/*! wl/wyl sprezarki*/
|
||||||
|
|
||||||
/*-funkcje typowe dla lokomotywy elektrycznej*/
|
/*-funkcje typowe dla lokomotywy elektrycznej*/
|
||||||
void ConverterCheck(); // przetwornica
|
void ConverterCheck( double const Timestep ); // przetwornica
|
||||||
bool FuseOn(void); //bezpiecznik nadamiary
|
bool FuseOn(void); //bezpiecznik nadamiary
|
||||||
bool FuseFlagCheck(void); // sprawdzanie flagi nadmiarowego
|
bool FuseFlagCheck(void); // sprawdzanie flagi nadmiarowego
|
||||||
void FuseOff(void); // wylaczenie nadmiarowego
|
void FuseOff(void); // wylaczenie nadmiarowego
|
||||||
@@ -1129,8 +1140,8 @@ public:
|
|||||||
bool AutoRelayCheck(void);//symulacja automatycznego rozruchu
|
bool AutoRelayCheck(void);//symulacja automatycznego rozruchu
|
||||||
|
|
||||||
bool ResistorsFlagCheck(void); //sprawdzenie kontrolki oporow rozruchowych NBMX
|
bool ResistorsFlagCheck(void); //sprawdzenie kontrolki oporow rozruchowych NBMX
|
||||||
bool PantFront( bool const State, int const Notify = command_range::consist ); //obsluga pantografou przedniego
|
bool PantFront( bool const State, int const Notify = range::consist ); //obsluga pantografou przedniego
|
||||||
bool PantRear( bool const State, int const Notify = command_range::consist ); //obsluga pantografu tylnego
|
bool PantRear( bool const State, int const Notify = range::consist ); //obsluga pantografu tylnego
|
||||||
|
|
||||||
/*-funkcje typowe dla lokomotywy spalinowej z przekladnia mechaniczna*/
|
/*-funkcje typowe dla lokomotywy spalinowej z przekladnia mechaniczna*/
|
||||||
bool dizel_EngageSwitch(double state);
|
bool dizel_EngageSwitch(double state);
|
||||||
|
|||||||
@@ -773,7 +773,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
|
|||||||
// wywalenie szybkiego z powodu niskiego ciśnienia
|
// wywalenie szybkiego z powodu niskiego ciśnienia
|
||||||
if( GetTrainsetVoltage() < 0.5 * EnginePowerSource.MaxVoltage ) {
|
if( GetTrainsetVoltage() < 0.5 * EnginePowerSource.MaxVoltage ) {
|
||||||
// to jest trochę proteza; zasilanie członu może być przez sprzęg WN
|
// to jest trochę proteza; zasilanie członu może być przez sprzęg WN
|
||||||
if( MainSwitch( false, ( TrainType == dt_EZT ? command_range::unit : command_range::local ) ) ) {
|
if( MainSwitch( false, ( TrainType == dt_EZT ? range::unit : range::local ) ) ) {
|
||||||
EventFlag = true;
|
EventFlag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1366,7 +1366,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
|
|||||||
Compressor = 0;
|
Compressor = 0;
|
||||||
CompressorFlag = false;
|
CompressorFlag = false;
|
||||||
};
|
};
|
||||||
ConverterCheck();
|
ConverterCheck(dt);
|
||||||
if (CompressorSpeed > 0.0) // sprężarka musi mieć jakąś niezerową wydajność
|
if (CompressorSpeed > 0.0) // sprężarka musi mieć jakąś niezerową wydajność
|
||||||
CompressorCheck(dt); //żeby rozważać jej załączenie i pracę
|
CompressorCheck(dt); //żeby rozważać jej załączenie i pracę
|
||||||
UpdateBrakePressure(dt);
|
UpdateBrakePressure(dt);
|
||||||
@@ -1522,7 +1522,7 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
|
|||||||
Compressor = 0;
|
Compressor = 0;
|
||||||
CompressorFlag = false;
|
CompressorFlag = false;
|
||||||
};
|
};
|
||||||
ConverterCheck();
|
ConverterCheck(dt);
|
||||||
if (CompressorSpeed > 0.0) // sprężarka musi mieć jakąś niezerową wydajność
|
if (CompressorSpeed > 0.0) // sprężarka musi mieć jakąś niezerową wydajność
|
||||||
CompressorCheck(dt); //żeby rozważać jej załączenie i pracę
|
CompressorCheck(dt); //żeby rozważać jej załączenie i pracę
|
||||||
UpdateBrakePressure(dt);
|
UpdateBrakePressure(dt);
|
||||||
@@ -1561,15 +1561,23 @@ double TMoverParameters::ShowEngineRotation(int VehN)
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void TMoverParameters::ConverterCheck()
|
// sprawdzanie przetwornicy
|
||||||
{ // sprawdzanie przetwornicy
|
void TMoverParameters::ConverterCheck( double const Timestep ) {
|
||||||
|
// TODO: move other converter checks here, to have it all in one place for potential device object
|
||||||
if( ( ConverterAllow )
|
if( ( ConverterAllow )
|
||||||
&& ( false == PantPressLockActive )
|
&& ( false == PantPressLockActive )
|
||||||
&& ( Mains ) ) {
|
&& ( Mains ) ) {
|
||||||
ConverterFlag = true;
|
// delay timer can be optionally configured, and is set anew whenever converter goes off
|
||||||
|
if( ConverterStartDelayTimer <= 0.0 ) {
|
||||||
|
ConverterFlag = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ConverterStartDelayTimer -= Timestep;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ConverterFlag = false;
|
ConverterFlag = false;
|
||||||
|
ConverterStartDelayTimer = static_cast<double>( ConverterStartDelay );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2087,10 +2095,10 @@ bool TMoverParameters::Sandbox( bool const State, int const Notify )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
// if requested pass the command on
|
// if requested pass the command on
|
||||||
auto const couplingtype =
|
auto const couplingtype =
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll );
|
ctrain_controll );
|
||||||
|
|
||||||
@@ -2348,11 +2356,11 @@ bool TMoverParameters::MainSwitch( bool const State, int const Notify )
|
|||||||
{
|
{
|
||||||
if( Mains ) {
|
if( Mains ) {
|
||||||
// jeśli był załączony
|
// jeśli był załączony
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
// wysłanie wyłączenia do pozostałych?
|
// wysłanie wyłączenia do pozostałych?
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"MainSwitch", int( State ), CabNo,
|
"MainSwitch", int( State ), CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
@@ -2360,11 +2368,11 @@ bool TMoverParameters::MainSwitch( bool const State, int const Notify )
|
|||||||
Mains = State;
|
Mains = State;
|
||||||
if( Mains ) {
|
if( Mains ) {
|
||||||
// jeśli został załączony
|
// jeśli został załączony
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
// wysłanie wyłączenia do pozostałych?
|
// wysłanie wyłączenia do pozostałych?
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"MainSwitch", int( State ), CabNo,
|
"MainSwitch", int( State ), CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
@@ -2399,19 +2407,19 @@ bool TMoverParameters::ConverterSwitch( bool State, int const Notify )
|
|||||||
CompressorAllow = ConverterAllow;
|
CompressorAllow = ConverterAllow;
|
||||||
}
|
}
|
||||||
if( ConverterAllow == true ) {
|
if( ConverterAllow == true ) {
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"ConverterSwitch", 1, CabNo,
|
"ConverterSwitch", 1, CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"ConverterSwitch", 0, CabNo,
|
"ConverterSwitch", 0, CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
@@ -2436,19 +2444,19 @@ bool TMoverParameters::CompressorSwitch( bool State, int const Notify )
|
|||||||
CS = true;
|
CS = true;
|
||||||
}
|
}
|
||||||
if( CompressorAllow == true ) {
|
if( CompressorAllow == true ) {
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"CompressorSwitch", 1, CabNo,
|
"CompressorSwitch", 1, CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"CompressorSwitch", 0, CabNo,
|
"CompressorSwitch", 0, CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
@@ -4165,7 +4173,7 @@ double TMoverParameters::TractionForce(double dt)
|
|||||||
if ( (std::max(GetTrainsetVoltage(), std::abs(Voltage)) < EnginePowerSource.CollectorParameters.MinV) ||
|
if ( (std::max(GetTrainsetVoltage(), std::abs(Voltage)) < EnginePowerSource.CollectorParameters.MinV) ||
|
||||||
(std::max(GetTrainsetVoltage(), std::abs(Voltage)) * EnginePowerSource.CollectorParameters.OVP >
|
(std::max(GetTrainsetVoltage(), std::abs(Voltage)) * EnginePowerSource.CollectorParameters.OVP >
|
||||||
EnginePowerSource.CollectorParameters.MaxV))
|
EnginePowerSource.CollectorParameters.MaxV))
|
||||||
if( MainSwitch( false, ( TrainType == dt_EZT ? command_range::unit : command_range::local ) ) ) // TODO: check whether we need to send this EMU-wide
|
if( MainSwitch( false, ( TrainType == dt_EZT ? range::unit : range::local ) ) ) // TODO: check whether we need to send this EMU-wide
|
||||||
EventFlag = true; // wywalanie szybkiego z powodu niewłaściwego napięcia
|
EventFlag = true; // wywalanie szybkiego z powodu niewłaściwego napięcia
|
||||||
|
|
||||||
if (((DynamicBrakeType == dbrake_automatic) || (DynamicBrakeType == dbrake_switch)) &&
|
if (((DynamicBrakeType == dbrake_automatic) || (DynamicBrakeType == dbrake_switch)) &&
|
||||||
@@ -4464,7 +4472,7 @@ double TMoverParameters::TractionForce(double dt)
|
|||||||
// nie wchodzić w funkcję bez potrzeby
|
// nie wchodzić w funkcję bez potrzeby
|
||||||
if( ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) < EnginePowerSource.CollectorParameters.MinV )
|
if( ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) < EnginePowerSource.CollectorParameters.MinV )
|
||||||
|| ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) > EnginePowerSource.CollectorParameters.MaxV + 200 ) ) {
|
|| ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) > EnginePowerSource.CollectorParameters.MaxV + 200 ) ) {
|
||||||
MainSwitch( false, ( TrainType == dt_EZT ? command_range::unit : command_range::local ) ); // TODO: check whether we need to send this EMU-wide
|
MainSwitch( false, ( TrainType == dt_EZT ? range::unit : range::local ) ); // TODO: check whether we need to send this EMU-wide
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpV = abs(nrot) * (PI * WheelDiameter) * 3.6; //*DirAbsolute*eimc[eimc_s_p]; - do przemyslenia dzialanie pp
|
tmpV = abs(nrot) * (PI * WheelDiameter) * 3.6; //*DirAbsolute*eimc[eimc_s_p]; - do przemyslenia dzialanie pp
|
||||||
@@ -4538,21 +4546,21 @@ double TMoverParameters::TractionForce(double dt)
|
|||||||
{
|
{
|
||||||
PosRatio = 0;
|
PosRatio = 0;
|
||||||
tmp = 4;
|
tmp = 4;
|
||||||
Sandbox( true, command_range::local );
|
Sandbox( true, range::local );
|
||||||
} // przeciwposlizg
|
} // przeciwposlizg
|
||||||
if ((abs((PosRatio + 9.80 * dizel_fill) * dmoment * 100) >
|
if ((abs((PosRatio + 9.80 * dizel_fill) * dmoment * 100) >
|
||||||
0.95 * Adhesive(RunningTrack.friction) * TotalMassxg))
|
0.95 * Adhesive(RunningTrack.friction) * TotalMassxg))
|
||||||
{
|
{
|
||||||
PosRatio = 0;
|
PosRatio = 0;
|
||||||
tmp = 9;
|
tmp = 9;
|
||||||
Sandbox( true, command_range::local );
|
Sandbox( true, range::local );
|
||||||
} // przeciwposlizg
|
} // przeciwposlizg
|
||||||
if ((SlippingWheels))
|
if ((SlippingWheels))
|
||||||
{
|
{
|
||||||
// PosRatio = -PosRatio * 0; // serio -0 ???
|
// PosRatio = -PosRatio * 0; // serio -0 ???
|
||||||
PosRatio = 0;
|
PosRatio = 0;
|
||||||
tmp = 9;
|
tmp = 9;
|
||||||
Sandbox( true, command_range::local );
|
Sandbox( true, range::local );
|
||||||
} // przeciwposlizg
|
} // przeciwposlizg
|
||||||
|
|
||||||
dizel_fill += Max0R(Min0R(PosRatio - dizel_fill, 0.1), -0.1) * 2 *
|
dizel_fill += Max0R(Min0R(PosRatio - dizel_fill, 0.1), -0.1) * 2 *
|
||||||
@@ -5190,22 +5198,22 @@ bool TMoverParameters::PantFront( bool const State, int const Notify )
|
|||||||
PantFrontUp = State;
|
PantFrontUp = State;
|
||||||
if( State == true ) {
|
if( State == true ) {
|
||||||
PantFrontStart = 0;
|
PantFrontStart = 0;
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
// wysłanie wyłączenia do pozostałych?
|
// wysłanie wyłączenia do pozostałych?
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"PantFront", 1, CabNo,
|
"PantFront", 1, CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PantFrontStart = 1;
|
PantFrontStart = 1;
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
// wysłanie wyłączenia do pozostałych?
|
// wysłanie wyłączenia do pozostałych?
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"PantFront", 0, CabNo,
|
"PantFront", 0, CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
@@ -5243,22 +5251,22 @@ bool TMoverParameters::PantRear( bool const State, int const Notify )
|
|||||||
PantRearUp = State;
|
PantRearUp = State;
|
||||||
if( State == true ) {
|
if( State == true ) {
|
||||||
PantRearStart = 0;
|
PantRearStart = 0;
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
// wysłanie wyłączenia do pozostałych?
|
// wysłanie wyłączenia do pozostałych?
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"PantRear", 1, CabNo,
|
"PantRear", 1, CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PantRearStart = 1;
|
PantRearStart = 1;
|
||||||
if( Notify != command_range::local ) {
|
if( Notify != range::local ) {
|
||||||
// wysłanie wyłączenia do pozostałych?
|
// wysłanie wyłączenia do pozostałych?
|
||||||
SendCtrlToNext(
|
SendCtrlToNext(
|
||||||
"PantRear", 0, CabNo,
|
"PantRear", 0, CabNo,
|
||||||
( Notify == command_range::unit ?
|
( Notify == range::unit ?
|
||||||
ctrain_controll | ctrain_depot :
|
ctrain_controll | ctrain_depot :
|
||||||
ctrain_controll ) );
|
ctrain_controll ) );
|
||||||
}
|
}
|
||||||
@@ -7048,6 +7056,20 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
|||||||
0;
|
0;
|
||||||
|
|
||||||
extract_value( StopBrakeDecc, "SBD", line, "" );
|
extract_value( StopBrakeDecc, "SBD", line, "" );
|
||||||
|
|
||||||
|
// converter
|
||||||
|
{
|
||||||
|
std::map<std::string, start> starts{
|
||||||
|
{ "Manual", start::manual },
|
||||||
|
{ "Automatic", start::automatic }
|
||||||
|
};
|
||||||
|
auto lookup = starts.find( extract_value( "ConverterStart", line ) );
|
||||||
|
ConverterStart =
|
||||||
|
lookup != starts.end() ?
|
||||||
|
lookup->second :
|
||||||
|
start::manual;
|
||||||
|
}
|
||||||
|
extract_value( ConverterStartDelay, "ConverterStartDelay", line, "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMoverParameters::LoadFIZ_Light( std::string const &line ) {
|
void TMoverParameters::LoadFIZ_Light( std::string const &line ) {
|
||||||
@@ -8148,7 +8170,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
|||||||
}
|
}
|
||||||
else if (Command == "Sandbox")
|
else if (Command == "Sandbox")
|
||||||
{
|
{
|
||||||
OK = Sandbox( CValue1 == 1, command_range::local );
|
OK = Sandbox( CValue1 == 1, range::local );
|
||||||
}
|
}
|
||||||
else if (Command == "CabSignal") /*SHP,Indusi*/
|
else if (Command == "CabSignal") /*SHP,Indusi*/
|
||||||
{ // Ra: to powinno działać tylko w członie obsadzonym
|
{ // Ra: to powinno działać tylko w członie obsadzonym
|
||||||
|
|||||||
602
Traction.cpp
602
Traction.cpp
@@ -116,25 +116,22 @@ void TTraction::Optimize()
|
|||||||
uiDisplayList = glGenLists(1);
|
uiDisplayList = glGenLists(1);
|
||||||
glNewList(uiDisplayList, GL_COMPILE);
|
glNewList(uiDisplayList, GL_COMPILE);
|
||||||
|
|
||||||
GfxRenderer.Bind(0);
|
|
||||||
// glColor3ub(0,0,0); McZapkie: to do render
|
|
||||||
|
|
||||||
// glPushMatrix();
|
|
||||||
// glTranslatef(pPosition.x,pPosition.y,pPosition.z);
|
|
||||||
|
|
||||||
if (Wires != 0)
|
if (Wires != 0)
|
||||||
{
|
{
|
||||||
// Dlugosc odcinka trakcji 'Winger
|
// Dlugosc odcinka trakcji 'Winger
|
||||||
double ddp = hypot(pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z);
|
double ddp = std::hypot(pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z);
|
||||||
|
|
||||||
if (Wires == 2)
|
if (Wires == 2)
|
||||||
WireOffset = 0;
|
WireOffset = 0;
|
||||||
// Przewoz jezdny 1 'Marcin
|
// Przewoz jezdny 1 'Marcin
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex3f(pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint1.y,
|
glVertex3f(
|
||||||
pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset,
|
||||||
glVertex3f(pPoint2.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint2.y,
|
pPoint1.y,
|
||||||
pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
||||||
|
glVertex3f(
|
||||||
|
pPoint2.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset,
|
||||||
|
pPoint2.y,
|
||||||
|
pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
||||||
glEnd();
|
glEnd();
|
||||||
// Nie wiem co 'Marcin
|
// Nie wiem co 'Marcin
|
||||||
Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2;
|
Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2;
|
||||||
@@ -146,24 +143,25 @@ void TTraction::Optimize()
|
|||||||
float f = step;
|
float f = step;
|
||||||
float mid = 0.5;
|
float mid = 0.5;
|
||||||
float t;
|
float t;
|
||||||
|
|
||||||
// Przewod nosny 'Marcin
|
// Przewod nosny 'Marcin
|
||||||
if (Wires != 1)
|
if (Wires > 1)
|
||||||
{
|
{
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex3f(pPoint3.x, pPoint3.y, pPoint3.z);
|
glVertex3f(pPoint3.x, pPoint3.y, pPoint3.z);
|
||||||
for (int i = 0; i < iNumSections - 1; i++)
|
for (int i = 0; i < iNumSections - 1; ++i)
|
||||||
{
|
{
|
||||||
pt3 = pPoint3 + v1 * f;
|
pt3 = pPoint3 + v1 * f;
|
||||||
t = (1 - fabs(f - mid) * 2);
|
t = (1 - std::fabs(f - mid) * 2);
|
||||||
if ((Wires < 4) || ((i != 0) && (i != iNumSections - 2)))
|
if ((Wires < 4) || ((i != 0) && (i != iNumSections - 2)))
|
||||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference, pt3.z);
|
glVertex3f(
|
||||||
|
pt3.x,
|
||||||
|
pt3.y - std::sqrt(t) * fHeightDifference,
|
||||||
|
pt3.z);
|
||||||
f += step;
|
f += step;
|
||||||
}
|
}
|
||||||
glVertex3f(pPoint4.x, pPoint4.y, pPoint4.z);
|
glVertex3f(pPoint4.x, pPoint4.y, pPoint4.z);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drugi przewod jezdny 'Winger
|
// Drugi przewod jezdny 'Winger
|
||||||
if (Wires > 2)
|
if (Wires > 2)
|
||||||
{
|
{
|
||||||
@@ -181,14 +179,17 @@ void TTraction::Optimize()
|
|||||||
{
|
{
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex3f(pPoint3.x, pPoint3.y - 0.65f * fHeightDifference, pPoint3.z);
|
glVertex3f(pPoint3.x, pPoint3.y - 0.65f * fHeightDifference, pPoint3.z);
|
||||||
for (int i = 0; i < iNumSections - 1; i++)
|
for (int i = 0; i < iNumSections - 1; ++i)
|
||||||
{
|
{
|
||||||
pt3 = pPoint3 + v1 * f;
|
pt3 = pPoint3 + v1 * f;
|
||||||
t = (1 - fabs(f - mid) * 2);
|
t = (1 - std::fabs(f - mid) * 2);
|
||||||
glVertex3f(
|
glVertex3f(
|
||||||
pt3.x,
|
pt3.x,
|
||||||
pt3.y - sqrt(t) * fHeightDifference -
|
pt3.y - std::sqrt( t ) * fHeightDifference - (
|
||||||
((i == 0) || (i == iNumSections - 2) ? 0.25f * fHeightDifference : +0.05),
|
( ( i == 0 )
|
||||||
|
|| ( i == iNumSections - 2 ) ) ?
|
||||||
|
0.25f * fHeightDifference :
|
||||||
|
0.05 ),
|
||||||
pt3.z);
|
pt3.z);
|
||||||
f += step;
|
f += step;
|
||||||
}
|
}
|
||||||
@@ -202,36 +203,47 @@ void TTraction::Optimize()
|
|||||||
if (Wires != 1)
|
if (Wires != 1)
|
||||||
{
|
{
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
for (int i = 0; i < iNumSections - 1; i++)
|
for (int i = 0; i < iNumSections - 1; ++i)
|
||||||
{
|
{
|
||||||
float flo, flo1;
|
float flo, flo1;
|
||||||
flo = (Wires == 4 ? 0.25f * fHeightDifference : 0);
|
flo = (Wires == 4 ? 0.25f * fHeightDifference : 0);
|
||||||
flo1 = (Wires == 4 ? +0.05 : 0);
|
flo1 = (Wires == 4 ? +0.05 : 0);
|
||||||
pt3 = pPoint3 + v1 * f;
|
pt3 = pPoint3 + v1 * f;
|
||||||
pt4 = pPoint1 + v2 * f;
|
pt4 = pPoint1 + v2 * f;
|
||||||
t = (1 - fabs(f - mid) * 2);
|
t = (1 - std::fabs(f - mid) * 2);
|
||||||
if ((i % 2) == 0)
|
if ((i % 2) == 0)
|
||||||
{
|
{
|
||||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference -
|
glVertex3f(
|
||||||
((i == 0) || (i == iNumSections - 2) ? flo : flo1),
|
pt3.x,
|
||||||
pt3.z);
|
pt3.y - std::sqrt(t) * fHeightDifference - ((i == 0) || (i == iNumSections - 2) ? flo : flo1),
|
||||||
glVertex3f(pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pt4.y,
|
pt3.z);
|
||||||
pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
glVertex3f(
|
||||||
|
pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset,
|
||||||
|
pt4.y,
|
||||||
|
pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference -
|
glVertex3f(
|
||||||
((i == 0) || (i == iNumSections - 2) ? flo : flo1),
|
pt3.x,
|
||||||
pt3.z);
|
pt3.y - std::sqrt(t) * fHeightDifference - ((i == 0) || (i == iNumSections - 2) ? flo : flo1),
|
||||||
glVertex3f(pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pt4.y,
|
pt3.z);
|
||||||
pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
glVertex3f(
|
||||||
|
pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset,
|
||||||
|
pt4.y,
|
||||||
|
pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
||||||
}
|
}
|
||||||
if ((Wires == 4) && ((i == 1) || (i == iNumSections - 3)))
|
if ((Wires == 4) && ((i == 1) || (i == iNumSections - 3)))
|
||||||
{
|
{
|
||||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference - 0.05, pt3.z);
|
glVertex3f(
|
||||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference, pt3.z);
|
pt3.x,
|
||||||
|
pt3.y - std::sqrt(t) * fHeightDifference - 0.05,
|
||||||
|
pt3.z);
|
||||||
|
glVertex3f(
|
||||||
|
pt3.x,
|
||||||
|
pt3.y - std::sqrt(t) * fHeightDifference,
|
||||||
|
pt3.z);
|
||||||
}
|
}
|
||||||
// endif;
|
|
||||||
f += step;
|
f += step;
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
@@ -249,146 +261,89 @@ void TTraction::InitCenter(vector3 Angles, vector3 pOrigin)
|
|||||||
void TTraction::RenderDL(float mgn) // McZapkie: mgn to odleglosc od obserwatora
|
void TTraction::RenderDL(float mgn) // McZapkie: mgn to odleglosc od obserwatora
|
||||||
{
|
{
|
||||||
// McZapkie: ustalanie przezroczystosci i koloru linii:
|
// McZapkie: ustalanie przezroczystosci i koloru linii:
|
||||||
if (Wires != 0 && !TestFlag(DamageFlag, 128)) // rysuj jesli sa druty i nie zerwana
|
if( Wires != 0 && !TestFlag( DamageFlag, 128 ) ) // rysuj jesli sa druty i nie zerwana
|
||||||
{
|
{
|
||||||
// glDisable(GL_LIGHTING); //aby nie używało wektorów normalnych do kolorowania
|
// setup
|
||||||
glColor4f(0, 0, 0, 1); // jak nieznany kolor to czarne nieprzezroczyste
|
GfxRenderer.Bind( 0 );
|
||||||
if (!Global::bSmoothTraction)
|
if( !Global::bSmoothTraction ) {
|
||||||
glDisable(GL_LINE_SMOOTH); // na liniach kiepsko wygląda - robi gradient
|
// na liniach kiepsko wygląda - robi gradient
|
||||||
float linealpha = 5000 * WireThickness / (mgn + 1.0); //*WireThickness
|
::glDisable( GL_LINE_SMOOTH );
|
||||||
if (linealpha > 1.2f)
|
|
||||||
linealpha = 1.2f; // zbyt grube nie są dobre
|
|
||||||
glLineWidth(linealpha);
|
|
||||||
if (linealpha > 1.0f)
|
|
||||||
linealpha = 1.0f;
|
|
||||||
// McZapkie-261102: kolor zalezy od materialu i zasniedzenia
|
|
||||||
float r, g, b;
|
|
||||||
switch (Material)
|
|
||||||
{ // Ra: kolory podzieliłem przez 2, bo po zmianie ambient za jasne były
|
|
||||||
// trzeba uwzględnić kierunek świecenia Słońca - tylko ze Słońcem widać kolor
|
|
||||||
case 1:
|
|
||||||
if (TestFlag(DamageFlag, 1))
|
|
||||||
{
|
|
||||||
r = 0.00000f;
|
|
||||||
g = 0.32549f;
|
|
||||||
b = 0.2882353f; // zielona miedź
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = 0.35098f;
|
|
||||||
g = 0.22549f;
|
|
||||||
b = 0.1f; // czerwona miedź
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (TestFlag(DamageFlag, 1))
|
|
||||||
{
|
|
||||||
r = 0.10f;
|
|
||||||
g = 0.10f;
|
|
||||||
b = 0.10f; // czarne Al
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = 0.25f;
|
|
||||||
g = 0.25f;
|
|
||||||
b = 0.25f; // srebrne Al
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// tymczasowo pokazanie zasilanych odcinków
|
|
||||||
case 4:
|
|
||||||
r = 0.5f;
|
|
||||||
g = 0.5f;
|
|
||||||
b = 1.0f;
|
|
||||||
break; // niebieskie z podłączonym zasilaniem
|
|
||||||
case 5:
|
|
||||||
r = 1.0f;
|
|
||||||
g = 0.0f;
|
|
||||||
b = 0.0f;
|
|
||||||
break; // czerwone z podłączonym zasilaniem 1
|
|
||||||
case 6:
|
|
||||||
r = 0.0f;
|
|
||||||
g = 1.0f;
|
|
||||||
b = 0.0f;
|
|
||||||
break; // zielone z podłączonym zasilaniem 2
|
|
||||||
case 7:
|
|
||||||
r = 1.0f;
|
|
||||||
g = 1.0f;
|
|
||||||
b = 0.0f;
|
|
||||||
break; //żółte z podłączonym zasilaniem z obu stron
|
|
||||||
}
|
}
|
||||||
if (DebugModeFlag)
|
float linealpha = 5000 * WireThickness / ( mgn + 1.0 ); //*WireThickness
|
||||||
if (hvParallel)
|
linealpha = std::min( 1.2f, linealpha ); // zbyt grube nie są dobre
|
||||||
{ // jeśli z bieżnią wspólną, to dodatkowo przyciemniamy
|
::glLineWidth( linealpha );
|
||||||
r *= 0.6f;
|
// McZapkie-261102: kolor zalezy od materialu i zasniedzenia
|
||||||
g *= 0.6f;
|
float
|
||||||
b *= 0.6f;
|
red{ 0.0f },
|
||||||
}
|
green{ 0.0f },
|
||||||
#ifdef EU07_USE_OLD_LIGHTING_MODEL
|
blue{ 0.0f };
|
||||||
r *= Global::ambientDayLight[ 0 ]; // w zaleźności od koloru swiatła
|
wire_color( red, green, blue );
|
||||||
g *= Global::ambientDayLight[ 1 ];
|
::glColor4f( red, green, blue, linealpha );
|
||||||
b *= Global::ambientDayLight[ 2 ];
|
// draw code
|
||||||
#else
|
|
||||||
r *= Global::DayLight.ambient[ 0 ]; // w zaleźności od koloru swiatła
|
|
||||||
g *= Global::DayLight.ambient[ 1 ];
|
|
||||||
b *= Global::DayLight.ambient[2];
|
|
||||||
#endif
|
|
||||||
if (linealpha > 1.0f)
|
|
||||||
linealpha = 1.0f; // trzeba ograniczyć do <=1
|
|
||||||
glColor4f(r, g, b, linealpha);
|
|
||||||
if (!uiDisplayList)
|
if (!uiDisplayList)
|
||||||
Optimize(); // generowanie DL w miarę potrzeby
|
Optimize(); // generowanie DL w miarę potrzeby
|
||||||
glCallList(uiDisplayList);
|
::glCallList(uiDisplayList);
|
||||||
glLineWidth(1.0);
|
// cleanup
|
||||||
glEnable(GL_LINE_SMOOTH);
|
::glLineWidth(1.0);
|
||||||
// glEnable(GL_LIGHTING); //bez tego się modele nie oświetlają
|
::glEnable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// przygotowanie tablic do skopiowania do VBO (zliczanie wierzchołków)
|
||||||
int TTraction::RaArrayPrepare()
|
int TTraction::RaArrayPrepare()
|
||||||
{ // przygotowanie tablic do skopiowania do VBO (zliczanie wierzchołków)
|
{
|
||||||
// if (bVisible) //o ile w ogóle widać
|
// jezdny
|
||||||
switch (Wires)
|
iLines = 2;
|
||||||
{
|
// przewod nosny
|
||||||
case 1:
|
if( Wires > 1 ) {
|
||||||
iLines = 2;
|
iLines += 2 + (
|
||||||
break;
|
Wires < 4 ?
|
||||||
case 2:
|
std::max( 0, iNumSections - 1 ) :
|
||||||
iLines = iNumSections ? 4 * (iNumSections)-2 + 2 : 4;
|
( iNumSections > 2 ?
|
||||||
break;
|
std::max( 0, iNumSections - 1 - 2 ) :
|
||||||
case 3:
|
std::max( 0, iNumSections - 1 - 1 ) ) );
|
||||||
iLines = iNumSections ? 4 * (iNumSections)-2 + 4 : 6;
|
}
|
||||||
break;
|
// drugi przewod jezdny
|
||||||
case 4:
|
if( Wires > 2 ) {
|
||||||
iLines = iNumSections ? 4 * (iNumSections)-2 + 6 : 8;
|
iLines += 2;
|
||||||
break;
|
}
|
||||||
default:
|
if( Wires == 4 ) {
|
||||||
iLines = 0;
|
iLines += 2 + std::max( 0, iNumSections - 1 );
|
||||||
|
}
|
||||||
|
// przewody pionowe (wieszaki)
|
||||||
|
if( Wires > 1 ) {
|
||||||
|
iLines += 2 * ( std::max( 0, iNumSections - 1 ) );
|
||||||
|
if( ( Wires == 4 )
|
||||||
|
&&( iNumSections > 0 ) ) {
|
||||||
|
iLines += (
|
||||||
|
iNumSections > 4 ?
|
||||||
|
4 :
|
||||||
|
2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// else iLines=0;
|
|
||||||
return iLines;
|
return iLines;
|
||||||
};
|
};
|
||||||
|
|
||||||
void TTraction::RaArrayFill(CVertNormTex *Vert)
|
void TTraction::RaArrayFill(CVertNormTex *Vert)
|
||||||
{ // wypełnianie tablic VBO
|
{ // wypełnianie tablic VBO
|
||||||
CVertNormTex *old = Vert;
|
double ddp = std::hypot(pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z);
|
||||||
double ddp = hypot(pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z);
|
|
||||||
if (Wires == 2)
|
if (Wires == 2)
|
||||||
WireOffset = 0;
|
WireOffset = 0;
|
||||||
// jezdny
|
// jezdny
|
||||||
Vert->x = pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
Vert->x = pPoint1.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset;
|
||||||
Vert->y = pPoint1.y;
|
Vert->y = pPoint1.y;
|
||||||
Vert->z = pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
Vert->z = pPoint1.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
||||||
++Vert;
|
++Vert;
|
||||||
Vert->x = pPoint2.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
Vert->x = pPoint2.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset;
|
||||||
Vert->y = pPoint2.y;
|
Vert->y = pPoint2.y;
|
||||||
Vert->z = pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
Vert->z = pPoint2.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
||||||
++Vert;
|
++Vert;
|
||||||
// Nie wiem co 'Marcin
|
// Nie wiem co 'Marcin
|
||||||
Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2;
|
Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2;
|
||||||
v1 = pPoint4 - pPoint3;
|
v1 = pPoint4 - pPoint3;
|
||||||
v2 = pPoint2 - pPoint1;
|
v2 = pPoint2 - pPoint1;
|
||||||
float step = 0;
|
float step = 0;
|
||||||
if (iNumSections > 0)
|
if( iNumSections > 0 )
|
||||||
step = 1.0f / (float)iNumSections;
|
step = 1.0f / (float)iNumSections;
|
||||||
float f = step;
|
float f = step;
|
||||||
float mid = 0.5;
|
float mid = 0.5;
|
||||||
@@ -400,18 +355,18 @@ void TTraction::RaArrayFill(CVertNormTex *Vert)
|
|||||||
Vert->y = pPoint3.y;
|
Vert->y = pPoint3.y;
|
||||||
Vert->z = pPoint3.z;
|
Vert->z = pPoint3.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
for (int i = 0; i < iNumSections - 1; i++)
|
for (int i = 0; i < iNumSections - 1; ++i)
|
||||||
{
|
{
|
||||||
pt3 = pPoint3 + v1 * f;
|
pt3 = pPoint3 + v1 * f;
|
||||||
t = (1 - fabs(f - mid) * 2);
|
t = (1 - std::fabs(f - mid) * 2);
|
||||||
Vert->x = pt3.x;
|
if( ( Wires < 4 )
|
||||||
Vert->y = pt3.y - sqrt(t) * fHeightDifference;
|
|| ( ( i != 0 )
|
||||||
Vert->z = pt3.z;
|
&& ( i != iNumSections - 2 ) ) ) {
|
||||||
++Vert;
|
Vert->x = pt3.x;
|
||||||
Vert->x = pt3.x; // drugi raz, bo nie jest line_strip
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference;
|
||||||
Vert->y = pt3.y - sqrt(t) * fHeightDifference;
|
Vert->z = pt3.z;
|
||||||
Vert->z = pt3.z;
|
++Vert;
|
||||||
++Vert;
|
}
|
||||||
f += step;
|
f += step;
|
||||||
}
|
}
|
||||||
Vert->x = pPoint4.x;
|
Vert->x = pPoint4.x;
|
||||||
@@ -420,7 +375,7 @@ void TTraction::RaArrayFill(CVertNormTex *Vert)
|
|||||||
++Vert;
|
++Vert;
|
||||||
}
|
}
|
||||||
// Drugi przewod jezdny 'Winger
|
// Drugi przewod jezdny 'Winger
|
||||||
if (Wires == 3)
|
if (Wires > 2)
|
||||||
{
|
{
|
||||||
Vert->x = pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
Vert->x = pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
||||||
Vert->y = pPoint1.y;
|
Vert->y = pPoint1.y;
|
||||||
@@ -431,124 +386,145 @@ void TTraction::RaArrayFill(CVertNormTex *Vert)
|
|||||||
Vert->z = pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
Vert->z = pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
||||||
++Vert;
|
++Vert;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = step;
|
f = step;
|
||||||
// Przewody pionowe (wieszaki) 'Marcin, poprawki na 2 przewody jezdne 'Winger
|
|
||||||
if (Wires > 1)
|
if( Wires == 4 ) {
|
||||||
{
|
Vert->x = pPoint3.x;
|
||||||
for (int i = 0; i < iNumSections - 1; i++)
|
Vert->y = pPoint3.y - 0.65f * fHeightDifference;
|
||||||
{
|
Vert->z = pPoint3.z;
|
||||||
|
++Vert;
|
||||||
|
for( int i = 0; i < iNumSections - 1; ++i ) {
|
||||||
pt3 = pPoint3 + v1 * f;
|
pt3 = pPoint3 + v1 * f;
|
||||||
pt4 = pPoint1 + v2 * f;
|
t = ( 1 - std::fabs( f - mid ) * 2 );
|
||||||
t = (1 - fabs(f - mid) * 2);
|
|
||||||
Vert->x = pt3.x;
|
Vert->x = pt3.x;
|
||||||
Vert->y = pt3.y - sqrt(t) * fHeightDifference;
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - (
|
||||||
|
( ( i == 0 )
|
||||||
|
|| ( i == iNumSections - 2 ) ) ?
|
||||||
|
0.25f * fHeightDifference :
|
||||||
|
0.05 );
|
||||||
Vert->z = pt3.z;
|
Vert->z = pt3.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
if ((i % 2) == 0)
|
f += step;
|
||||||
{
|
}
|
||||||
Vert->x = pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
Vert->x = pPoint4.x;
|
||||||
Vert->y = pt4.y;
|
Vert->y = pPoint4.y - 0.65f * fHeightDifference;
|
||||||
Vert->z = pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
Vert->z = pPoint4.z;
|
||||||
}
|
}
|
||||||
else
|
f = step;
|
||||||
{
|
|
||||||
Vert->x = pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
// Przewody pionowe (wieszaki) 'Marcin, poprawki na 2 przewody jezdne 'Winger
|
||||||
Vert->y = pt4.y;
|
if (Wires > 1)
|
||||||
Vert->z = pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
{
|
||||||
}
|
for (int i = 0; i < iNumSections - 1; ++i)
|
||||||
++Vert;
|
{
|
||||||
|
float flo, flo1;
|
||||||
|
flo = ( Wires == 4 ? 0.25f * fHeightDifference : 0 );
|
||||||
|
flo1 = ( Wires == 4 ? +0.05 : 0 );
|
||||||
|
pt3 = pPoint3 + v1 * f;
|
||||||
|
pt4 = pPoint1 + v2 * f;
|
||||||
|
t = (1 - std::fabs(f - mid) * 2);
|
||||||
|
|
||||||
|
if( ( i % 2 ) == 0 ) {
|
||||||
|
Vert->x = pt3.x;
|
||||||
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 );
|
||||||
|
Vert->z = pt3.z;
|
||||||
|
++Vert;
|
||||||
|
Vert->x = pt4.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset;
|
||||||
|
Vert->y = pt4.y;
|
||||||
|
Vert->z = pt4.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
||||||
|
++Vert;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Vert->x = pt3.x;
|
||||||
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 );
|
||||||
|
Vert->z = pt3.z;
|
||||||
|
++Vert;
|
||||||
|
Vert->x = pt4.x + ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset;
|
||||||
|
Vert->y = pt4.y;
|
||||||
|
Vert->z = pt4.z + ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
||||||
|
++Vert;
|
||||||
|
}
|
||||||
|
if( ( ( Wires == 4 )
|
||||||
|
&& ( ( i == 1 )
|
||||||
|
|| ( i == iNumSections - 3 ) ) ) ) {
|
||||||
|
Vert->x = pt3.x;
|
||||||
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - 0.05;
|
||||||
|
Vert->z = pt3.z;
|
||||||
|
++Vert;
|
||||||
|
Vert->x = pt3.x;
|
||||||
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference;
|
||||||
|
Vert->z = pt3.z;
|
||||||
|
++Vert;
|
||||||
|
}
|
||||||
f += step;
|
f += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Vert - old) != iLines)
|
|
||||||
WriteLog("!!! Wygenerowano punktów " + std::to_string(Vert - old) + ", powinno być " +
|
|
||||||
std::to_string(iLines));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TTraction::RenderVBO(float mgn, int iPtr)
|
void TTraction::RenderVBO(float mgn, int iPtr)
|
||||||
{ // renderowanie z użyciem VBO
|
{ // renderowanie z użyciem VBO
|
||||||
if (Wires != 0 && !TestFlag(DamageFlag, 128)) // rysuj jesli sa druty i nie zerwana
|
if (Wires != 0 && !TestFlag(DamageFlag, 128)) // rysuj jesli sa druty i nie zerwana
|
||||||
{
|
{
|
||||||
|
// setup
|
||||||
GfxRenderer.Bind(0);
|
GfxRenderer.Bind(0);
|
||||||
glDisable(GL_LIGHTING); // aby nie używało wektorów normalnych do kolorowania
|
if( !Global::bSmoothTraction ) {
|
||||||
glColor4f(0, 0, 0, 1); // jak nieznany kolor to czarne nieprzezroczyste
|
// na liniach kiepsko wygląda - robi gradient
|
||||||
if (!Global::bSmoothTraction)
|
::glDisable( GL_LINE_SMOOTH );
|
||||||
glDisable(GL_LINE_SMOOTH); // na liniach kiepsko wygląda - robi gradient
|
|
||||||
float linealpha = 5000 * WireThickness / (mgn + 1.0); //*WireThickness
|
|
||||||
if (linealpha > 1.2f)
|
|
||||||
linealpha = 1.2f; // zbyt grube nie są dobre
|
|
||||||
glLineWidth(linealpha);
|
|
||||||
// McZapkie-261102: kolor zalezy od materialu i zasniedzenia
|
|
||||||
float r, g, b;
|
|
||||||
switch (Material)
|
|
||||||
{ // Ra: kolory podzieliłem przez 2, bo po zmianie ambient za jasne były
|
|
||||||
// trzeba uwzględnić kierunek świecenia Słońca - tylko ze Słońcem widać kolor
|
|
||||||
case 1:
|
|
||||||
if (TestFlag(DamageFlag, 1))
|
|
||||||
{
|
|
||||||
r = 0.00000f;
|
|
||||||
g = 0.32549f;
|
|
||||||
b = 0.2882353f; // zielona miedź
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = 0.35098f;
|
|
||||||
g = 0.22549f;
|
|
||||||
b = 0.1f; // czerwona miedź
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (TestFlag(DamageFlag, 1))
|
|
||||||
{
|
|
||||||
r = 0.10f;
|
|
||||||
g = 0.10f;
|
|
||||||
b = 0.10f; // czarne Al
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = 0.25f;
|
|
||||||
g = 0.25f;
|
|
||||||
b = 0.25f; // srebrne Al
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// tymczasowo pokazanie zasilanych odcinków
|
|
||||||
case 4:
|
|
||||||
r = 0.5f;
|
|
||||||
g = 0.5f;
|
|
||||||
b = 1.0f;
|
|
||||||
break; // niebieskie z podłączonym zasilaniem
|
|
||||||
case 5:
|
|
||||||
r = 1.0f;
|
|
||||||
g = 0.0f;
|
|
||||||
b = 0.0f;
|
|
||||||
break; // czerwone z podłączonym zasilaniem 1
|
|
||||||
case 6:
|
|
||||||
r = 0.0f;
|
|
||||||
g = 1.0f;
|
|
||||||
b = 0.0f;
|
|
||||||
break; // zielone z podłączonym zasilaniem 2
|
|
||||||
case 7:
|
|
||||||
r = 1.0f;
|
|
||||||
g = 1.0f;
|
|
||||||
b = 0.0f;
|
|
||||||
break; //żółte z podłączonym zasilaniem z obu stron
|
|
||||||
}
|
}
|
||||||
#ifdef EU07_USE_OLD_LIGHTING_MODEL
|
float linealpha = 5000 * WireThickness / (mgn + 1.0); //*WireThickness
|
||||||
r *= Global::ambientDayLight[ 0 ]; // w zaleźności od koloru swiatła
|
linealpha = std::min( 1.2f, linealpha ); // zbyt grube nie są dobre
|
||||||
g *= Global::ambientDayLight[ 1 ];
|
::glLineWidth(linealpha);
|
||||||
b *= Global::ambientDayLight[ 2 ];
|
// McZapkie-261102: kolor zalezy od materialu i zasniedzenia
|
||||||
#else
|
float
|
||||||
r *= Global::DayLight.ambient[ 0 ]; // w zaleźności od koloru swiatła
|
red{ 0.0f },
|
||||||
g *= Global::DayLight.ambient[ 1 ];
|
green{ 0.0f },
|
||||||
b *= Global::DayLight.ambient[ 2 ];
|
blue{ 0.0f };
|
||||||
#endif
|
wire_color( red, green, blue );
|
||||||
if (linealpha > 1.0f)
|
::glColor4f(red, green, blue, linealpha);
|
||||||
linealpha = 1.0f; // trzeba ograniczyć do <=1
|
// draw code
|
||||||
glColor4f(r, g, b, linealpha);
|
// jezdny
|
||||||
glDrawArrays(GL_LINES, iPtr, iLines);
|
::glDrawArrays( GL_LINE_STRIP, iPtr, 2 );
|
||||||
glLineWidth(1.0);
|
iPtr += 2;
|
||||||
glEnable(GL_LINE_SMOOTH);
|
// przewod nosny
|
||||||
glEnable(GL_LIGHTING); // bez tego się modele nie oświetlają
|
if( Wires > 1 ) {
|
||||||
|
auto const piececount = 2 + (
|
||||||
|
Wires < 4 ?
|
||||||
|
std::max( 0 , iNumSections - 1 ) :
|
||||||
|
( iNumSections > 2 ?
|
||||||
|
std::max( 0, iNumSections - 1 - 2 ) :
|
||||||
|
std::max( 0, iNumSections - 1 - 1 ) ) );
|
||||||
|
::glDrawArrays( GL_LINE_STRIP, iPtr, piececount );
|
||||||
|
iPtr += piececount;
|
||||||
|
}
|
||||||
|
// drugi przewod jezdny
|
||||||
|
if( Wires > 2 ) {
|
||||||
|
::glDrawArrays( GL_LINE_STRIP, iPtr, 2 );
|
||||||
|
iPtr += 2;
|
||||||
|
}
|
||||||
|
if( Wires == 4 ) {
|
||||||
|
auto const piececount = 2 + std::max( 0, iNumSections - 1 );
|
||||||
|
::glDrawArrays( GL_LINE_STRIP, iPtr, piececount );
|
||||||
|
iPtr += piececount;
|
||||||
|
}
|
||||||
|
// przewody pionowe (wieszaki)
|
||||||
|
if( Wires != 1 ) {
|
||||||
|
auto piececount = 2 * std::max( 0, iNumSections - 1 );
|
||||||
|
if( ( Wires == 4 )
|
||||||
|
&& ( iNumSections > 0 ) ) {
|
||||||
|
piececount += (
|
||||||
|
iNumSections > 4 ?
|
||||||
|
4 :
|
||||||
|
2 );
|
||||||
|
}
|
||||||
|
if( piececount > 0 ) {
|
||||||
|
::glDrawArrays( GL_LINES, iPtr, piececount );
|
||||||
|
iPtr += piececount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// cleanup
|
||||||
|
::glLineWidth(1.0);
|
||||||
|
::glEnable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -619,11 +595,16 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
|
|||||||
else
|
else
|
||||||
ps = psPower[d ^ 1]; // zasilacz od przeciwnej strony niż idzie analiza
|
ps = psPower[d ^ 1]; // zasilacz od przeciwnej strony niż idzie analiza
|
||||||
d = iNext[d]; // kierunek
|
d = iNext[d]; // kierunek
|
||||||
// double r; //sumaryczna rezystancja
|
#ifdef EU07_USE_OLD_TRACTIONPOWER_CODE
|
||||||
if (DebugModeFlag) // tylko podczas testów
|
if (DebugModeFlag) // tylko podczas testów
|
||||||
Material = 4; // pokazanie, że to przęsło ma podłączone zasilanie
|
Material = 4; // pokazanie, że to przęsło ma podłączone zasilanie
|
||||||
|
#else
|
||||||
|
// TBD, TODO: we don't need to maintain 4-7 value range as it's part of legacy system
|
||||||
|
PowerState = 4;
|
||||||
|
#endif
|
||||||
while (t ? !t->psPower[d] : false) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza
|
while (t ? !t->psPower[d] : false) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza
|
||||||
{ // ustawienie zasilacza i policzenie rezystancji zastępczej
|
{ // ustawienie zasilacza i policzenie rezystancji zastępczej
|
||||||
|
#ifdef EU07_USE_OLD_TRACTIONPOWER_CODE
|
||||||
if (DebugModeFlag) // tylko podczas testów
|
if (DebugModeFlag) // tylko podczas testów
|
||||||
if (t->Material != 4) // przęsła zasilającego nie modyfikować
|
if (t->Material != 4) // przęsła zasilającego nie modyfikować
|
||||||
{
|
{
|
||||||
@@ -631,6 +612,16 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
|
|||||||
t->Material = 4; // tymczasowo, aby zmieniła kolor
|
t->Material = 4; // tymczasowo, aby zmieniła kolor
|
||||||
t->Material |= d ? 2 : 1; // kolor zależny od strony, z której jest zasilanie
|
t->Material |= d ? 2 : 1; // kolor zależny od strony, z której jest zasilanie
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if( t->PowerState != 4 ) {
|
||||||
|
// przęsła zasilającego nie modyfikować
|
||||||
|
if( t->PowerState < 4 ) {
|
||||||
|
// tymczasowo, aby zmieniła kolor
|
||||||
|
t->PowerState = 4;
|
||||||
|
}
|
||||||
|
t->PowerState |= d ? 2 : 1; // kolor zależny od strony, z której jest zasilanie
|
||||||
|
}
|
||||||
|
#endif
|
||||||
t->psPower[d] = ps; // skopiowanie wskaźnika zasilacza od danej strony
|
t->psPower[d] = ps; // skopiowanie wskaźnika zasilacza od danej strony
|
||||||
t->fResistance[d] = r; // wpisanie rezystancji w kierunku tego zasilacza
|
t->fResistance[d] = r; // wpisanie rezystancji w kierunku tego zasilacza
|
||||||
r += t->fResistivity * Length3(t->vParametric); // doliczenie oporu kolejnego odcinka
|
r += t->fResistivity * Length3(t->vParametric); // doliczenie oporu kolejnego odcinka
|
||||||
@@ -716,3 +707,84 @@ double TTraction::VoltageGet(double u, double i)
|
|||||||
return psPower[1]->CurrentGet(res + r1t) * res;
|
return psPower[1]->CurrentGet(res + r1t) * res;
|
||||||
return 0.0; // gdy nie podłączony wcale?
|
return 0.0; // gdy nie podłączony wcale?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
TTraction::wire_color( float &Red, float &Green, float &Blue ) const {
|
||||||
|
|
||||||
|
if( false == DebugModeFlag ) {
|
||||||
|
switch( Material ) { // Ra: kolory podzieliłem przez 2, bo po zmianie ambient za jasne były
|
||||||
|
// trzeba uwzględnić kierunek świecenia Słońca - tylko ze Słońcem widać kolor
|
||||||
|
case 1: {
|
||||||
|
if( TestFlag( DamageFlag, 1 ) ) {
|
||||||
|
Red = 0.00000f;
|
||||||
|
Green = 0.32549f;
|
||||||
|
Blue = 0.2882353f; // zielona miedź
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Red = 0.35098f;
|
||||||
|
Green = 0.22549f;
|
||||||
|
Blue = 0.1f; // czerwona miedź
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
if( TestFlag( DamageFlag, 1 ) ) {
|
||||||
|
Red = 0.10f;
|
||||||
|
Green = 0.10f;
|
||||||
|
Blue = 0.10f; // czarne Al
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Red = 0.25f;
|
||||||
|
Green = 0.25f;
|
||||||
|
Blue = 0.25f; // srebrne Al
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {break; }
|
||||||
|
}
|
||||||
|
// w zaleźności od koloru swiatła
|
||||||
|
Red *= Global::DayLight.ambient[ 0 ];
|
||||||
|
Green *= Global::DayLight.ambient[ 1 ];
|
||||||
|
Blue *= Global::DayLight.ambient[ 2 ];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// tymczasowo pokazanie zasilanych odcinków
|
||||||
|
switch( PowerState ) {
|
||||||
|
|
||||||
|
case 4: {
|
||||||
|
// niebieskie z podłączonym zasilaniem
|
||||||
|
Red = 0.5f;
|
||||||
|
Green = 0.5f;
|
||||||
|
Blue = 1.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: {
|
||||||
|
// czerwone z podłączonym zasilaniem 1
|
||||||
|
Red = 1.0f;
|
||||||
|
Green = 0.0f;
|
||||||
|
Blue = 0.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 6: {
|
||||||
|
// zielone z podłączonym zasilaniem 2
|
||||||
|
Red = 0.0f;
|
||||||
|
Green = 1.0f;
|
||||||
|
Blue = 0.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 7: {
|
||||||
|
//żółte z podłączonym zasilaniem z obu stron
|
||||||
|
Red = 1.0f;
|
||||||
|
Green = 1.0f;
|
||||||
|
Blue = 0.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: { break; }
|
||||||
|
}
|
||||||
|
if( hvParallel ) { // jeśli z bieżnią wspólną, to dodatkowo przyciemniamy
|
||||||
|
Red *= 0.6f;
|
||||||
|
Green *= 0.6f;
|
||||||
|
Blue *= 0.6f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,8 +54,7 @@ class TTraction
|
|||||||
TTraction *hvParallel = nullptr; // jednokierunkowa i zapętlona lista przęseł ewentualnej bieżni wspólnej
|
TTraction *hvParallel = nullptr; // jednokierunkowa i zapętlona lista przęseł ewentualnej bieżni wspólnej
|
||||||
float fResistance[2]; // rezystancja zastępcza do punktu zasilania (0: przęsło zasilane, <0: do policzenia)
|
float fResistance[2]; // rezystancja zastępcza do punktu zasilania (0: przęsło zasilane, <0: do policzenia)
|
||||||
int iTries = 0;
|
int iTries = 0;
|
||||||
// bool bVisible;
|
int PowerState{ 0 }; // type of incoming power, if any
|
||||||
// DWORD dwFlags;
|
|
||||||
|
|
||||||
void Optimize();
|
void Optimize();
|
||||||
|
|
||||||
@@ -78,5 +77,7 @@ class TTraction
|
|||||||
void ResistanceCalc(int d = -1, double r = 0, TTractionPowerSource *ps = NULL);
|
void ResistanceCalc(int d = -1, double r = 0, TTractionPowerSource *ps = NULL);
|
||||||
void PowerSet(TTractionPowerSource *ps);
|
void PowerSet(TTractionPowerSource *ps);
|
||||||
double VoltageGet(double u, double i);
|
double VoltageGet(double u, double i);
|
||||||
|
private:
|
||||||
|
void wire_color( float &Red, float &Green, float &Blue ) const;
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
18
Train.cpp
18
Train.cpp
@@ -1600,7 +1600,7 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com
|
|||||||
if( Train->mvControlled->EngineType != DieselEngine ) {
|
if( Train->mvControlled->EngineType != DieselEngine ) {
|
||||||
if( Train->mvControlled->MainSwitch( true ) ) {
|
if( Train->mvControlled->MainSwitch( true ) ) {
|
||||||
// side-effects
|
// side-effects
|
||||||
Train->mvControlled->ConverterSwitch( Train->ggConverterButton.GetValue() > 0.5 );
|
Train->mvControlled->ConverterSwitch( ( Train->ggConverterButton.GetValue() > 0.5 ) || ( Train->mvControlled->ConverterStart == start::automatic ) );
|
||||||
Train->mvControlled->CompressorSwitch( Train->ggCompressorButton.GetValue() > 0.5 );
|
Train->mvControlled->CompressorSwitch( Train->ggCompressorButton.GetValue() > 0.5 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1636,6 +1636,11 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com
|
|||||||
|
|
||||||
void TTrain::OnCommand_convertertoggle( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_convertertoggle( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
|
if( Train->mvControlled->ConverterStart == start::automatic ) {
|
||||||
|
// let the automatic thing do its automatic thing...
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||||
if( ( false == Train->mvControlled->ConverterAllow )
|
if( ( false == Train->mvControlled->ConverterAllow )
|
||||||
@@ -3680,7 +3685,7 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
// TODO: check whether it should affect entire consist for EMU
|
// TODO: check whether it should affect entire consist for EMU
|
||||||
// TODO: check whether it should happen if there's power supplied alternatively through hvcouplers
|
// TODO: check whether it should happen if there's power supplied alternatively through hvcouplers
|
||||||
// TODO: potentially move this to the mover module, as there isn't much reason to have this dependent on the operator presence
|
// TODO: potentially move this to the mover module, as there isn't much reason to have this dependent on the operator presence
|
||||||
mvControlled->MainSwitch( false, ( mvControlled->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
|
mvControlled->MainSwitch( false, ( mvControlled->TrainType == dt_EZT ? range::unit : range::local ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3711,7 +3716,7 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
{
|
{
|
||||||
mvControlled->ConvOvldFlag = true;
|
mvControlled->ConvOvldFlag = true;
|
||||||
if (mvControlled->TrainType != dt_EZT)
|
if (mvControlled->TrainType != dt_EZT)
|
||||||
mvControlled->MainSwitch( false, ( mvControlled->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
|
mvControlled->MainSwitch( false, ( mvControlled->TrainType == dt_EZT ? range::unit : range::local ) );
|
||||||
}
|
}
|
||||||
else if( fConverterTimer >= fConverterPrzekaznik ) {
|
else if( fConverterTimer >= fConverterPrzekaznik ) {
|
||||||
// changed switch from always true to take into account state of the compressor switch
|
// changed switch from always true to take into account state of the compressor switch
|
||||||
@@ -4440,9 +4445,10 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
tmp = DynamicObject->PrevConnected;
|
tmp = DynamicObject->PrevConnected;
|
||||||
|
|
||||||
if (tmp)
|
if (tmp)
|
||||||
if (tmp->MoverParameters->Mains)
|
if ( mvControlled->Battery || mvControlled->ConverterFlag )
|
||||||
{
|
{
|
||||||
btLampkaWylSzybkiB.TurnOn();
|
btLampkaWylSzybkiB.Turn( tmp->MoverParameters->Mains );
|
||||||
|
|
||||||
btLampkaOporyB.Turn(tmp->MoverParameters->ResistorsFlagCheck());
|
btLampkaOporyB.Turn(tmp->MoverParameters->ResistorsFlagCheck());
|
||||||
btLampkaBezoporowaB.Turn(
|
btLampkaBezoporowaB.Turn(
|
||||||
tmp->MoverParameters->ResistorsFlagCheck() ||
|
tmp->MoverParameters->ResistorsFlagCheck() ||
|
||||||
@@ -5312,7 +5318,7 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
switch (LampkaUniversal3_typ)
|
switch (LampkaUniversal3_typ)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
btLampkaUniversal3.Turn(mvControlled->Battery);
|
btLampkaUniversal3.Turn( mvControlled->Battery || mvControlled->ConverterFlag );
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
btLampkaUniversal3.Turn(mvControlled->Mains);
|
btLampkaUniversal3.Turn(mvControlled->Mains);
|
||||||
|
|||||||
Reference in New Issue
Block a user