mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-20 11:29:18 +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
|
||||
/*
|
||||
// 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->PantRear( 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 ? range::unit : range::local ) );
|
||||
*/
|
||||
if( MoverParameters->TrainType != dt_EZT ) {
|
||||
// pressure switch safety measure -- open the line breaker, unless there's alternate source of traction voltage
|
||||
if( MoverParameters->GetTrainsetVoltage() < 0.5 * MoverParameters->EnginePowerSource.MaxVoltage ) {
|
||||
// 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 {
|
||||
@@ -2473,7 +2473,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
// and prevents their activation until pressure switch is set again
|
||||
MoverParameters->PantPressLockActive = true;
|
||||
// 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
|
||||
MoverParameters->PantPressSwitchActive = false;
|
||||
@@ -2936,7 +2936,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
&& ( MoverParameters->EngineType != DieselEngine )
|
||||
&& ( MoverParameters->EngineType != WheelsDriven ) )
|
||||
{ // 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
|
||||
// NOTE: we turn off entire EMU, but only the affected unit for other multi-unit consists
|
||||
MoverParameters->EventFlag = true;
|
||||
@@ -2945,8 +2945,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
// 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
|
||||
/*
|
||||
MoverParameters->PantFront( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
|
||||
MoverParameters->PantRear( 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 ? range::unit : range::local ) );
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
54
Ground.cpp
54
Ground.cpp
@@ -285,8 +285,7 @@ void TGroundNode::MoveMe(vector3 pPosition)
|
||||
void TGroundNode::RaRenderVBO()
|
||||
{ // renderowanie z domyslnego bufora VBO
|
||||
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
|
||||
}
|
||||
|
||||
@@ -2248,31 +2247,19 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
case GL_LINES:
|
||||
case GL_LINE_STRIP:
|
||||
case GL_LINE_LOOP: {
|
||||
parser->getTokens( 3 );
|
||||
*parser >> tmp->Diffuse[ 0 ] >> tmp->Diffuse[ 1 ] >> tmp->Diffuse[ 2 ];
|
||||
// tmp->Diffuse[0]=Parser->GetNextSymbol().ToDouble()/255;
|
||||
// tmp->Diffuse[1]=Parser->GetNextSymbol().ToDouble()/255;
|
||||
// tmp->Diffuse[2]=Parser->GetNextSymbol().ToDouble()/255;
|
||||
parser->getTokens();
|
||||
*parser >> tmp->fLineThickness;
|
||||
parser->getTokens( 4 );
|
||||
*parser
|
||||
>> tmp->Diffuse[ 0 ]
|
||||
>> tmp->Diffuse[ 1 ]
|
||||
>> tmp->Diffuse[ 2 ]
|
||||
>> tmp->fLineThickness;
|
||||
TempVerts.clear();
|
||||
TGroundVertex vertex;
|
||||
i = 0;
|
||||
parser->getTokens();
|
||||
*parser >> token;
|
||||
do {
|
||||
str = token;
|
||||
/*
|
||||
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() );
|
||||
vertex.Point.x = std::atof( token.c_str() );
|
||||
parser->getTokens( 2 );
|
||||
*parser
|
||||
>> vertex.Point.y
|
||||
@@ -2328,27 +2315,19 @@ TSubRect * TGround::GetSubRect(int iCol, int iRow)
|
||||
TEvent * TGround::FindEvent(const std::string &asEventName)
|
||||
{
|
||||
auto const lookup = m_eventmap.find( asEventName );
|
||||
return
|
||||
return (
|
||||
lookup != m_eventmap.end() ?
|
||||
lookup->second :
|
||||
nullptr;
|
||||
/* //powolna wyszukiwarka
|
||||
for (TEvent *Current=RootEvent;Current;Current=Current->Next2)
|
||||
{
|
||||
if (Current->asName==asEventName)
|
||||
return Current;
|
||||
}
|
||||
return NULL;
|
||||
*/
|
||||
lookup->second :
|
||||
nullptr );
|
||||
}
|
||||
|
||||
TEvent * TGround::FindEventScan( std::string const &asEventName )
|
||||
{ // wyszukanie eventu z opcją utworzenia niejawnego dla komórek skanowanych
|
||||
auto const lookup = m_eventmap.find( asEventName );
|
||||
auto e =
|
||||
auto e = (
|
||||
lookup != m_eventmap.end() ?
|
||||
lookup->second :
|
||||
nullptr;
|
||||
lookup->second :
|
||||
nullptr );
|
||||
if (e)
|
||||
return e; // jak istnieje, to w porządku
|
||||
if (asEventName.rfind(":scan") != std::string::npos) // jeszcze może być event niejawny
|
||||
@@ -4290,11 +4269,6 @@ bool TGround::CheckQuery()
|
||||
return true;
|
||||
}
|
||||
|
||||
void TGround::OpenGLUpdate(HDC hDC)
|
||||
{
|
||||
SwapBuffers(hDC); // swap buffers (double buffering)
|
||||
};
|
||||
|
||||
void TGround::UpdatePhys(double dt, int iter)
|
||||
{ // aktualizacja fizyki stałym krokiem: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń
|
||||
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 *nLastOfType[TP_LAST]; //ostatnia
|
||||
TSubRect srGlobal; // zawiera obiekty globalne (na razie wyzwalacze czasowe)
|
||||
int hh = 0,
|
||||
mm = 0; // ustawienia czasu
|
||||
// int tracks,tracksfar; //liczniki torów
|
||||
typedef std::unordered_map<std::string, TEvent *> event_map;
|
||||
event_map m_eventmap;
|
||||
@@ -374,7 +372,6 @@ class TGround
|
||||
void TrackJoin(TGroundNode *Current);
|
||||
|
||||
private:
|
||||
void OpenGLUpdate(HDC hDC);
|
||||
void RaTriangleDivider(TGroundNode *node);
|
||||
void Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
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_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
|
||||
// possible coupling types; can be combined
|
||||
enum coupling {
|
||||
faux = 0x0,
|
||||
coupler = 0x1,
|
||||
@@ -150,11 +151,16 @@ enum coupling {
|
||||
heating = 0x40,
|
||||
permanent = 0x80
|
||||
};
|
||||
/*! przesylanie komend sterujacych*/
|
||||
enum command_range {
|
||||
// possible effect ranges for control commands; exclusive
|
||||
enum range {
|
||||
local,
|
||||
unit,
|
||||
consist
|
||||
};
|
||||
// start method for devices; exclusive
|
||||
enum start {
|
||||
manual,
|
||||
automatic
|
||||
};
|
||||
/*typ hamulca elektrodynamicznego*/
|
||||
static int const dbrake_none = 0;
|
||||
@@ -842,9 +848,14 @@ public:
|
||||
bool PantCompFlag = false; /*!o czy wlaczona sprezarka pantografow*/
|
||||
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 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*/
|
||||
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 BrakeCtrlPos2 = 0.0; /*nastawa hamulca zespolonego - kapturek dla FV4a*/
|
||||
int LocalBrakePos = 0; /*nastawa hamulca indywidualnego*/
|
||||
@@ -1045,7 +1056,7 @@ public:
|
||||
|
||||
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*/
|
||||
void SSReset(void);
|
||||
@@ -1101,12 +1112,12 @@ public:
|
||||
|
||||
/*--funkcje dla lokomotyw*/
|
||||
bool DirectionBackward(void);/*! kierunek ruchu*/
|
||||
bool MainSwitch( bool const State, int const Notify = command_range::consist );/*! wylacznik glowny*/
|
||||
bool ConverterSwitch( bool State, int const Notify = command_range::consist );/*! wl/wyl przetwornicy*/
|
||||
bool CompressorSwitch( bool State, int const Notify = command_range::consist );/*! wl/wyl sprezarki*/
|
||||
bool MainSwitch( bool const State, int const Notify = range::consist );/*! wylacznik glowny*/
|
||||
bool ConverterSwitch( bool State, int const Notify = range::consist );/*! wl/wyl przetwornicy*/
|
||||
bool CompressorSwitch( bool State, int const Notify = range::consist );/*! wl/wyl sprezarki*/
|
||||
|
||||
/*-funkcje typowe dla lokomotywy elektrycznej*/
|
||||
void ConverterCheck(); // przetwornica
|
||||
void ConverterCheck( double const Timestep ); // przetwornica
|
||||
bool FuseOn(void); //bezpiecznik nadamiary
|
||||
bool FuseFlagCheck(void); // sprawdzanie flagi nadmiarowego
|
||||
void FuseOff(void); // wylaczenie nadmiarowego
|
||||
@@ -1129,8 +1140,8 @@ public:
|
||||
bool AutoRelayCheck(void);//symulacja automatycznego rozruchu
|
||||
|
||||
bool ResistorsFlagCheck(void); //sprawdzenie kontrolki oporow rozruchowych NBMX
|
||||
bool PantFront( bool const State, int const Notify = command_range::consist ); //obsluga pantografou przedniego
|
||||
bool PantRear( bool const State, int const Notify = command_range::consist ); //obsluga pantografu tylnego
|
||||
bool PantFront( bool const State, int const Notify = range::consist ); //obsluga pantografou przedniego
|
||||
bool PantRear( bool const State, int const Notify = range::consist ); //obsluga pantografu tylnego
|
||||
|
||||
/*-funkcje typowe dla lokomotywy spalinowej z przekladnia mechaniczna*/
|
||||
bool dizel_EngageSwitch(double state);
|
||||
|
||||
@@ -773,7 +773,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
|
||||
// wywalenie szybkiego z powodu niskiego ciśnienia
|
||||
if( GetTrainsetVoltage() < 0.5 * EnginePowerSource.MaxVoltage ) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -1366,7 +1366,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
Compressor = 0;
|
||||
CompressorFlag = false;
|
||||
};
|
||||
ConverterCheck();
|
||||
ConverterCheck(dt);
|
||||
if (CompressorSpeed > 0.0) // sprężarka musi mieć jakąś niezerową wydajność
|
||||
CompressorCheck(dt); //żeby rozważać jej załączenie i pracę
|
||||
UpdateBrakePressure(dt);
|
||||
@@ -1522,7 +1522,7 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
|
||||
Compressor = 0;
|
||||
CompressorFlag = false;
|
||||
};
|
||||
ConverterCheck();
|
||||
ConverterCheck(dt);
|
||||
if (CompressorSpeed > 0.0) // sprężarka musi mieć jakąś niezerową wydajność
|
||||
CompressorCheck(dt); //żeby rozważać jej załączenie i pracę
|
||||
UpdateBrakePressure(dt);
|
||||
@@ -1561,15 +1561,23 @@ double TMoverParameters::ShowEngineRotation(int VehN)
|
||||
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 )
|
||||
&& ( false == PantPressLockActive )
|
||||
&& ( 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 {
|
||||
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
|
||||
auto const couplingtype =
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll );
|
||||
|
||||
@@ -2348,11 +2356,11 @@ bool TMoverParameters::MainSwitch( bool const State, int const Notify )
|
||||
{
|
||||
if( Mains ) {
|
||||
// jeśli był załączony
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
"MainSwitch", int( State ), CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
@@ -2360,11 +2368,11 @@ bool TMoverParameters::MainSwitch( bool const State, int const Notify )
|
||||
Mains = State;
|
||||
if( Mains ) {
|
||||
// jeśli został załączony
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
"MainSwitch", int( State ), CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
@@ -2399,19 +2407,19 @@ bool TMoverParameters::ConverterSwitch( bool State, int const Notify )
|
||||
CompressorAllow = ConverterAllow;
|
||||
}
|
||||
if( ConverterAllow == true ) {
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
SendCtrlToNext(
|
||||
"ConverterSwitch", 1, CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
SendCtrlToNext(
|
||||
"ConverterSwitch", 0, CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
@@ -2436,19 +2444,19 @@ bool TMoverParameters::CompressorSwitch( bool State, int const Notify )
|
||||
CS = true;
|
||||
}
|
||||
if( CompressorAllow == true ) {
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
SendCtrlToNext(
|
||||
"CompressorSwitch", 1, CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
SendCtrlToNext(
|
||||
"CompressorSwitch", 0, CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
@@ -4165,7 +4173,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
if ( (std::max(GetTrainsetVoltage(), std::abs(Voltage)) < EnginePowerSource.CollectorParameters.MinV) ||
|
||||
(std::max(GetTrainsetVoltage(), std::abs(Voltage)) * EnginePowerSource.CollectorParameters.OVP >
|
||||
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
|
||||
|
||||
if (((DynamicBrakeType == dbrake_automatic) || (DynamicBrakeType == dbrake_switch)) &&
|
||||
@@ -4464,7 +4472,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
// nie wchodzić w funkcję bez potrzeby
|
||||
if( ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) < EnginePowerSource.CollectorParameters.MinV )
|
||||
|| ( 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
|
||||
@@ -4538,21 +4546,21 @@ double TMoverParameters::TractionForce(double dt)
|
||||
{
|
||||
PosRatio = 0;
|
||||
tmp = 4;
|
||||
Sandbox( true, command_range::local );
|
||||
Sandbox( true, range::local );
|
||||
} // przeciwposlizg
|
||||
if ((abs((PosRatio + 9.80 * dizel_fill) * dmoment * 100) >
|
||||
0.95 * Adhesive(RunningTrack.friction) * TotalMassxg))
|
||||
{
|
||||
PosRatio = 0;
|
||||
tmp = 9;
|
||||
Sandbox( true, command_range::local );
|
||||
Sandbox( true, range::local );
|
||||
} // przeciwposlizg
|
||||
if ((SlippingWheels))
|
||||
{
|
||||
// PosRatio = -PosRatio * 0; // serio -0 ???
|
||||
PosRatio = 0;
|
||||
tmp = 9;
|
||||
Sandbox( true, command_range::local );
|
||||
Sandbox( true, range::local );
|
||||
} // przeciwposlizg
|
||||
|
||||
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;
|
||||
if( State == true ) {
|
||||
PantFrontStart = 0;
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
"PantFront", 1, CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
PantFrontStart = 1;
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
"PantFront", 0, CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
@@ -5243,22 +5251,22 @@ bool TMoverParameters::PantRear( bool const State, int const Notify )
|
||||
PantRearUp = State;
|
||||
if( State == true ) {
|
||||
PantRearStart = 0;
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
"PantRear", 1, CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
PantRearStart = 1;
|
||||
if( Notify != command_range::local ) {
|
||||
if( Notify != range::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
"PantRear", 0, CabNo,
|
||||
( Notify == command_range::unit ?
|
||||
( Notify == range::unit ?
|
||||
ctrain_controll | ctrain_depot :
|
||||
ctrain_controll ) );
|
||||
}
|
||||
@@ -7048,6 +7056,20 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
||||
0;
|
||||
|
||||
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 ) {
|
||||
@@ -8148,7 +8170,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
||||
}
|
||||
else if (Command == "Sandbox")
|
||||
{
|
||||
OK = Sandbox( CValue1 == 1, command_range::local );
|
||||
OK = Sandbox( CValue1 == 1, range::local );
|
||||
}
|
||||
else if (Command == "CabSignal") /*SHP,Indusi*/
|
||||
{ // 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);
|
||||
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)
|
||||
{
|
||||
// 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)
|
||||
WireOffset = 0;
|
||||
// Przewoz jezdny 1 'Marcin
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3f(pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint1.y,
|
||||
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);
|
||||
glVertex3f(
|
||||
pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset,
|
||||
pPoint1.y,
|
||||
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();
|
||||
// Nie wiem co 'Marcin
|
||||
Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2;
|
||||
@@ -146,24 +143,25 @@ void TTraction::Optimize()
|
||||
float f = step;
|
||||
float mid = 0.5;
|
||||
float t;
|
||||
|
||||
// Przewod nosny 'Marcin
|
||||
if (Wires != 1)
|
||||
if (Wires > 1)
|
||||
{
|
||||
glBegin(GL_LINE_STRIP);
|
||||
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;
|
||||
t = (1 - fabs(f - mid) * 2);
|
||||
t = (1 - std::fabs(f - mid) * 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;
|
||||
}
|
||||
glVertex3f(pPoint4.x, pPoint4.y, pPoint4.z);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
// Drugi przewod jezdny 'Winger
|
||||
if (Wires > 2)
|
||||
{
|
||||
@@ -181,14 +179,17 @@ void TTraction::Optimize()
|
||||
{
|
||||
glBegin(GL_LINE_STRIP);
|
||||
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;
|
||||
t = (1 - fabs(f - mid) * 2);
|
||||
t = (1 - std::fabs(f - mid) * 2);
|
||||
glVertex3f(
|
||||
pt3.x,
|
||||
pt3.y - sqrt(t) * fHeightDifference -
|
||||
((i == 0) || (i == iNumSections - 2) ? 0.25f * fHeightDifference : +0.05),
|
||||
pt3.y - std::sqrt( t ) * fHeightDifference - (
|
||||
( ( i == 0 )
|
||||
|| ( i == iNumSections - 2 ) ) ?
|
||||
0.25f * fHeightDifference :
|
||||
0.05 ),
|
||||
pt3.z);
|
||||
f += step;
|
||||
}
|
||||
@@ -202,36 +203,47 @@ void TTraction::Optimize()
|
||||
if (Wires != 1)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
for (int i = 0; i < iNumSections - 1; i++)
|
||||
for (int i = 0; i < iNumSections - 1; ++i)
|
||||
{
|
||||
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 - fabs(f - mid) * 2);
|
||||
t = (1 - std::fabs(f - mid) * 2);
|
||||
if ((i % 2) == 0)
|
||||
{
|
||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference -
|
||||
((i == 0) || (i == iNumSections - 2) ? flo : flo1),
|
||||
pt3.z);
|
||||
glVertex3f(pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pt4.y,
|
||||
pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
||||
glVertex3f(
|
||||
pt3.x,
|
||||
pt3.y - std::sqrt(t) * fHeightDifference - ((i == 0) || (i == iNumSections - 2) ? flo : flo1),
|
||||
pt3.z);
|
||||
glVertex3f(
|
||||
pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset,
|
||||
pt4.y,
|
||||
pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference -
|
||||
((i == 0) || (i == iNumSections - 2) ? flo : flo1),
|
||||
pt3.z);
|
||||
glVertex3f(pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pt4.y,
|
||||
pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
|
||||
glVertex3f(
|
||||
pt3.x,
|
||||
pt3.y - std::sqrt(t) * fHeightDifference - ((i == 0) || (i == iNumSections - 2) ? flo : flo1),
|
||||
pt3.z);
|
||||
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)))
|
||||
{
|
||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference - 0.05, pt3.z);
|
||||
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference, pt3.z);
|
||||
glVertex3f(
|
||||
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;
|
||||
}
|
||||
glEnd();
|
||||
@@ -249,146 +261,89 @@ void TTraction::InitCenter(vector3 Angles, vector3 pOrigin)
|
||||
void TTraction::RenderDL(float mgn) // McZapkie: mgn to odleglosc od obserwatora
|
||||
{
|
||||
// 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
|
||||
glColor4f(0, 0, 0, 1); // jak nieznany kolor to czarne nieprzezroczyste
|
||||
if (!Global::bSmoothTraction)
|
||||
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);
|
||||
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
|
||||
// setup
|
||||
GfxRenderer.Bind( 0 );
|
||||
if( !Global::bSmoothTraction ) {
|
||||
// na liniach kiepsko wygląda - robi gradient
|
||||
::glDisable( GL_LINE_SMOOTH );
|
||||
}
|
||||
if (DebugModeFlag)
|
||||
if (hvParallel)
|
||||
{ // jeśli z bieżnią wspólną, to dodatkowo przyciemniamy
|
||||
r *= 0.6f;
|
||||
g *= 0.6f;
|
||||
b *= 0.6f;
|
||||
}
|
||||
#ifdef EU07_USE_OLD_LIGHTING_MODEL
|
||||
r *= Global::ambientDayLight[ 0 ]; // w zaleźności od koloru swiatła
|
||||
g *= Global::ambientDayLight[ 1 ];
|
||||
b *= Global::ambientDayLight[ 2 ];
|
||||
#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);
|
||||
float linealpha = 5000 * WireThickness / ( mgn + 1.0 ); //*WireThickness
|
||||
linealpha = std::min( 1.2f, linealpha ); // zbyt grube nie są dobre
|
||||
::glLineWidth( linealpha );
|
||||
// McZapkie-261102: kolor zalezy od materialu i zasniedzenia
|
||||
float
|
||||
red{ 0.0f },
|
||||
green{ 0.0f },
|
||||
blue{ 0.0f };
|
||||
wire_color( red, green, blue );
|
||||
::glColor4f( red, green, blue, linealpha );
|
||||
// draw code
|
||||
if (!uiDisplayList)
|
||||
Optimize(); // generowanie DL w miarę potrzeby
|
||||
glCallList(uiDisplayList);
|
||||
glLineWidth(1.0);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
// glEnable(GL_LIGHTING); //bez tego się modele nie oświetlają
|
||||
::glCallList(uiDisplayList);
|
||||
// cleanup
|
||||
::glLineWidth(1.0);
|
||||
::glEnable(GL_LINE_SMOOTH);
|
||||
}
|
||||
}
|
||||
|
||||
// przygotowanie tablic do skopiowania do VBO (zliczanie wierzchołków)
|
||||
int TTraction::RaArrayPrepare()
|
||||
{ // przygotowanie tablic do skopiowania do VBO (zliczanie wierzchołków)
|
||||
// if (bVisible) //o ile w ogóle widać
|
||||
switch (Wires)
|
||||
{
|
||||
case 1:
|
||||
iLines = 2;
|
||||
break;
|
||||
case 2:
|
||||
iLines = iNumSections ? 4 * (iNumSections)-2 + 2 : 4;
|
||||
break;
|
||||
case 3:
|
||||
iLines = iNumSections ? 4 * (iNumSections)-2 + 4 : 6;
|
||||
break;
|
||||
case 4:
|
||||
iLines = iNumSections ? 4 * (iNumSections)-2 + 6 : 8;
|
||||
break;
|
||||
default:
|
||||
iLines = 0;
|
||||
{
|
||||
// jezdny
|
||||
iLines = 2;
|
||||
// przewod nosny
|
||||
if( Wires > 1 ) {
|
||||
iLines += 2 + (
|
||||
Wires < 4 ?
|
||||
std::max( 0, iNumSections - 1 ) :
|
||||
( iNumSections > 2 ?
|
||||
std::max( 0, iNumSections - 1 - 2 ) :
|
||||
std::max( 0, iNumSections - 1 - 1 ) ) );
|
||||
}
|
||||
// drugi przewod jezdny
|
||||
if( Wires > 2 ) {
|
||||
iLines += 2;
|
||||
}
|
||||
if( Wires == 4 ) {
|
||||
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;
|
||||
};
|
||||
|
||||
void TTraction::RaArrayFill(CVertNormTex *Vert)
|
||||
{ // wypełnianie tablic VBO
|
||||
CVertNormTex *old = Vert;
|
||||
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)
|
||||
WireOffset = 0;
|
||||
// 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->z = pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
||||
Vert->z = pPoint1.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
||||
++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->z = pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
||||
Vert->z = pPoint2.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
||||
++Vert;
|
||||
// Nie wiem co 'Marcin
|
||||
Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2;
|
||||
v1 = pPoint4 - pPoint3;
|
||||
v2 = pPoint2 - pPoint1;
|
||||
float step = 0;
|
||||
if (iNumSections > 0)
|
||||
if( iNumSections > 0 )
|
||||
step = 1.0f / (float)iNumSections;
|
||||
float f = step;
|
||||
float mid = 0.5;
|
||||
@@ -400,18 +355,18 @@ void TTraction::RaArrayFill(CVertNormTex *Vert)
|
||||
Vert->y = pPoint3.y;
|
||||
Vert->z = pPoint3.z;
|
||||
++Vert;
|
||||
for (int i = 0; i < iNumSections - 1; i++)
|
||||
for (int i = 0; i < iNumSections - 1; ++i)
|
||||
{
|
||||
pt3 = pPoint3 + v1 * f;
|
||||
t = (1 - fabs(f - mid) * 2);
|
||||
Vert->x = pt3.x;
|
||||
Vert->y = pt3.y - sqrt(t) * fHeightDifference;
|
||||
Vert->z = pt3.z;
|
||||
++Vert;
|
||||
Vert->x = pt3.x; // drugi raz, bo nie jest line_strip
|
||||
Vert->y = pt3.y - sqrt(t) * fHeightDifference;
|
||||
Vert->z = pt3.z;
|
||||
++Vert;
|
||||
t = (1 - std::fabs(f - mid) * 2);
|
||||
if( ( Wires < 4 )
|
||||
|| ( ( i != 0 )
|
||||
&& ( i != iNumSections - 2 ) ) ) {
|
||||
Vert->x = pt3.x;
|
||||
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference;
|
||||
Vert->z = pt3.z;
|
||||
++Vert;
|
||||
}
|
||||
f += step;
|
||||
}
|
||||
Vert->x = pPoint4.x;
|
||||
@@ -420,7 +375,7 @@ void TTraction::RaArrayFill(CVertNormTex *Vert)
|
||||
++Vert;
|
||||
}
|
||||
// Drugi przewod jezdny 'Winger
|
||||
if (Wires == 3)
|
||||
if (Wires > 2)
|
||||
{
|
||||
Vert->x = pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
||||
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;
|
||||
}
|
||||
|
||||
f = step;
|
||||
// Przewody pionowe (wieszaki) 'Marcin, poprawki na 2 przewody jezdne 'Winger
|
||||
if (Wires > 1)
|
||||
{
|
||||
for (int i = 0; i < iNumSections - 1; i++)
|
||||
{
|
||||
|
||||
if( Wires == 4 ) {
|
||||
Vert->x = pPoint3.x;
|
||||
Vert->y = pPoint3.y - 0.65f * fHeightDifference;
|
||||
Vert->z = pPoint3.z;
|
||||
++Vert;
|
||||
for( int i = 0; i < iNumSections - 1; ++i ) {
|
||||
pt3 = pPoint3 + v1 * f;
|
||||
pt4 = pPoint1 + v2 * f;
|
||||
t = (1 - fabs(f - mid) * 2);
|
||||
t = ( 1 - std::fabs( f - mid ) * 2 );
|
||||
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;
|
||||
if ((i % 2) == 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
f += step;
|
||||
}
|
||||
Vert->x = pPoint4.x;
|
||||
Vert->y = pPoint4.y - 0.65f * fHeightDifference;
|
||||
Vert->z = pPoint4.z;
|
||||
}
|
||||
f = step;
|
||||
|
||||
// Przewody pionowe (wieszaki) 'Marcin, poprawki na 2 przewody jezdne 'Winger
|
||||
if (Wires > 1)
|
||||
{
|
||||
for (int i = 0; i < iNumSections - 1; ++i)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{ // renderowanie z użyciem VBO
|
||||
if (Wires != 0 && !TestFlag(DamageFlag, 128)) // rysuj jesli sa druty i nie zerwana
|
||||
{
|
||||
// setup
|
||||
GfxRenderer.Bind(0);
|
||||
glDisable(GL_LIGHTING); // aby nie używało wektorów normalnych do kolorowania
|
||||
glColor4f(0, 0, 0, 1); // jak nieznany kolor to czarne nieprzezroczyste
|
||||
if (!Global::bSmoothTraction)
|
||||
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
|
||||
if( !Global::bSmoothTraction ) {
|
||||
// na liniach kiepsko wygląda - robi gradient
|
||||
::glDisable( GL_LINE_SMOOTH );
|
||||
}
|
||||
#ifdef EU07_USE_OLD_LIGHTING_MODEL
|
||||
r *= Global::ambientDayLight[ 0 ]; // w zaleźności od koloru swiatła
|
||||
g *= Global::ambientDayLight[ 1 ];
|
||||
b *= Global::ambientDayLight[ 2 ];
|
||||
#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);
|
||||
glDrawArrays(GL_LINES, iPtr, iLines);
|
||||
glLineWidth(1.0);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_LIGHTING); // bez tego się modele nie oświetlają
|
||||
float linealpha = 5000 * WireThickness / (mgn + 1.0); //*WireThickness
|
||||
linealpha = std::min( 1.2f, linealpha ); // zbyt grube nie są dobre
|
||||
::glLineWidth(linealpha);
|
||||
// McZapkie-261102: kolor zalezy od materialu i zasniedzenia
|
||||
float
|
||||
red{ 0.0f },
|
||||
green{ 0.0f },
|
||||
blue{ 0.0f };
|
||||
wire_color( red, green, blue );
|
||||
::glColor4f(red, green, blue, linealpha);
|
||||
// draw code
|
||||
// jezdny
|
||||
::glDrawArrays( GL_LINE_STRIP, iPtr, 2 );
|
||||
iPtr += 2;
|
||||
// przewod nosny
|
||||
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
|
||||
ps = psPower[d ^ 1]; // zasilacz od przeciwnej strony niż idzie analiza
|
||||
d = iNext[d]; // kierunek
|
||||
// double r; //sumaryczna rezystancja
|
||||
#ifdef EU07_USE_OLD_TRACTIONPOWER_CODE
|
||||
if (DebugModeFlag) // tylko podczas testów
|
||||
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
|
||||
{ // ustawienie zasilacza i policzenie rezystancji zastępczej
|
||||
#ifdef EU07_USE_OLD_TRACTIONPOWER_CODE
|
||||
if (DebugModeFlag) // tylko podczas testów
|
||||
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 |= 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->fResistance[d] = r; // wpisanie rezystancji w kierunku tego zasilacza
|
||||
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 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
|
||||
float fResistance[2]; // rezystancja zastępcza do punktu zasilania (0: przęsło zasilane, <0: do policzenia)
|
||||
int iTries = 0;
|
||||
// bool bVisible;
|
||||
// DWORD dwFlags;
|
||||
int PowerState{ 0 }; // type of incoming power, if any
|
||||
|
||||
void Optimize();
|
||||
|
||||
@@ -78,5 +77,7 @@ class TTraction
|
||||
void ResistanceCalc(int d = -1, double r = 0, TTractionPowerSource *ps = NULL);
|
||||
void PowerSet(TTractionPowerSource *ps);
|
||||
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->MainSwitch( true ) ) {
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
@@ -1636,6 +1636,11 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com
|
||||
|
||||
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 ) {
|
||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||
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 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
|
||||
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;
|
||||
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 ) {
|
||||
// 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;
|
||||
|
||||
if (tmp)
|
||||
if (tmp->MoverParameters->Mains)
|
||||
if ( mvControlled->Battery || mvControlled->ConverterFlag )
|
||||
{
|
||||
btLampkaWylSzybkiB.TurnOn();
|
||||
btLampkaWylSzybkiB.Turn( tmp->MoverParameters->Mains );
|
||||
|
||||
btLampkaOporyB.Turn(tmp->MoverParameters->ResistorsFlagCheck());
|
||||
btLampkaBezoporowaB.Turn(
|
||||
tmp->MoverParameters->ResistorsFlagCheck() ||
|
||||
@@ -5312,7 +5318,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
switch (LampkaUniversal3_typ)
|
||||
{
|
||||
case 0:
|
||||
btLampkaUniversal3.Turn(mvControlled->Battery);
|
||||
btLampkaUniversal3.Turn( mvControlled->Battery || mvControlled->ConverterFlag );
|
||||
break;
|
||||
case 1:
|
||||
btLampkaUniversal3.Turn(mvControlled->Mains);
|
||||
|
||||
Reference in New Issue
Block a user