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

support for K type brakes, tweaks to external camera positioning

This commit is contained in:
tmj-fstate
2017-02-28 17:33:54 +01:00
parent c49b774864
commit 58b183d462
5 changed files with 131 additions and 113 deletions

View File

@@ -444,7 +444,7 @@ public: // modele składowe pojazdu
{ {
return vUp; return vUp;
}; };
inline vector3 VectorLeft() inline vector3 VectorLeft() const
{ {
return vLeft; return vLeft;
}; };
@@ -460,7 +460,7 @@ public: // modele składowe pojazdu
{ {
return MoverParameters->Dim.L; return MoverParameters->Dim.L;
}; };
inline double GetWidth() inline double GetWidth() const
{ {
return MoverParameters->Dim.W; return MoverParameters->Dim.W;
}; };

View File

@@ -495,7 +495,10 @@ void Global::ConfigParse(cParser &Parser)
Parser.getTokens(); Parser.getTokens();
Parser >> token; Parser >> token;
/*
Global::bUseVBO = (token == "yes"); Global::bUseVBO = (token == "yes");
*/
Global::bUseVBO = false; // temporarily disabled until render paths are sorted out
} }
else if (token == "feedbackmode") else if (token == "feedbackmode")
{ {

View File

@@ -3005,98 +3005,105 @@ void TMoverParameters::UpdatePipePressure(double dt)
// if (Hamulec is typeid(TWest)) return 0; // if (Hamulec is typeid(TWest)) return 0;
switch (BrakeValve) switch (BrakeValve) {
{
case W: case K:
{ case W: {
if (BrakeLocHandle != NoHandle)
if( BrakeLocHandle != NoHandle ) {
LocBrakePress = LocHandle->GetCP();
//(Hamulec as TWest).SetLBP(LocBrakePress);
Hamulec->SetLBP( LocBrakePress );
}
if( MBPM < 2 )
//(Hamulec as TWest).PLC(MaxBrakePress[LoadFlag])
Hamulec->PLC( MaxBrakePress[ LoadFlag ] );
else
//(Hamulec as TWest).PLC(TotalMass);
Hamulec->PLC( TotalMass );
break;
}
case LSt:
case EStED: {
LocBrakePress = LocHandle->GetCP();
for( int b = 0; b < 2; b++ )
if( ( ( TrainType & ( dt_ET41 | dt_ET42 ) ) != 0 ) &&
( Couplers[ b ].Connected != NULL ) ) // nie podoba mi się to rozwiązanie, chyba trzeba
// dodać jakiś wpis do fizyki na to
if( ( ( Couplers[ b ].Connected->TrainType & ( dt_ET41 | dt_ET42 ) ) != 0 ) &&
( ( Couplers[ b ].CouplingFlag & 36 ) == 36 ) )
LocBrakePress = Max0R( Couplers[ b ].Connected->LocHandle->GetCP(), LocBrakePress );
//if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor))
//{
// //if (Vel > 10)
// // LocBrakePress = 0;
// //else if (Vel > 5)
// // LocBrakePress = (10 - Vel) / 5 * LocBrakePress;
//}
//(Hamulec as TLSt).SetLBP(LocBrakePress);
Hamulec->SetLBP( LocBrakePress );
if( ( BrakeValve == EStED ) )
if( MBPM < 2 )
Hamulec->PLC( MaxBrakePress[ LoadFlag ] );
else
Hamulec->PLC( TotalMass );
break;
}
case CV1_L_TR:
{ {
LocBrakePress = LocHandle->GetCP(); LocBrakePress = LocHandle->GetCP();
//(Hamulec as TCV1L_TR).SetLBP(LocBrakePress);
//(Hamulec as TWest).SetLBP(LocBrakePress); Hamulec->SetLBP( LocBrakePress );
Hamulec->SetLBP(LocBrakePress); break;
} }
if (MBPM < 2)
//(Hamulec as TWest).PLC(MaxBrakePress[LoadFlag])
Hamulec->PLC(MaxBrakePress[LoadFlag]);
else
//(Hamulec as TWest).PLC(TotalMass);
Hamulec->PLC(TotalMass);
break;
}
case LSt: case EP2:
case EStED: {
{ Hamulec->PLC( TotalMass );
LocBrakePress = LocHandle->GetCP(); break;
for (int b = 0; b < 2; b++) }
if (((TrainType & (dt_ET41 | dt_ET42)) != 0) && case ESt3AL2:
(Couplers[b].Connected != NULL)) // nie podoba mi się to rozwiązanie, chyba trzeba case NESt3:
// dodać jakiś wpis do fizyki na to case ESt4:
if (((Couplers[b].Connected->TrainType & (dt_ET41 | dt_ET42)) != 0) && case ESt3:
((Couplers[b].CouplingFlag & 36) == 36)) {
LocBrakePress = Max0R(Couplers[b].Connected->LocHandle->GetCP(), LocBrakePress); if( MBPM < 2 )
//(Hamulec as TNESt3).PLC(MaxBrakePress[LoadFlag])
//if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor)) Hamulec->PLC( MaxBrakePress[ LoadFlag ] );
//{ else
// //if (Vel > 10) //(Hamulec as TNESt3).PLC(TotalMass);
// // LocBrakePress = 0; Hamulec->PLC( TotalMass );
// //else if (Vel > 5) LocBrakePress = LocHandle->GetCP();
// // LocBrakePress = (10 - Vel) / 5 * LocBrakePress; //(Hamulec as TNESt3).SetLBP(LocBrakePress);
//} Hamulec->SetLBP( LocBrakePress );
break;
//(Hamulec as TLSt).SetLBP(LocBrakePress); }
Hamulec->SetLBP(LocBrakePress); case KE:
if ((BrakeValve == EStED)) {
if (MBPM < 2) LocBrakePress = LocHandle->GetCP();
Hamulec->PLC(MaxBrakePress[LoadFlag]); //(Hamulec as TKE).SetLBP(LocBrakePress);
else Hamulec->SetLBP( LocBrakePress );
Hamulec->PLC(TotalMass); if( MBPM < 2 )
break; //(Hamulec as TKE).PLC(MaxBrakePress[LoadFlag])
} Hamulec->PLC( MaxBrakePress[ LoadFlag ] );
else
case CV1_L_TR: //(Hamulec as TKE).PLC(TotalMass);
{ Hamulec->PLC( TotalMass );
LocBrakePress = LocHandle->GetCP(); break;
//(Hamulec as TCV1L_TR).SetLBP(LocBrakePress); }
Hamulec->SetLBP(LocBrakePress); default:
break; {
} // unsupported brake valve type, we should never land here
// ErrorLog( "Unsupported brake valve type (" + std::to_string( BrakeValve ) + ") in " + TypeName );
case EP2: // ::PostQuitMessage( 0 );
{ break;
Hamulec->PLC(TotalMass); }
break;
}
case ESt3AL2:
case NESt3:
case ESt4:
case ESt3:
{
if (MBPM < 2)
//(Hamulec as TNESt3).PLC(MaxBrakePress[LoadFlag])
Hamulec->PLC(MaxBrakePress[LoadFlag]);
else
//(Hamulec as TNESt3).PLC(TotalMass);
Hamulec->PLC(TotalMass);
LocBrakePress = LocHandle->GetCP();
//(Hamulec as TNESt3).SetLBP(LocBrakePress);
Hamulec->SetLBP(LocBrakePress);
break;
}
case KE:
{
LocBrakePress = LocHandle->GetCP();
//(Hamulec as TKE).SetLBP(LocBrakePress);
Hamulec->SetLBP(LocBrakePress);
if (MBPM < 2)
//(Hamulec as TKE).PLC(MaxBrakePress[LoadFlag])
Hamulec->PLC(MaxBrakePress[LoadFlag]);
else
//(Hamulec as TKE).PLC(TotalMass);
Hamulec->PLC(TotalMass);
break;
}
} // switch } // switch
if ((BrakeHandle == FVel6) && (ActiveCab != 0)) if ((BrakeHandle == FVel6) && (ActiveCab != 0))
@@ -7252,8 +7259,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
} }
if ( ( true == TestFlag( BrakeDelays, bdelay_G ) ) if ( ( true == TestFlag( BrakeDelays, bdelay_G ) )
&& ( false == TestFlag(BrakeDelays, bdelay_R) ) && ( ( false == TestFlag(BrakeDelays, bdelay_R ) )
|| ( Power > 1.0 ) ) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy || ( Power > 1.0 ) ) ) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy
Spg = 0.792; Spg = 0.792;
else else
Spg = 0.507; Spg = 0.507;

View File

@@ -763,7 +763,8 @@ void TWorld::OnKeyDown(int cKey)
break; break;
} }
case VK_F4: { case VK_F4: {
InOutKey();
InOutKey( !Console::Pressed( VK_SHIFT ) ); // distant view with Shift, short distance step out otherwise
break; break;
} }
case VK_F5: { case VK_F5: {
@@ -980,7 +981,7 @@ void TWorld::OnMouseMove(double x, double y)
Camera.OnCursorMove(x * Global::fMouseXScale / Global::ZoomFactor, -y * Global::fMouseYScale / Global::ZoomFactor); Camera.OnCursorMove(x * Global::fMouseXScale / Global::ZoomFactor, -y * Global::fMouseYScale / Global::ZoomFactor);
} }
void TWorld::InOutKey() void TWorld::InOutKey( bool const Near )
{ // przełączenie widoku z kabiny na zewnętrzny i odwrotnie { // przełączenie widoku z kabiny na zewnętrzny i odwrotnie
FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku
if (FreeFlyModeFlag) if (FreeFlyModeFlag)
@@ -990,7 +991,7 @@ void TWorld::InOutKey()
{ // Train->Dynamic()->ABuSetModelShake(vector3(0,0,0)); { // Train->Dynamic()->ABuSetModelShake(vector3(0,0,0));
Train->Silence(); // wyłączenie dźwięków kabiny Train->Silence(); // wyłączenie dźwięków kabiny
Train->Dynamic()->bDisplayCab = false; Train->Dynamic()->bDisplayCab = false;
DistantView(); DistantView( Near );
} }
} }
else else
@@ -1010,26 +1011,33 @@ void TWorld::InOutKey()
} }
}; };
void TWorld::DistantView() // places camera outside the controlled vehicle, or nearest if nothing is under control
// depending on provided switch the view is placed right outside, or at medium distance
void TWorld::DistantView( bool const Near )
{ // ustawienie widoku pojazdu z zewnątrz { // ustawienie widoku pojazdu z zewnątrz
if (Controlled) // jest pojazd do prowadzenia?
{ // na prowadzony TDynamicObject const *vehicle{ nullptr };
if( nullptr != Controlled ) { vehicle = Controlled; }
else if( nullptr != pDynamicNearest ) { vehicle = pDynamicNearest; }
else { return; }
if( true == Near ) {
Camera.Pos = Camera.Pos =
Controlled->GetPosition() + vector3( Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z )
(Controlled->MoverParameters->ActiveCab >= 0 ? 30 : -30) * Controlled->VectorFront() + + vehicle->VectorLeft() * vehicle->MoverParameters->ActiveCab * vehicle->GetWidth()
vector3(0, 5, 0); + vector3( 1.25 * vehicle->MoverParameters->ActiveCab, 1.6, 0.0 );
Camera.LookAt = Controlled->GetPosition();
Camera.RaLook(); // jednorazowe przestawienie kamery
} }
else if (pDynamicNearest) // jeśli jest pojazd wykryty blisko else {
{ // patrzenie na najbliższy pojazd
Camera.Pos = pDynamicNearest->GetPosition() + Camera.Pos =
(pDynamicNearest->MoverParameters->ActiveCab >= 0 ? 30 : -30) * vehicle->GetPosition()
pDynamicNearest->VectorFront() + + vehicle->VectorFront() * vehicle->MoverParameters->ActiveCab * 50.0
vector3(0, 5, 0); + vector3( -10.0, 1.6, 0.0 );
Camera.LookAt = pDynamicNearest->GetPosition();
Camera.RaLook(); // jednorazowe przestawienie kamery
} }
Camera.LookAt = vehicle->GetPosition();
Camera.RaLook(); // jednorazowe przestawienie kamery
}; };
void TWorld::FollowView(bool wycisz) void TWorld::FollowView(bool wycisz)

View File

@@ -35,9 +35,9 @@ private:
class TWorld class TWorld
{ {
void InOutKey(); void InOutKey( bool const Near = true );
void FollowView(bool wycisz = true); void FollowView(bool wycisz = true);
void DistantView(); void DistantView( bool const Near = false );
public: public:
bool Init(HWND NhWnd, HDC hDC); bool Init(HWND NhWnd, HDC hDC);