mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 00:09:18 +02:00
Merge branch 'tmj-dev' into lua
This commit is contained in:
@@ -25,17 +25,13 @@ void TCamera::Init(vector3 NPos, vector3 NAngle)
|
|||||||
{
|
{
|
||||||
|
|
||||||
vUp = vector3(0, 1, 0);
|
vUp = vector3(0, 1, 0);
|
||||||
// pOffset= vector3(-0.8,0,0);
|
|
||||||
CrossDist = 10;
|
|
||||||
Velocity = vector3(0, 0, 0);
|
Velocity = vector3(0, 0, 0);
|
||||||
Pitch = NAngle.x;
|
Pitch = NAngle.x;
|
||||||
Yaw = NAngle.y;
|
Yaw = NAngle.y;
|
||||||
Roll = NAngle.z;
|
Roll = NAngle.z;
|
||||||
Pos = NPos;
|
Pos = NPos;
|
||||||
|
|
||||||
// Type= tp_Follow;
|
|
||||||
Type = (Global::bFreeFly ? tp_Free : tp_Follow);
|
Type = (Global::bFreeFly ? tp_Free : tp_Follow);
|
||||||
// Type= tp_Free;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TCamera::OnCursorMove(double x, double y)
|
void TCamera::OnCursorMove(double x, double y)
|
||||||
|
|||||||
9
Camera.h
9
Camera.h
@@ -46,13 +46,10 @@ class TCamera
|
|||||||
vector3 LookAt; // współrzędne punktu, na który ma patrzeć
|
vector3 LookAt; // współrzędne punktu, na który ma patrzeć
|
||||||
vector3 vUp;
|
vector3 vUp;
|
||||||
vector3 Velocity;
|
vector3 Velocity;
|
||||||
vector3 CrossPos;
|
|
||||||
double CrossDist;
|
|
||||||
void Init(vector3 NPos, vector3 NAngle);
|
void Init(vector3 NPos, vector3 NAngle);
|
||||||
void Reset()
|
inline
|
||||||
{
|
void Reset() {
|
||||||
Pitch = Yaw = Roll = 0;
|
Pitch = Yaw = Roll = 0; };
|
||||||
};
|
|
||||||
void OnCursorMove(double const x, double const y);
|
void OnCursorMove(double const x, double const y);
|
||||||
void OnCommand( command_data const &Command );
|
void OnCommand( command_data const &Command );
|
||||||
void Update();
|
void Update();
|
||||||
|
|||||||
111
Driver.cpp
111
Driver.cpp
@@ -46,12 +46,12 @@ ProjectEventOnTrack( TEvent const *Event, TTrack const *Track, double const Dire
|
|||||||
( 1.0 - nearestpoint ) * segment->GetLength() ); // measure from point2
|
( 1.0 - nearestpoint ) * segment->GetLength() ); // measure from point2
|
||||||
};
|
};
|
||||||
|
|
||||||
double GetDistanceToEvent(TTrack* track, TEvent* event, double scan_dir, double start_dist, int iter = 0, bool back = false)
|
double GetDistanceToEvent(TTrack const *track, TEvent const *event, double scan_dir, double start_dist, int iter = 0, bool back = false)
|
||||||
{
|
{
|
||||||
if( track == nullptr ) { return start_dist; }
|
if( track == nullptr ) { return start_dist; }
|
||||||
|
|
||||||
auto const segment = track->CurrentSegment();
|
auto const segment = track->CurrentSegment();
|
||||||
vector3 const pos_event = event->PositionGet();
|
auto const pos_event = event->PositionGet();
|
||||||
double len1, len2;
|
double len1, len2;
|
||||||
double sd = scan_dir;
|
double sd = scan_dir;
|
||||||
double seg_len = scan_dir > 0 ? 0.0 : 1.0;
|
double seg_len = scan_dir > 0 ? 0.0 : 1.0;
|
||||||
@@ -63,15 +63,15 @@ double GetDistanceToEvent(TTrack* track, TEvent* event, double scan_dir, double
|
|||||||
len1 = len2;
|
len1 = len2;
|
||||||
seg_len += scan_dir > 0 ? dzielnik : -dzielnik;
|
seg_len += scan_dir > 0 ? dzielnik : -dzielnik;
|
||||||
len2 = (pos_event - segment->FastGetPoint(seg_len)).LengthSquared();
|
len2 = (pos_event - segment->FastGetPoint(seg_len)).LengthSquared();
|
||||||
krok++;
|
++krok;
|
||||||
} while ((len1 > len2) && (seg_len >= dzielnik && (seg_len <= (1 - dzielnik))));
|
} while ((len1 > len2) && (seg_len >= dzielnik && (seg_len <= (1.0 - dzielnik))));
|
||||||
//trzeba sprawdzić czy seg_len nie osiągnął skrajnych wartości, bo wtedy
|
//trzeba sprawdzić czy seg_len nie osiągnął skrajnych wartości, bo wtedy
|
||||||
// trzeba sprawdzić tor obok
|
// trzeba sprawdzić tor obok
|
||||||
if (1 == krok)
|
if (1 == krok)
|
||||||
sd = -sd; // jeśli tylko jeden krok tzn, że event przy poprzednim sprawdzaym torze
|
sd = -sd; // jeśli tylko jeden krok tzn, że event przy poprzednim sprawdzaym torze
|
||||||
if (((seg_len <= dzielnik) || (seg_len > (1 - dzielnik))) && (iter < 3))
|
if (((1 == krok) || (seg_len <= dzielnik) || (seg_len > (1.0 - dzielnik))) && (iter < 3))
|
||||||
{ // przejście na inny tor
|
{ // przejście na inny tor
|
||||||
track = track->Neightbour(int(sd), sd);
|
track = track->Connected(int(sd), sd);
|
||||||
start_dist += (1 == krok) ? 0 : back ? -segment->GetLength() : segment->GetLength();
|
start_dist += (1 == krok) ? 0 : back ? -segment->GetLength() : segment->GetLength();
|
||||||
return GetDistanceToEvent(track, event, sd, start_dist, ++iter, 1 == krok ? true : false);
|
return GetDistanceToEvent(track, event, sd, start_dist, ++iter, 1 == krok ? true : false);
|
||||||
}
|
}
|
||||||
@@ -616,7 +616,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
|
|||||||
fCurrentDistance += fTrackLength; // doliczenie kolejnego odcinka do przeskanowanej długości
|
fCurrentDistance += fTrackLength; // doliczenie kolejnego odcinka do przeskanowanej długości
|
||||||
tLast = pTrack; // odhaczenie, że sprawdzony
|
tLast = pTrack; // odhaczenie, że sprawdzony
|
||||||
fLastVel = pTrack->VelocityGet(); // prędkość na poprzednio sprawdzonym odcinku
|
fLastVel = pTrack->VelocityGet(); // prędkość na poprzednio sprawdzonym odcinku
|
||||||
pTrack = pTrack->Neightbour(
|
pTrack = pTrack->Connected(
|
||||||
( pTrack->eType == tt_Cross ?
|
( pTrack->eType == tt_Cross ?
|
||||||
(sSpeedTable[iLast].iFlags >> 28) :
|
(sSpeedTable[iLast].iFlags >> 28) :
|
||||||
static_cast<int>(fLastDir) ),
|
static_cast<int>(fLastDir) ),
|
||||||
@@ -3922,6 +3922,13 @@ TController::UpdateSituation(double dt) {
|
|||||||
fStopTime = 0.0; // nie ma na co czekać z odczepianiem
|
fStopTime = 0.0; // nie ma na co czekać z odczepianiem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if( mvOccupied->Vel > 0.0 ) {
|
||||||
|
// 1st phase(?)
|
||||||
|
// bring it to stop if it's not already stopped
|
||||||
|
SetVelocity( 0, 0, stopJoin ); // wyłączyć przyspieszanie
|
||||||
|
}
|
||||||
|
}
|
||||||
} // odczepiania
|
} // odczepiania
|
||||||
else // to poniżej jeśli ilość wagonów ujemna
|
else // to poniżej jeśli ilość wagonów ujemna
|
||||||
if (iDrivigFlags & movePress)
|
if (iDrivigFlags & movePress)
|
||||||
@@ -3988,8 +3995,8 @@ TController::UpdateSituation(double dt) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// samochod (sokista też)
|
// samochod (sokista też)
|
||||||
fMinProximityDist = std::max( 4.0, mvOccupied->Vel * 0.2 );
|
fMinProximityDist = std::max( 3.0, mvOccupied->Vel * 0.2 );
|
||||||
fMaxProximityDist = std::max( 8.0, mvOccupied->Vel * 0.375 ); //[m]
|
fMaxProximityDist = std::max( 9.0, mvOccupied->Vel * 0.375 ); //[m]
|
||||||
// margines prędkości powodujący załączenie napędu
|
// margines prędkości powodujący załączenie napędu
|
||||||
fVelMinus = 2.0;
|
fVelMinus = 2.0;
|
||||||
// dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania
|
// dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania
|
||||||
@@ -4262,12 +4269,17 @@ TController::UpdateSituation(double dt) {
|
|||||||
&& ( coupler->CouplingFlag == coupling::faux ) ) {
|
&& ( coupler->CouplingFlag == coupling::faux ) ) {
|
||||||
// mamy coś z przodu podłączone sprzęgiem wirtualnym
|
// mamy coś z przodu podłączone sprzęgiem wirtualnym
|
||||||
// wyliczanie optymalnego przyspieszenia do jazdy na widoczność
|
// wyliczanie optymalnego przyspieszenia do jazdy na widoczność
|
||||||
|
/*
|
||||||
ActualProximityDist = std::min(
|
ActualProximityDist = std::min(
|
||||||
ActualProximityDist,
|
ActualProximityDist,
|
||||||
vehicle->fTrackBlock - (
|
vehicle->fTrackBlock - (
|
||||||
mvOccupied->CategoryFlag & 2 ?
|
mvOccupied->CategoryFlag & 2 ?
|
||||||
fMinProximityDist : // cars can bunch up tighter
|
fMinProximityDist : // cars can bunch up tighter
|
||||||
fMaxProximityDist ) ); // other vehicle types less so
|
fMaxProximityDist ) ); // other vehicle types less so
|
||||||
|
*/
|
||||||
|
ActualProximityDist = std::min(
|
||||||
|
ActualProximityDist,
|
||||||
|
vehicle->fTrackBlock );
|
||||||
double k = coupler->Connected->Vel; // prędkość pojazdu z przodu (zakładając,
|
double k = coupler->Connected->Vel; // prędkość pojazdu z przodu (zakładając,
|
||||||
// że jedzie w tę samą stronę!!!)
|
// że jedzie w tę samą stronę!!!)
|
||||||
if( k < vel + 10 ) {
|
if( k < vel + 10 ) {
|
||||||
@@ -4326,36 +4338,47 @@ TController::UpdateSituation(double dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sprawdzamy możliwe ograniczenia prędkości
|
// sprawdzamy możliwe ograniczenia prędkości
|
||||||
if (OrderCurrentGet() & (Shunt | Obey_train)) // w Connect nie, bo moveStopHere
|
if( OrderCurrentGet() & ( Shunt | Obey_train ) ) {
|
||||||
// odnosi się do stanu po połączeniu
|
// w Connect nie, bo moveStopHere odnosi się do stanu po połączeniu
|
||||||
if (iDrivigFlags & moveStopHere) // jeśli ma czekać na wolną drogę
|
if( ( iDrivigFlags & moveStopHere )
|
||||||
if (vel == 0.0) // a stoi
|
&& ( vel == 0.0 )
|
||||||
if (VelNext == 0.0) // a wyjazdu nie ma
|
&& ( VelNext == 0.0 ) ) {
|
||||||
VelDesired = 0.0; // to ma stać
|
// jeśli ma czekać na wolną drogę, stoi a wyjazdu nie ma, to ma stać
|
||||||
if (fStopTime < 0) // czas postoju przed dalszą jazdą (np. na przystanku)
|
VelDesired = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( fStopTime < 0 ) {
|
||||||
|
// czas postoju przed dalszą jazdą (np. na przystanku)
|
||||||
VelDesired = 0.0; // jak ma czekać, to nie ma jazdy
|
VelDesired = 0.0; // jak ma czekać, to nie ma jazdy
|
||||||
// else if (VelSignal<0)
|
}
|
||||||
// VelDesired=fVelMax; //ile fabryka dala (Ra: uwzględione wagony)
|
else if( VelSignal >= 0 ) {
|
||||||
else if (VelSignal >= 0) // jeśli skład był zatrzymany na początku i teraz już może jechać
|
// jeśli skład był zatrzymany na początku i teraz już może jechać
|
||||||
VelDesired = Global::Min0RSpeed(VelDesired, VelSignal);
|
|
||||||
|
|
||||||
if (mvOccupied->RunningTrack.Velmax >=
|
|
||||||
0) // ograniczenie prędkości z trajektorii ruchu
|
|
||||||
VelDesired =
|
VelDesired =
|
||||||
Global::Min0RSpeed(VelDesired,
|
Global::Min0RSpeed(
|
||||||
mvOccupied->RunningTrack.Velmax); // uwaga na ograniczenia szlakowej!
|
VelDesired,
|
||||||
if (VelforDriver >= 0) // tu jest zero przy zmianie kierunku jazdy
|
VelSignal );
|
||||||
VelDesired = Global::Min0RSpeed(VelDesired, VelforDriver); // Ra: tu może być 40, jeśli
|
}
|
||||||
// mechanik nie ma znajomości
|
if( mvOccupied->RunningTrack.Velmax >= 0 ) {
|
||||||
// szlaaku, albo kierowca jeździ
|
// ograniczenie prędkości z trajektorii ruchu
|
||||||
// 70
|
VelDesired =
|
||||||
if (TrainParams)
|
Global::Min0RSpeed(
|
||||||
if (TrainParams->CheckTrainLatency() < 5.0)
|
VelDesired,
|
||||||
if (TrainParams->TTVmax > 0.0)
|
mvOccupied->RunningTrack.Velmax ); // uwaga na ograniczenia szlakowej!
|
||||||
VelDesired = Global::Min0RSpeed(
|
}
|
||||||
VelDesired,
|
if( VelforDriver >= 0 ) {
|
||||||
TrainParams
|
// tu jest zero przy zmianie kierunku jazdy
|
||||||
->TTVmax); // jesli nie spozniony to nie przekraczać rozkladowej
|
// Ra: tu może być 40, jeśli mechanik nie ma znajomości szlaaku, albo kierowca jeździ 70
|
||||||
|
VelDesired = Global::Min0RSpeed( VelDesired, VelforDriver );
|
||||||
|
}
|
||||||
|
if( ( TrainParams != nullptr )
|
||||||
|
&& ( TrainParams->CheckTrainLatency() < 5.0 )
|
||||||
|
&& ( TrainParams->TTVmax > 0.0 ) ) {
|
||||||
|
// jesli nie spozniony to nie przekraczać rozkladowej
|
||||||
|
VelDesired =
|
||||||
|
Global::Min0RSpeed(
|
||||||
|
VelDesired,
|
||||||
|
TrainParams->TTVmax );
|
||||||
|
}
|
||||||
if (VelDesired > 0.0)
|
if (VelDesired > 0.0)
|
||||||
if( ( ( iDrivigFlags & moveStopHere ) == 0 )
|
if( ( ( iDrivigFlags & moveStopHere ) == 0 )
|
||||||
|| ( ( SemNextIndex != -1 )
|
|| ( ( SemNextIndex != -1 )
|
||||||
@@ -4454,10 +4477,16 @@ TController::UpdateSituation(double dt) {
|
|||||||
VelDesired = Global::Min0RSpeed( VelDesired, VelNext );
|
VelDesired = Global::Min0RSpeed( VelDesired, VelNext );
|
||||||
*/
|
*/
|
||||||
if( VelNext == 0.0 ) {
|
if( VelNext == 0.0 ) {
|
||||||
// hamowanie tak, aby stanąć
|
if( mvOccupied->CategoryFlag & 1 ) {
|
||||||
VelDesired = VelNext;
|
// hamowanie tak, aby stanąć
|
||||||
AccDesired = ( VelNext * VelNext - vel * vel ) / ( 25.92 * ( ActualProximityDist + 0.1 - 0.5*fMinProximityDist ) );
|
VelDesired = VelNext;
|
||||||
AccDesired = std::min( AccDesired, fAccThreshold );
|
AccDesired = ( VelNext * VelNext - vel * vel ) / ( 25.92 * ( ActualProximityDist + 0.1 - 0.5*fMinProximityDist ) );
|
||||||
|
AccDesired = std::min( AccDesired, fAccThreshold );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// for cars (and others) coast at low speed until we hit min proximity range
|
||||||
|
VelDesired = Global::Min0RSpeed( VelDesired, 5.0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
18
Driver.h
18
Driver.h
@@ -212,13 +212,12 @@ private: // parametry aktualnego składu
|
|||||||
double AbsAccS_pub = 0.0; // próg opóźnienia dla zadziałania hamulca
|
double AbsAccS_pub = 0.0; // próg opóźnienia dla zadziałania hamulca
|
||||||
double fBrake_a0[BrakeAccTableSize+1] = { 0.0 }; // próg opóźnienia dla zadziałania hamulca
|
double fBrake_a0[BrakeAccTableSize+1] = { 0.0 }; // próg opóźnienia dla zadziałania hamulca
|
||||||
double fBrake_a1[BrakeAccTableSize+1] = { 0.0 }; // próg opóźnienia dla zadziałania hamulca
|
double fBrake_a1[BrakeAccTableSize+1] = { 0.0 }; // próg opóźnienia dla zadziałania hamulca
|
||||||
public:
|
|
||||||
double fLastStopExpDist = -1.0; // odległość wygasania ostateniego przystanku
|
double fLastStopExpDist = -1.0; // odległość wygasania ostateniego przystanku
|
||||||
double ReactionTime = 0.0; // czas reakcji Ra: czego i na co? świadomości AI
|
double ReactionTime = 0.0; // czas reakcji Ra: czego i na co? świadomości AI
|
||||||
double fBrakeTime = 0.0; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca
|
double fBrakeTime = 0.0; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca
|
||||||
private:
|
|
||||||
double fReady = 0.0; // poziom odhamowania wagonów
|
double fReady = 0.0; // poziom odhamowania wagonów
|
||||||
bool Ready = false; // ABu: stan gotowosci do odjazdu - sprawdzenie odhamowania wagonow
|
bool Ready = false; // ABu: stan gotowosci do odjazdu - sprawdzenie odhamowania wagonow
|
||||||
|
private:
|
||||||
double LastUpdatedTime = 0.0; // czas od ostatniego logu
|
double LastUpdatedTime = 0.0; // czas od ostatniego logu
|
||||||
double ElapsedTime = 0.0; // czas od poczatku logu
|
double ElapsedTime = 0.0; // czas od poczatku logu
|
||||||
double deltalog = 0.05; // przyrost czasu
|
double deltalog = 0.05; // przyrost czasu
|
||||||
@@ -227,26 +226,21 @@ private: // parametry aktualnego składu
|
|||||||
double m_radiocontroltime{ 0.0 }; // timer used to control speed of radio operations
|
double m_radiocontroltime{ 0.0 }; // timer used to control speed of radio operations
|
||||||
TAction eAction = actSleep; // aktualny stan
|
TAction eAction = actSleep; // aktualny stan
|
||||||
public:
|
public:
|
||||||
inline TAction GetAction()
|
inline
|
||||||
{
|
TAction GetAction() {
|
||||||
return eAction;
|
return eAction; }
|
||||||
}
|
|
||||||
bool AIControllFlag = false; // rzeczywisty/wirtualny maszynista
|
bool AIControllFlag = false; // rzeczywisty/wirtualny maszynista
|
||||||
int iRouteWanted = 3; // oczekiwany kierunek jazdy (0-stop,1-lewo,2-prawo,3-prosto) np. odpala
|
int iRouteWanted = 3; // oczekiwany kierunek jazdy (0-stop,1-lewo,2-prawo,3-prosto) np. odpala
|
||||||
// migacz lub czeka na stan zwrotnicy
|
// migacz lub czeka na stan zwrotnicy
|
||||||
private:
|
private:
|
||||||
TDynamicObject *pVehicle = nullptr; // pojazd w którym siedzi sterujący
|
TDynamicObject *pVehicle = nullptr; // pojazd w którym siedzi sterujący
|
||||||
TDynamicObject
|
TDynamicObject *pVehicles[2]; // skrajne pojazdy w składzie (niekoniecznie bezpośrednio sterowane)
|
||||||
*pVehicles[2]; // skrajne pojazdy w składzie (niekoniecznie bezpośrednio sterowane)
|
|
||||||
TMoverParameters *mvControlling = nullptr; // jakim pojazdem steruje (może silnikowym w EZT)
|
TMoverParameters *mvControlling = nullptr; // jakim pojazdem steruje (może silnikowym w EZT)
|
||||||
TMoverParameters *mvOccupied = nullptr; // jakim pojazdem hamuje
|
TMoverParameters *mvOccupied = nullptr; // jakim pojazdem hamuje
|
||||||
TTrainParameters *TrainParams = nullptr; // rozkład jazdy zawsze jest, nawet jeśli pusty
|
TTrainParameters *TrainParams = nullptr; // rozkład jazdy zawsze jest, nawet jeśli pusty
|
||||||
// int TrainNumber; //numer rozkladowy tego pociagu
|
|
||||||
// AnsiString OrderCommand; //komenda pobierana z pojazdu
|
|
||||||
// double OrderValue; //argument komendy
|
|
||||||
int iRadioChannel = 1; // numer aktualnego kanału radiowego
|
int iRadioChannel = 1; // numer aktualnego kanału radiowego
|
||||||
sound *tsGuardSignal = nullptr; // komunikat od kierownika
|
|
||||||
int iGuardRadio = 0; // numer kanału radiowego kierownika (0, gdy nie używa radia)
|
int iGuardRadio = 0; // numer kanału radiowego kierownika (0, gdy nie używa radia)
|
||||||
|
sound *tsGuardSignal = nullptr; // komunikat od kierownika
|
||||||
public:
|
public:
|
||||||
double AccPreferred = 0.0; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy wykryciu kolizji)
|
double AccPreferred = 0.0; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy wykryciu kolizji)
|
||||||
double AccDesired = AccPreferred; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj)
|
double AccDesired = AccPreferred; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj)
|
||||||
|
|||||||
170
DynObj.cpp
170
DynObj.cpp
@@ -1263,71 +1263,65 @@ int TDynamicObject::Dettach(int dir)
|
|||||||
.CouplingFlag; // sprzęg po rozłączaniu (czego się nie da odpiąć
|
.CouplingFlag; // sprzęg po rozłączaniu (czego się nie da odpiąć
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDynamicObject::CouplersDettach(double MinDist, int MyScanDir)
|
void TDynamicObject::CouplersDettach(double MinDist, int MyScanDir) {
|
||||||
{ // funkcja rozłączajaca podłączone sprzęgi,
|
// funkcja rozłączajaca podłączone sprzęgi, jeśli odległość przekracza (MinDist)
|
||||||
// jeśli odległość przekracza (MinDist)
|
|
||||||
// MinDist - dystans minimalny, dla ktorego mozna rozłączać
|
// MinDist - dystans minimalny, dla ktorego mozna rozłączać
|
||||||
if (MyScanDir > 0)
|
if (MyScanDir > 0) {
|
||||||
{
|
// pojazd od strony sprzęgu 0
|
||||||
if (PrevConnected) // pojazd od strony sprzęgu 0
|
if( ( PrevConnected != nullptr )
|
||||||
{
|
&& ( MoverParameters->Couplers[ TMoverParameters::side::front ].CoupleDist > MinDist ) ) {
|
||||||
if (MoverParameters->Couplers[0].CoupleDist > MinDist) {
|
// sprzęgi wirtualne zawsze przekraczają
|
||||||
// sprzęgi wirtualne zawsze przekraczają
|
if( ( PrevConnectedNo == TMoverParameters::side::front ?
|
||||||
|
PrevConnected->PrevConnected :
|
||||||
if ((PrevConnectedNo ? PrevConnected->NextConnected :
|
PrevConnected->NextConnected )
|
||||||
PrevConnected->PrevConnected) == this)
|
== this ) {
|
||||||
{ // Ra: nie rozłączamy znalezionego, jeżeli nie do nas
|
// Ra: nie rozłączamy znalezionego, jeżeli nie do nas podłączony
|
||||||
// podłączony (może jechać w
|
// (może jechać w innym kierunku)
|
||||||
// innym kierunku)
|
PrevConnected->MoverParameters->Couplers[PrevConnectedNo].Connected = nullptr;
|
||||||
PrevConnected->MoverParameters->Couplers[PrevConnectedNo].Connected = NULL;
|
if( PrevConnectedNo == TMoverParameters::side::front ) {
|
||||||
if (PrevConnectedNo == 0)
|
// sprzęg 0 nie podłączony
|
||||||
{
|
PrevConnected->PrevConnectedNo = 2;
|
||||||
PrevConnected->PrevConnectedNo = 2; // sprzęg 0 nie podłączony
|
PrevConnected->PrevConnected = nullptr;
|
||||||
PrevConnected->PrevConnected = NULL;
|
}
|
||||||
}
|
else if( PrevConnectedNo == TMoverParameters::side::rear ) {
|
||||||
else if (PrevConnectedNo == 1)
|
// sprzęg 1 nie podłączony
|
||||||
{
|
PrevConnected->NextConnectedNo = 2;
|
||||||
PrevConnected->NextConnectedNo = 2; // sprzęg 1 nie podłączony
|
PrevConnected->NextConnected = nullptr;
|
||||||
PrevConnected->NextConnected = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// za to zawsze odłączamy siebie
|
|
||||||
PrevConnected = NULL;
|
|
||||||
PrevConnectedNo = 2; // sprzęg 0 nie podłączony
|
|
||||||
MoverParameters->Couplers[0].Connected = nullptr;
|
|
||||||
}
|
}
|
||||||
|
// za to zawsze odłączamy siebie
|
||||||
|
PrevConnected = nullptr;
|
||||||
|
PrevConnectedNo = 2; // sprzęg 0 nie podłączony
|
||||||
|
MoverParameters->Couplers[ TMoverParameters::side::front ].Connected = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
// pojazd od strony sprzęgu 1
|
||||||
if (NextConnected) // pojazd od strony sprzęgu 1
|
if( ( NextConnected != nullptr )
|
||||||
{
|
&& ( MoverParameters->Couplers[ TMoverParameters::side::rear ].CoupleDist > MinDist ) ) {
|
||||||
if (MoverParameters->Couplers[1].CoupleDist > MinDist) {
|
// sprzęgi wirtualne zawsze przekraczają
|
||||||
// sprzęgi wirtualne zawsze przekraczają
|
if( ( NextConnectedNo == TMoverParameters::side::front ?
|
||||||
|
NextConnected->PrevConnected :
|
||||||
if ((NextConnectedNo ? NextConnected->NextConnected :
|
NextConnected->NextConnected )
|
||||||
NextConnected->PrevConnected) == this)
|
== this) {
|
||||||
{ // Ra: nie rozłączamy znalezionego, jeżeli nie do nas
|
// Ra: nie rozłączamy znalezionego, jeżeli nie do nas podłączony
|
||||||
// podłączony (może jechać w
|
// (może jechać w innym kierunku)
|
||||||
// innym kierunku)
|
NextConnected->MoverParameters->Couplers[ NextConnectedNo ].Connected = nullptr;
|
||||||
NextConnected->MoverParameters->Couplers[NextConnectedNo].Connected = NULL;
|
if( NextConnectedNo == TMoverParameters::side::front ) {
|
||||||
if (NextConnectedNo == 0)
|
// sprzęg 0 nie podłączony
|
||||||
{
|
NextConnected->PrevConnectedNo = 2;
|
||||||
NextConnected->PrevConnectedNo = 2; // sprzęg 0 nie podłączony
|
NextConnected->PrevConnected = nullptr;
|
||||||
NextConnected->PrevConnected = NULL;
|
}
|
||||||
}
|
else if( NextConnectedNo == TMoverParameters::side::rear ) {
|
||||||
else if (NextConnectedNo == 1)
|
// sprzęg 1 nie podłączony
|
||||||
{
|
NextConnected->NextConnectedNo = 2;
|
||||||
NextConnected->NextConnectedNo = 2; // sprzęg 1 nie podłączony
|
NextConnected->NextConnected = nullptr;
|
||||||
NextConnected->NextConnected = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NextConnected = NULL;
|
|
||||||
NextConnectedNo = 2; // sprzęg 1 nie podłączony
|
|
||||||
MoverParameters->Couplers[1].Connected = nullptr;
|
|
||||||
}
|
}
|
||||||
|
// za to zawsze odłączamy siebie
|
||||||
|
NextConnected = nullptr;
|
||||||
|
NextConnectedNo = 2; // sprzęg 1 nie podłączony
|
||||||
|
MoverParameters->Couplers[1].Connected = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1338,15 +1332,7 @@ void TDynamicObject::ABuScanObjects( int Direction, double Distance )
|
|||||||
// pojazdu
|
// pojazdu
|
||||||
// ScanDir=1 - od strony Coupler0, ScanDir=-1 - od strony Coupler1
|
// ScanDir=1 - od strony Coupler0, ScanDir=-1 - od strony Coupler1
|
||||||
auto const initialdirection = Direction; // zapamiętanie kierunku poszukiwań na torze początkowym, względem sprzęgów
|
auto const initialdirection = Direction; // zapamiętanie kierunku poszukiwań na torze początkowym, względem sprzęgów
|
||||||
/*
|
|
||||||
TTrackFollower const *firstaxle = (initialdirection > 0 ? &Axle0 : &Axle1); // można by to trzymać w trainset
|
|
||||||
TTrack const *track = firstaxle->GetTrack(); // tor na którym "stoi" skrajny wózek
|
|
||||||
// (może być inny niż tor pojazdu)
|
|
||||||
if( firstaxle->GetDirection() < 0 ) {
|
|
||||||
// czy oś jest ustawiona w stronę Point1?
|
|
||||||
Direction = -Direction; // jeśli tak, to kierunek szukania będzie przeciwny
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
TTrack const *track = RaTrackGet();
|
TTrack const *track = RaTrackGet();
|
||||||
if( RaDirectionGet() < 0 ) {
|
if( RaDirectionGet() < 0 ) {
|
||||||
// czy oś jest ustawiona w stronę Point1?
|
// czy oś jest ustawiona w stronę Point1?
|
||||||
@@ -1429,6 +1415,18 @@ void TDynamicObject::ABuScanObjects( int Direction, double Distance )
|
|||||||
|
|
||||||
if( foundobject->MoverParameters->Couplers[ foundcoupler ].CouplingFlag == coupling::faux ) {
|
if( foundobject->MoverParameters->Couplers[ foundcoupler ].CouplingFlag == coupling::faux ) {
|
||||||
// Ra: wpinamy się wirtualnym tylko jeśli znaleziony ma wirtualny sprzęg
|
// Ra: wpinamy się wirtualnym tylko jeśli znaleziony ma wirtualny sprzęg
|
||||||
|
if( ( foundcoupler == TMoverParameters::side::front ?
|
||||||
|
foundobject->PrevConnected :
|
||||||
|
foundobject->NextConnected )
|
||||||
|
!= this ) {
|
||||||
|
// but first break existing connection of the target,
|
||||||
|
// otherwise we risk leaving the target's connected vehicle with active one-side connection
|
||||||
|
foundobject->CouplersDettach(
|
||||||
|
1.0,
|
||||||
|
( foundcoupler == TMoverParameters::side::front ?
|
||||||
|
1 :
|
||||||
|
-1 ) );
|
||||||
|
}
|
||||||
foundobject->MoverParameters->Attach( foundcoupler, mycoupler, this->MoverParameters, coupling::faux );
|
foundobject->MoverParameters->Attach( foundcoupler, mycoupler, this->MoverParameters, coupling::faux );
|
||||||
|
|
||||||
if( foundcoupler == TMoverParameters::side::front ) {
|
if( foundcoupler == TMoverParameters::side::front ) {
|
||||||
@@ -1453,18 +1451,18 @@ void TDynamicObject::ABuScanObjects( int Direction, double Distance )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// odległość do najbliższego pojazdu w linii prostej
|
// NOTE: the distance we get is approximated as it's measured between active axles, not vehicle ends
|
||||||
// Ra: jeśli dwa samochody się mijają na odcinku przed zawrotką, to odległość między nimi nie może być liczona w linii prostej!
|
fTrackBlock = distance;
|
||||||
fTrackBlock = MoverParameters->Couplers[mycoupler].CoupleDist;
|
if( distance < 100.0 ) {
|
||||||
if( track->iCategoryFlag & 254 ) {
|
// at short distances start to calculate range between couplers directly
|
||||||
// jeśli samochód
|
// odległość do najbliższego pojazdu w linii prostej
|
||||||
if( distance > MoverParameters->Dim.L + foundobject->MoverParameters->Dim.L ) {
|
fTrackBlock = std::min( fTrackBlock, MoverParameters->Couplers[ mycoupler ].CoupleDist );
|
||||||
// przeskanowana odległość większa od długości pojazdów
|
}
|
||||||
// else if (ActDist<ScanDist) //dla samochodów musi być uwzględniona
|
if( ( false == TestFlag( track->iCategoryFlag, 1 ) )
|
||||||
// droga do
|
&& ( distance > 50.0 ) ) {
|
||||||
// zawrócenia
|
// Ra: jeśli dwa samochody się mijają na odcinku przed zawrotką, to odległość między nimi nie może być liczona w linii prostej!
|
||||||
fTrackBlock = distance; // ta odległość jest wiecej warta
|
// NOTE: the distance is approximated, and additionally less accurate for cars heading in opposite direction
|
||||||
}
|
fTrackBlock = distance - ( 0.5 * ( MoverParameters->Dim.L + foundobject->MoverParameters->Dim.L ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2589,15 +2587,19 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
tp.CategoryFlag = MyTrack->iCategoryFlag & 15;
|
tp.CategoryFlag = MyTrack->iCategoryFlag & 15;
|
||||||
tp.DamageFlag = MyTrack->iDamageFlag;
|
tp.DamageFlag = MyTrack->iDamageFlag;
|
||||||
tp.QualityFlag = MyTrack->iQualityFlag;
|
tp.QualityFlag = MyTrack->iQualityFlag;
|
||||||
if ((MoverParameters->Couplers[0].CouplingFlag > 0) &&
|
|
||||||
(MoverParameters->Couplers[1].CouplingFlag > 0))
|
// couplers
|
||||||
{
|
if( ( MoverParameters->Couplers[ 0 ].CouplingFlag != coupling::faux )
|
||||||
|
&& ( MoverParameters->Couplers[ 1 ].CouplingFlag != coupling::faux ) ) {
|
||||||
|
|
||||||
MoverParameters->InsideConsist = true;
|
MoverParameters->InsideConsist = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
MoverParameters->InsideConsist = false;
|
MoverParameters->InsideConsist = false;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
|
||||||
// napiecie sieci trakcyjnej
|
// napiecie sieci trakcyjnej
|
||||||
// Ra 15-01: przeliczenie poboru prądu powinno być robione wcześniej, żeby na
|
// Ra 15-01: przeliczenie poboru prądu powinno być robione wcześniej, żeby na
|
||||||
// tym etapie były
|
// tym etapie były
|
||||||
|
|||||||
73
EU07.cpp
73
EU07.cpp
@@ -244,10 +244,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
std::string token(argv[i]);
|
std::string token(argv[i]);
|
||||||
|
|
||||||
if (token == "-modifytga")
|
if (token == "-e3d") {
|
||||||
Global::iModifyTGA = -1;
|
|
||||||
else if (token == "-e3d")
|
|
||||||
{
|
|
||||||
if (Global::iConvertModels > 0)
|
if (Global::iConvertModels > 0)
|
||||||
Global::iConvertModels = -Global::iConvertModels;
|
Global::iConvertModels = -Global::iConvertModels;
|
||||||
else
|
else
|
||||||
@@ -263,8 +260,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "usage: " << std::string(argv[0]) << " [-s sceneryfilepath] "
|
std::cout
|
||||||
<< "[-v vehiclename] [-modifytga] [-e3d]" << std::endl;
|
<< "usage: " << std::string(argv[0])
|
||||||
|
<< " [-s sceneryfilepath]"
|
||||||
|
<< " [-v vehiclename]"
|
||||||
|
<< " [-e3d]"
|
||||||
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,49 +377,41 @@ int main(int argc, char *argv[])
|
|||||||
if( !joyGetNumDevs() )
|
if( !joyGetNumDevs() )
|
||||||
WriteLog( "No joystick" );
|
WriteLog( "No joystick" );
|
||||||
*/
|
*/
|
||||||
if( Global::iModifyTGA < 0 ) { // tylko modyfikacja TGA, bez uruchamiania symulacji
|
if( Global::iConvertModels < 0 ) {
|
||||||
Global::iMaxTextureSize = 64; //żeby nie zamulać pamięci
|
Global::iConvertModels = -Global::iConvertModels;
|
||||||
World.ModifyTGA(); // rekurencyjne przeglądanie katalogów
|
World.CreateE3D( "models/" ); // rekurencyjne przeglądanie katalogów
|
||||||
}
|
World.CreateE3D( "dynamic/", true );
|
||||||
else {
|
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
|
||||||
if( Global::iConvertModels < 0 ) {
|
|
||||||
Global::iConvertModels = -Global::iConvertModels;
|
|
||||||
World.CreateE3D( "models/" ); // rekurencyjne przeglądanie katalogów
|
|
||||||
World.CreateE3D( "dynamic/", true );
|
|
||||||
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Console::On(); // włączenie konsoli
|
Console::On(); // włączenie konsoli
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while( ( false == glfwWindowShouldClose( window ) )
|
while( ( false == glfwWindowShouldClose( window ) )
|
||||||
&& ( true == World.Update() )
|
&& ( true == World.Update() )
|
||||||
&& ( true == GfxRenderer.Render() ) ) {
|
&& ( true == GfxRenderer.Render() ) ) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
input::Keyboard.poll();
|
input::Keyboard.poll();
|
||||||
if( true == Global::InputMouse ) { input::Mouse.poll(); }
|
if( true == Global::InputMouse ) { input::Mouse.poll(); }
|
||||||
if( true == Global::InputGamepad ) { input::Gamepad.poll(); }
|
if( true == Global::InputGamepad ) { input::Gamepad.poll(); }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch( std::bad_alloc const &Error ) {
|
}
|
||||||
|
catch (std::runtime_error e)
|
||||||
|
{
|
||||||
|
ErrorLog(e.what());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
catch( std::bad_alloc const &Error ) {
|
||||||
|
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
catch (std::runtime_error e)
|
|
||||||
{
|
|
||||||
ErrorLog(e.what());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
TPythonInterpreter::killInstance();
|
TPythonInterpreter::killInstance();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
|
||||||
delete pConsole;
|
delete pConsole;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
120
Event.cpp
120
Event.cpp
@@ -140,10 +140,7 @@ void TEvent::Conditions(cParser *parser, std::string s)
|
|||||||
|
|
||||||
void TEvent::Load(cParser *parser, vector3 *org)
|
void TEvent::Load(cParser *parser, vector3 *org)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int ti;
|
|
||||||
std::string token;
|
std::string token;
|
||||||
//string str;
|
|
||||||
|
|
||||||
bEnabled = true; // zmieniane na false dla eventów używanych do skanowania sygnałów
|
bEnabled = true; // zmieniane na false dla eventów używanych do skanowania sygnałów
|
||||||
|
|
||||||
@@ -247,47 +244,47 @@ void TEvent::Load(cParser *parser, vector3 *org)
|
|||||||
*parser >> token;
|
*parser >> token;
|
||||||
Conditions(parser, token); // sprawdzanie warunków
|
Conditions(parser, token); // sprawdzanie warunków
|
||||||
break;
|
break;
|
||||||
case tp_CopyValues:
|
case tp_CopyValues: {
|
||||||
Params[9].asText = NULL;
|
Params[9].asText = nullptr;
|
||||||
iFlags = update_memstring | update_memval1 | update_memval2; // normalanie trzy
|
iFlags = update_memstring | update_memval1 | update_memval2; // normalanie trzy
|
||||||
i = 0;
|
int paramidx { 0 };
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token; // nazwa drugiej komórki (źródłowej)
|
*parser >> token; // nazwa drugiej komórki (źródłowej)
|
||||||
while (token.compare("endevent") != 0)
|
while (token.compare("endevent") != 0) {
|
||||||
{
|
|
||||||
switch (++i)
|
switch (++paramidx)
|
||||||
{ // znaczenie kolejnych parametrów
|
{ // znaczenie kolejnych parametrów
|
||||||
case 1: // nazwa drugiej komórki (źródłowej)
|
case 1: // nazwa drugiej komórki (źródłowej)
|
||||||
Params[9].asText = new char[token.size() + 1]; // usuwane i zamieniane na wskaźnik
|
Params[9].asText = new char[token.size() + 1]; // usuwane i zamieniane na wskaźnik
|
||||||
strcpy(Params[9].asText, token.c_str());
|
strcpy(Params[9].asText, token.c_str());
|
||||||
break;
|
break;
|
||||||
case 2: // maska wartości
|
case 2: // maska wartości
|
||||||
iFlags = stol_def(token,
|
iFlags = stol_def(token, (update_memstring | update_memval1 | update_memval2));
|
||||||
(update_memstring | update_memval1 | update_memval2));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tp_WhoIs:
|
}
|
||||||
|
case tp_WhoIs: {
|
||||||
iFlags = update_memstring | update_memval1 | update_memval2; // normalanie trzy
|
iFlags = update_memstring | update_memval1 | update_memval2; // normalanie trzy
|
||||||
i = 0;
|
int paramidx { 0 };
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token; // nazwa drugiej komórki (źródłowej)
|
*parser >> token; // nazwa drugiej komórki (źródłowej)
|
||||||
while (token.compare("endevent") != 0)
|
while( token.compare( "endevent" ) != 0 ) {
|
||||||
{
|
switch( ++paramidx ) { // znaczenie kolejnych parametrów
|
||||||
switch (++i)
|
case 1: // maska wartości
|
||||||
{ // znaczenie kolejnych parametrów
|
iFlags = stol_def( token, ( update_memstring | update_memval1 | update_memval2 ) );
|
||||||
case 1: // maska wartości
|
break;
|
||||||
iFlags = stol_def(token,
|
default:
|
||||||
(update_memstring | update_memval1 | update_memval2));
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case tp_GetValues:
|
case tp_GetValues:
|
||||||
case tp_LogValues:
|
case tp_LogValues:
|
||||||
parser->getTokens(); //"endevent"
|
parser->getTokens(); //"endevent"
|
||||||
@@ -384,25 +381,27 @@ void TEvent::Load(cParser *parser, vector3 *org)
|
|||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
break;
|
break;
|
||||||
case tp_Lights:
|
case tp_Lights: {
|
||||||
i = 0;
|
int paramidx { 0 };
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
if (token.compare("endevent") != 0)
|
if( token.compare( "endevent" ) != 0 ) {
|
||||||
{
|
|
||||||
// str = AnsiString(token.c_str());
|
if( paramidx < 8 ) {
|
||||||
if (i < 8)
|
Params[ paramidx ].asdouble = atof( token.c_str() ); // teraz może mieć ułamek
|
||||||
Params[i].asdouble = atof(token.c_str()); // teraz może mieć ułamek
|
++paramidx;
|
||||||
i++;
|
}
|
||||||
|
else {
|
||||||
|
ErrorLog( "Bad event: lights event \"" + asName + "\" with more than 8 parameters" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (token.compare("endevent") != 0);
|
} while( token.compare( "endevent" ) != 0 );
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case tp_Visible: // zmiana wyświetlania obiektu
|
case tp_Visible: // zmiana wyświetlania obiektu
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
// str = AnsiString(token.c_str());
|
|
||||||
Params[0].asInt = atoi(token.c_str());
|
Params[0].asInt = atoi(token.c_str());
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
@@ -410,7 +409,6 @@ void TEvent::Load(cParser *parser, vector3 *org)
|
|||||||
case tp_Velocity:
|
case tp_Velocity:
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
// str = AnsiString(token.c_str());
|
|
||||||
Params[0].asdouble = atof(token.c_str()) * 0.28;
|
Params[0].asdouble = atof(token.c_str()) * 0.28;
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
@@ -544,38 +542,46 @@ void TEvent::Load(cParser *parser, vector3 *org)
|
|||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
break;
|
break;
|
||||||
case tp_Multiple:
|
case tp_Multiple: {
|
||||||
i = 0;
|
int paramidx { 0 };
|
||||||
ti = 0; // flaga dla else
|
bool ti { false }; // flaga dla else
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
// str = AnsiString(token.c_str());
|
|
||||||
while (token != "endevent" && token != "condition" &&
|
while( ( token != "endevent" )
|
||||||
token != "randomdelay")
|
&& ( token != "condition" )
|
||||||
{
|
&& ( token != "randomdelay" ) ) {
|
||||||
if ((token.substr(0, 5) != "none_") ? (i < 8) : false)
|
|
||||||
{ // eventy rozpoczynające się od "none_" są ignorowane
|
if( token != "else" ) {
|
||||||
if (token != "else")
|
if( token.substr( 0, 5 ) != "none_" ) {
|
||||||
{
|
// eventy rozpoczynające się od "none_" są ignorowane
|
||||||
Params[i].asText = new char[token.size() + 1];
|
if( paramidx < 8 ) {
|
||||||
strcpy(Params[i].asText, token.c_str());
|
Params[ paramidx ].asText = new char[ token.size() + 1 ];
|
||||||
if (ti)
|
strcpy( Params[ paramidx ].asText, token.c_str() );
|
||||||
iFlags |= conditional_else << i; // oflagowanie dla eventów "else"
|
if( ti ) {
|
||||||
i++;
|
// oflagowanie dla eventów "else"
|
||||||
|
iFlags |= conditional_else << paramidx;
|
||||||
|
}
|
||||||
|
++paramidx;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ErrorLog( "Bad event: multi-event \"" + asName + "\" with more than 8 events; discarding link to event \"" + token + "\"" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WriteLog( "Multi-event \"" + asName + "\" ignored link to event \"" + token + "\"" );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
ti = !ti; // zmiana flagi dla słowa "else"
|
|
||||||
}
|
}
|
||||||
else if (i >= 8)
|
else {
|
||||||
ErrorLog("Bad event: \"" + token + "\" ignored in multiple \"" + asName + "\"!");
|
// zmiana flagi dla słowa "else"
|
||||||
else
|
ti = !ti;
|
||||||
WriteLog("Event \"" + token + "\" ignored in multiple \"" + asName + "\"!");
|
}
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> token;
|
*parser >> token;
|
||||||
// str = AnsiString(token.c_str());
|
|
||||||
}
|
}
|
||||||
Conditions(parser, token); // sprawdzanie warunków
|
Conditions(parser, token); // sprawdzanie warunków
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case tp_Voltage: // zmiana napięcia w zasilaczu (TractionPowerSource)
|
case tp_Voltage: // zmiana napięcia w zasilaczu (TractionPowerSource)
|
||||||
case tp_Friction: // zmiana przyczepnosci na scenerii
|
case tp_Friction: // zmiana przyczepnosci na scenerii
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
|
|||||||
93
Globals.cpp
93
Globals.cpp
@@ -55,11 +55,8 @@ double Global::fTimeAngleDeg = 0.0; // godzina w postaci kąta
|
|||||||
float Global::fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego
|
float Global::fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego
|
||||||
std::string Global::szTexturesTGA = ".tga"; // lista tekstur od TGA
|
std::string Global::szTexturesTGA = ".tga"; // lista tekstur od TGA
|
||||||
std::string Global::szTexturesDDS = ".dds"; // lista tekstur od DDS
|
std::string Global::szTexturesDDS = ".dds"; // lista tekstur od DDS
|
||||||
int Global::iKeyLast = 0; // ostatnio naciśnięty klawisz w celu logowania
|
|
||||||
int Global::iPause = 0; // 0x10; // globalna pauza ruchu
|
int Global::iPause = 0; // 0x10; // globalna pauza ruchu
|
||||||
bool Global::bActive = true;
|
bool Global::bActive = true; // czy jest aktywnym oknem
|
||||||
int Global::iErorrCounter = 0; // licznik sprawdzań do śledzenia błędów OpenGL
|
|
||||||
int Global::iTextures = 0; // licznik użytych tekstur
|
|
||||||
TWorld *Global::pWorld = NULL;
|
TWorld *Global::pWorld = NULL;
|
||||||
cParser *Global::pParser = NULL;
|
cParser *Global::pParser = NULL;
|
||||||
TCamera *Global::pCamera = NULL; // parametry kamery
|
TCamera *Global::pCamera = NULL; // parametry kamery
|
||||||
@@ -74,8 +71,6 @@ double Global::pCameraRotation;
|
|||||||
double Global::pCameraRotationDeg;
|
double Global::pCameraRotationDeg;
|
||||||
std::vector<vector3> Global::FreeCameraInit;
|
std::vector<vector3> Global::FreeCameraInit;
|
||||||
std::vector<vector3> Global::FreeCameraInitAngle;
|
std::vector<vector3> Global::FreeCameraInitAngle;
|
||||||
float Global::Background[3] = {0.2f, 0.4f, 0.33f};
|
|
||||||
GLfloat Global::AtmoColor[] = {0.423f, 0.702f, 1.0f};
|
|
||||||
GLfloat Global::FogColor[] = {0.6f, 0.7f, 0.8f};
|
GLfloat Global::FogColor[] = {0.6f, 0.7f, 0.8f};
|
||||||
double Global::fFogStart = 1700;
|
double Global::fFogStart = 1700;
|
||||||
double Global::fFogEnd = 2000;
|
double Global::fFogEnd = 2000;
|
||||||
@@ -121,10 +116,6 @@ bool Global::bEnableTraction = true;
|
|||||||
bool Global::bLoadTraction = true;
|
bool Global::bLoadTraction = true;
|
||||||
bool Global::bLiveTraction = true;
|
bool Global::bLiveTraction = true;
|
||||||
float Global::AnisotropicFiltering = 8.0f; // requested level of anisotropic filtering. TODO: move it to renderer object
|
float Global::AnisotropicFiltering = 8.0f; // requested level of anisotropic filtering. TODO: move it to renderer object
|
||||||
int Global::iDefaultFiltering = 9; // domyślne rozmywanie tekstur TGA bez alfa
|
|
||||||
int Global::iBallastFiltering = 9; // domyślne rozmywanie tekstur podsypki
|
|
||||||
int Global::iRailProFiltering = 5; // domyślne rozmywanie tekstur szyn
|
|
||||||
int Global::iDynamicFiltering = 5; // domyślne rozmywanie tekstur pojazdów
|
|
||||||
std::string Global::LastGLError;
|
std::string Global::LastGLError;
|
||||||
GLint Global::iMaxTextureSize = 4096; // maksymalny rozmiar tekstury
|
GLint Global::iMaxTextureSize = 4096; // maksymalny rozmiar tekstury
|
||||||
bool Global::bSmoothTraction = false; // wygładzanie drutów starym sposobem
|
bool Global::bSmoothTraction = false; // wygładzanie drutów starym sposobem
|
||||||
@@ -136,7 +127,6 @@ bool Global::bGlutFont = false; // czy tekst generowany przez GLUT32.DLL
|
|||||||
//int Global::iConvertModels = 7; // tworzenie plików binarnych, +2-optymalizacja transformów
|
//int Global::iConvertModels = 7; // tworzenie plików binarnych, +2-optymalizacja transformów
|
||||||
int Global::iConvertModels{ 0 }; // temporary override, to prevent generation of .e3d not compatible with old exe
|
int Global::iConvertModels{ 0 }; // temporary override, to prevent generation of .e3d not compatible with old exe
|
||||||
int Global::iSlowMotionMask = -1; // maska wyłączanych właściwości dla zwiększenia FPS
|
int Global::iSlowMotionMask = -1; // maska wyłączanych właściwości dla zwiększenia FPS
|
||||||
int Global::iModifyTGA = 7; // czy korygować pliki TGA dla szybszego wczytywania
|
|
||||||
// bool Global::bTerrainCompact=true; //czy zapisać teren w pliku
|
// bool Global::bTerrainCompact=true; //czy zapisać teren w pliku
|
||||||
TAnimModel *Global::pTerrainCompact = NULL; // do zapisania terenu w pliku
|
TAnimModel *Global::pTerrainCompact = NULL; // do zapisania terenu w pliku
|
||||||
std::string Global::asTerrainModel = ""; // nazwa obiektu terenu do zapisania w pliku
|
std::string Global::asTerrainModel = ""; // nazwa obiektu terenu do zapisania w pliku
|
||||||
@@ -144,17 +134,13 @@ double Global::fFpsAverage = 20.0; // oczekiwana wartosć FPS
|
|||||||
double Global::fFpsDeviation = 5.0; // odchylenie standardowe FPS
|
double Global::fFpsDeviation = 5.0; // odchylenie standardowe FPS
|
||||||
double Global::fFpsMin = 30.0; // dolna granica FPS, przy której promień scenerii będzie zmniejszany
|
double Global::fFpsMin = 30.0; // dolna granica FPS, przy której promień scenerii będzie zmniejszany
|
||||||
double Global::fFpsMax = 65.0; // górna granica FPS, przy której promień scenerii będzie zwiększany
|
double Global::fFpsMax = 65.0; // górna granica FPS, przy której promień scenerii będzie zwiększany
|
||||||
double Global::fFpsRadiusMax = 3000.0; // maksymalny promień renderowania
|
bool Global::FullPhysics { true }; // full calculations performed for each simulation step
|
||||||
int Global::iFpsRadiusMax = 225; // maksymalny promień renderowania
|
|
||||||
double Global::fRadiusFactor = 1.1; // współczynnik jednorazowej zmiany promienia scenerii
|
|
||||||
|
|
||||||
// parametry testowe (do testowania scenerii i obiektów)
|
// parametry testowe (do testowania scenerii i obiektów)
|
||||||
bool Global::bWireFrame = false;
|
bool Global::bWireFrame = false;
|
||||||
bool Global::bSoundEnabled = true;
|
bool Global::bSoundEnabled = true;
|
||||||
int Global::iWriteLogEnabled = 3; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów
|
int Global::iWriteLogEnabled = 3; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów
|
||||||
bool Global::MultipleLogs{ false };
|
bool Global::MultipleLogs{ false };
|
||||||
bool Global::bManageNodes = true;
|
|
||||||
bool Global::bDecompressDDS = false; // czy programowa dekompresja DDS
|
|
||||||
|
|
||||||
// parametry do kalibracji
|
// parametry do kalibracji
|
||||||
// kolejno współczynniki dla potęg 0, 1, 2, 3 wartości odczytanej z urządzenia
|
// kolejno współczynniki dla potęg 0, 1, 2, 3 wartości odczytanej z urządzenia
|
||||||
@@ -178,10 +164,8 @@ int Global::iPoKeysPWM[7] = {0, 1, 2, 3, 4, 5, 6};
|
|||||||
// bool Global::bTimeChange=false; //Ra: ZiomalCl wyłączył starą wersję nocy
|
// bool Global::bTimeChange=false; //Ra: ZiomalCl wyłączył starą wersję nocy
|
||||||
// bool Global::bRenderAlpha=true; //Ra: wywaliłam tę flagę
|
// bool Global::bRenderAlpha=true; //Ra: wywaliłam tę flagę
|
||||||
bool Global::bnewAirCouplers = true;
|
bool Global::bnewAirCouplers = true;
|
||||||
bool Global::bDoubleAmbient = false; // podwójna jasność ambient
|
|
||||||
double Global::fTimeSpeed = 1.0; // przyspieszenie czasu, zmienna do testów
|
double Global::fTimeSpeed = 1.0; // przyspieszenie czasu, zmienna do testów
|
||||||
bool Global::bHideConsole = false; // hunter-271211: ukrywanie konsoli
|
bool Global::bHideConsole = false; // hunter-271211: ukrywanie konsoli
|
||||||
int Global::iBpp = 32; // chyba już nie używa się kart, na których 16bpp coś poprawi
|
|
||||||
//randomizacja
|
//randomizacja
|
||||||
std::mt19937 Global::random_engine = std::mt19937(std::time(NULL));
|
std::mt19937 Global::random_engine = std::mt19937(std::time(NULL));
|
||||||
// maciek001: konfiguracja wstępna portu COM
|
// maciek001: konfiguracja wstępna portu COM
|
||||||
@@ -279,13 +263,6 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser.getTokens(1, false);
|
Parser.getTokens(1, false);
|
||||||
Parser >> Global::fDistanceFactor;
|
Parser >> Global::fDistanceFactor;
|
||||||
}
|
}
|
||||||
else if (token == "bpp")
|
|
||||||
{
|
|
||||||
|
|
||||||
Parser.getTokens();
|
|
||||||
Parser >> token;
|
|
||||||
Global::iBpp = (token == "32" ? 32 : 16);
|
|
||||||
}
|
|
||||||
else if (token == "fullscreen")
|
else if (token == "fullscreen")
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -335,11 +312,11 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> WriteLogFlag;
|
Parser >> WriteLogFlag;
|
||||||
}
|
}
|
||||||
else if (token == "physicsdeactivation")
|
else if (token == "fullphysics")
|
||||||
{ // McZapkie-291103 - usypianie fizyki
|
{ // McZapkie-291103 - usypianie fizyki
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> PhysicActivationFlag;
|
Parser >> Global::FullPhysics;
|
||||||
}
|
}
|
||||||
else if (token == "debuglog")
|
else if (token == "debuglog")
|
||||||
{
|
{
|
||||||
@@ -412,18 +389,6 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser >> token;
|
Parser >> token;
|
||||||
Global::asSky = (token == "yes" ? "1" : "0");
|
Global::asSky = (token == "yes" ? "1" : "0");
|
||||||
}
|
}
|
||||||
else if (token == "managenodes")
|
|
||||||
{
|
|
||||||
|
|
||||||
Parser.getTokens();
|
|
||||||
Parser >> Global::bManageNodes;
|
|
||||||
}
|
|
||||||
else if (token == "decompressdds")
|
|
||||||
{
|
|
||||||
|
|
||||||
Parser.getTokens();
|
|
||||||
Parser >> Global::bDecompressDDS;
|
|
||||||
}
|
|
||||||
else if (token == "defaultext")
|
else if (token == "defaultext")
|
||||||
{
|
{
|
||||||
// ShaXbee - domyslne rozszerzenie tekstur
|
// ShaXbee - domyslne rozszerzenie tekstur
|
||||||
@@ -447,30 +412,6 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> Global::bnewAirCouplers;
|
Parser >> Global::bnewAirCouplers;
|
||||||
}
|
}
|
||||||
else if (token == "defaultfiltering")
|
|
||||||
{
|
|
||||||
|
|
||||||
Parser.getTokens(1, false);
|
|
||||||
Parser >> Global::iDefaultFiltering;
|
|
||||||
}
|
|
||||||
else if (token == "ballastfiltering")
|
|
||||||
{
|
|
||||||
|
|
||||||
Parser.getTokens(1, false);
|
|
||||||
Parser >> Global::iBallastFiltering;
|
|
||||||
}
|
|
||||||
else if (token == "railprofiltering")
|
|
||||||
{
|
|
||||||
|
|
||||||
Parser.getTokens(1, false);
|
|
||||||
Parser >> Global::iRailProFiltering;
|
|
||||||
}
|
|
||||||
else if (token == "dynamicfiltering")
|
|
||||||
{
|
|
||||||
|
|
||||||
Parser.getTokens(1, false);
|
|
||||||
Parser >> Global::iDynamicFiltering;
|
|
||||||
}
|
|
||||||
else if( token == "anisotropicfiltering" ) {
|
else if( token == "anisotropicfiltering" ) {
|
||||||
|
|
||||||
Parser.getTokens( 1, false );
|
Parser.getTokens( 1, false );
|
||||||
@@ -510,12 +451,6 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
else if (size <= 8192) { Global::iMaxTextureSize = 8192; }
|
else if (size <= 8192) { Global::iMaxTextureSize = 8192; }
|
||||||
else { Global::iMaxTextureSize = 16384; }
|
else { Global::iMaxTextureSize = 16384; }
|
||||||
}
|
}
|
||||||
else if (token == "doubleambient")
|
|
||||||
{
|
|
||||||
// podwójna jasność ambient
|
|
||||||
Parser.getTokens();
|
|
||||||
Parser >> Global::bDoubleAmbient;
|
|
||||||
}
|
|
||||||
else if (token == "movelight")
|
else if (token == "movelight")
|
||||||
{
|
{
|
||||||
// numer dnia w roku albo -1
|
// numer dnia w roku albo -1
|
||||||
@@ -652,12 +587,6 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser.getTokens(1, false);
|
Parser.getTokens(1, false);
|
||||||
Parser >> Global::iSlowMotionMask;
|
Parser >> Global::iSlowMotionMask;
|
||||||
}
|
}
|
||||||
else if (token == "modifytga")
|
|
||||||
{
|
|
||||||
// czy korygować pliki TGA dla szybszego wczytywania
|
|
||||||
Parser.getTokens(1, false);
|
|
||||||
Parser >> Global::iModifyTGA;
|
|
||||||
}
|
|
||||||
else if (token == "hideconsole")
|
else if (token == "hideconsole")
|
||||||
{
|
{
|
||||||
// hunter-271211: ukrywanie konsoli
|
// hunter-271211: ukrywanie konsoli
|
||||||
@@ -682,12 +611,6 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser.getTokens(1, false);
|
Parser.getTokens(1, false);
|
||||||
Parser >> Global::fFpsDeviation;
|
Parser >> Global::fFpsDeviation;
|
||||||
}
|
}
|
||||||
else if (token == "fpsradiusmax")
|
|
||||||
{
|
|
||||||
// maksymalny promień renderowania
|
|
||||||
Parser.getTokens(1, false);
|
|
||||||
Parser >> Global::fFpsRadiusMax;
|
|
||||||
}
|
|
||||||
else if (token == "calibratein")
|
else if (token == "calibratein")
|
||||||
{
|
{
|
||||||
// parametry kalibracji wejść
|
// parametry kalibracji wejść
|
||||||
@@ -828,14 +751,6 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Global::UITextColor = Global::UITextColor / 255.0f;
|
Global::UITextColor = Global::UITextColor / 255.0f;
|
||||||
Global::UITextColor.w = 1.0f;
|
Global::UITextColor.w = 1.0f;
|
||||||
}
|
}
|
||||||
else if (token == "background")
|
|
||||||
{
|
|
||||||
|
|
||||||
Parser.getTokens(3, false);
|
|
||||||
Parser >> Global::Background[0] // r
|
|
||||||
>> Global::Background[1] // g
|
|
||||||
>> Global::Background[2]; // b
|
|
||||||
}
|
|
||||||
else if( token == "input.gamepad" ) {
|
else if( token == "input.gamepad" ) {
|
||||||
// czy grupować eventy o tych samych nazwach
|
// czy grupować eventy o tych samych nazwach
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
|
|||||||
52
Globals.h
52
Globals.h
@@ -130,25 +130,13 @@ class TTranscript
|
|||||||
float fHide; // czas ukrycia/usunięcia
|
float fHide; // czas ukrycia/usunięcia
|
||||||
std::string asText; // tekst gotowy do wyświetlenia (usunięte znaczniki czasu)
|
std::string asText; // tekst gotowy do wyświetlenia (usunięte znaczniki czasu)
|
||||||
bool bItalic; // czy kursywa (dźwięk nieistotny dla prowadzącego)
|
bool bItalic; // czy kursywa (dźwięk nieistotny dla prowadzącego)
|
||||||
/*
|
|
||||||
int iNext; // następna używana linijka, żeby nie przestawiać fizycznie tabeli
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
#define MAX_TRANSCRIPTS 30
|
|
||||||
*/
|
|
||||||
class TTranscripts
|
class TTranscripts
|
||||||
{ // klasa obsługująca napisy do dźwięków
|
{ // klasa obsługująca napisy do dźwięków
|
||||||
/*
|
|
||||||
TTranscript aLines[MAX_TRANSCRIPTS]; // pozycje na napisy do wyświetlenia
|
|
||||||
*/
|
|
||||||
public:
|
public:
|
||||||
std::deque<TTranscript> aLines;
|
std::deque<TTranscript> aLines;
|
||||||
/*
|
|
||||||
int iCount; // liczba zajętych pozycji
|
|
||||||
int iStart; // pierwsza istotna pozycja w tabeli, żeby sortować przestawiając numerki
|
|
||||||
*/
|
|
||||||
private:
|
private:
|
||||||
float fRefreshTime;
|
float fRefreshTime;
|
||||||
|
|
||||||
@@ -166,7 +154,6 @@ class Global
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
// double Global::tSinceStart;
|
|
||||||
static int Keys[MaxKeys];
|
static int Keys[MaxKeys];
|
||||||
static bool RealisticControlMode; // controls ability to steer the vehicle from outside views
|
static bool RealisticControlMode; // controls ability to steer the vehicle from outside views
|
||||||
static Math3D::vector3 pCameraPosition; // pozycja kamery w świecie
|
static Math3D::vector3 pCameraPosition; // pozycja kamery w świecie
|
||||||
@@ -179,23 +166,17 @@ class Global
|
|||||||
static int iWindowWidth;
|
static int iWindowWidth;
|
||||||
static int iWindowHeight;
|
static int iWindowHeight;
|
||||||
static float fDistanceFactor;
|
static float fDistanceFactor;
|
||||||
static int iBpp;
|
|
||||||
static bool bFullScreen;
|
static bool bFullScreen;
|
||||||
static bool VSync;
|
static bool VSync;
|
||||||
static bool bFreeFly;
|
static bool bFreeFly;
|
||||||
// float RunningTime;
|
|
||||||
static bool bWireFrame;
|
static bool bWireFrame;
|
||||||
static bool bSoundEnabled;
|
static bool bSoundEnabled;
|
||||||
// McZapkie-131202
|
// McZapkie-131202
|
||||||
// static bool bRenderAlpha;
|
|
||||||
static bool bAdjustScreenFreq;
|
static bool bAdjustScreenFreq;
|
||||||
static bool bEnableTraction;
|
static bool bEnableTraction;
|
||||||
static bool bLoadTraction;
|
static bool bLoadTraction;
|
||||||
static float fFriction;
|
static float fFriction;
|
||||||
static bool bLiveTraction;
|
static bool bLiveTraction;
|
||||||
static bool bManageNodes;
|
|
||||||
static bool bDecompressDDS;
|
|
||||||
// bool WFreeFly;
|
|
||||||
static float fMouseXScale;
|
static float fMouseXScale;
|
||||||
static float fMouseYScale;
|
static float fMouseYScale;
|
||||||
static double fFogStart;
|
static double fFogStart;
|
||||||
@@ -217,11 +198,8 @@ class Global
|
|||||||
static int iWriteLogEnabled; // maska bitowa: 1-zapis do pliku, 2-okienko
|
static int iWriteLogEnabled; // maska bitowa: 1-zapis do pliku, 2-okienko
|
||||||
static bool MultipleLogs;
|
static bool MultipleLogs;
|
||||||
// McZapkie-221002: definicja swiatla dziennego
|
// McZapkie-221002: definicja swiatla dziennego
|
||||||
static float Background[3];
|
|
||||||
static GLfloat AtmoColor[];
|
|
||||||
static GLfloat FogColor[];
|
static GLfloat FogColor[];
|
||||||
static float Overcast;
|
static float Overcast;
|
||||||
// static bool bTimeChange;
|
|
||||||
|
|
||||||
// TODO: put these things in the renderer
|
// TODO: put these things in the renderer
|
||||||
static float BaseDrawRange;
|
static float BaseDrawRange;
|
||||||
@@ -235,18 +213,22 @@ class Global
|
|||||||
float depth;
|
float depth;
|
||||||
float distance;
|
float distance;
|
||||||
} shadowtune;
|
} shadowtune;
|
||||||
|
static bool bUseVBO; // czy jest VBO w karcie graficznej
|
||||||
|
static float AnisotropicFiltering; // requested level of anisotropic filtering. TODO: move it to renderer object
|
||||||
|
static int ScreenWidth; // current window dimensions. TODO: move it to renderer
|
||||||
|
static int ScreenHeight;
|
||||||
|
static float ZoomFactor; // determines current camera zoom level. TODO: move it to the renderer
|
||||||
|
static float FieldOfView; // vertical field of view for the camera. TODO: move it to the renderer
|
||||||
|
static GLint iMaxTextureSize; // maksymalny rozmiar tekstury
|
||||||
|
static int iMultisampling; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px
|
||||||
|
|
||||||
|
static bool FullPhysics; // full calculations performed for each simulation step
|
||||||
static int iSlowMotion;
|
static int iSlowMotion;
|
||||||
static TDynamicObject *changeDynObj;
|
static TDynamicObject *changeDynObj;
|
||||||
static double ABuDebug;
|
static double ABuDebug;
|
||||||
static std::string asSky;
|
static std::string asSky;
|
||||||
static bool bnewAirCouplers;
|
static bool bnewAirCouplers;
|
||||||
// Ra: nowe zmienne globalne
|
// Ra: nowe zmienne globalne
|
||||||
static float AnisotropicFiltering; // requested level of anisotropic filtering. TODO: move it to renderer object
|
|
||||||
static int iDefaultFiltering; // domyślne rozmywanie tekstur TGA
|
|
||||||
static int iBallastFiltering; // domyślne rozmywanie tekstury podsypki
|
|
||||||
static int iRailProFiltering; // domyślne rozmywanie tekstury szyn
|
|
||||||
static int iDynamicFiltering; // domyślne rozmywanie tekstur pojazdów
|
|
||||||
static std::string LastGLError;
|
static std::string LastGLError;
|
||||||
static int iFeedbackMode; // tryb pracy informacji zwrotnej
|
static int iFeedbackMode; // tryb pracy informacji zwrotnej
|
||||||
static int iFeedbackPort; // dodatkowy adres dla informacji zwrotnych
|
static int iFeedbackPort; // dodatkowy adres dla informacji zwrotnych
|
||||||
@@ -257,18 +239,12 @@ class Global
|
|||||||
static GLFWwindow *window;
|
static GLFWwindow *window;
|
||||||
static bool shiftState; //m7todo: brzydko
|
static bool shiftState; //m7todo: brzydko
|
||||||
static bool ctrlState;
|
static bool ctrlState;
|
||||||
static int ScreenWidth; // current window dimensions. TODO: move it to renderer
|
|
||||||
static int ScreenHeight;
|
|
||||||
static float ZoomFactor; // determines current camera zoom level. TODO: move it to the renderer
|
|
||||||
static float FieldOfView; // vertical field of view for the camera. TODO: move it to the renderer
|
|
||||||
static int iCameraLast;
|
static int iCameraLast;
|
||||||
static std::string asVersion; // z opisem
|
static std::string asVersion; // z opisem
|
||||||
static GLint iMaxTextureSize; // maksymalny rozmiar tekstury
|
|
||||||
static bool ControlPicking; // indicates controls pick mode is active
|
static bool ControlPicking; // indicates controls pick mode is active
|
||||||
static bool InputMouse; // whether control pick mode can be activated
|
static bool InputMouse; // whether control pick mode can be activated
|
||||||
static int iTextMode; // tryb pracy wyświetlacza tekstowego
|
static int iTextMode; // tryb pracy wyświetlacza tekstowego
|
||||||
static int iScreenMode[12]; // numer ekranu wyświetlacza tekstowego
|
static int iScreenMode[12]; // numer ekranu wyświetlacza tekstowego
|
||||||
static bool bDoubleAmbient; // podwójna jasność ambient
|
|
||||||
static double fMoveLight; // numer dnia w roku albo -1
|
static double fMoveLight; // numer dnia w roku albo -1
|
||||||
static bool FakeLight; // toggle between fixed and dynamic daylight
|
static bool FakeLight; // toggle between fixed and dynamic daylight
|
||||||
static bool bSmoothTraction; // wygładzanie drutów
|
static bool bSmoothTraction; // wygładzanie drutów
|
||||||
@@ -279,19 +255,14 @@ class Global
|
|||||||
static double fLatitudeDeg; // szerokość geograficzna
|
static double fLatitudeDeg; // szerokość geograficzna
|
||||||
static std::string szTexturesTGA; // lista tekstur od TGA
|
static std::string szTexturesTGA; // lista tekstur od TGA
|
||||||
static std::string szTexturesDDS; // lista tekstur od DDS
|
static std::string szTexturesDDS; // lista tekstur od DDS
|
||||||
static int iMultisampling; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px
|
|
||||||
static bool DLFont; // switch indicating presence of basic font
|
static bool DLFont; // switch indicating presence of basic font
|
||||||
static bool bGlutFont; // tekst generowany przez GLUT
|
static bool bGlutFont; // tekst generowany przez GLUT
|
||||||
static int iKeyLast; // ostatnio naciśnięty klawisz w celu logowania
|
|
||||||
static int iPause; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie
|
static int iPause; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie
|
||||||
static bool bActive;
|
static bool bActive;
|
||||||
|
|
||||||
static int iConvertModels; // tworzenie plików binarnych
|
static int iConvertModels; // tworzenie plików binarnych
|
||||||
static int iErorrCounter; // licznik sprawdzań do śledzenia błędów OpenGL
|
|
||||||
static bool bInactivePause; // automatyczna pauza, gdy okno nieaktywne
|
static bool bInactivePause; // automatyczna pauza, gdy okno nieaktywne
|
||||||
static int iTextures; // licznik użytych tekstur
|
|
||||||
static int iSlowMotionMask; // maska wyłączanych właściwości
|
static int iSlowMotionMask; // maska wyłączanych właściwości
|
||||||
static int iModifyTGA; // czy korygować pliki TGA dla szybszego wczytywania
|
|
||||||
static bool bHideConsole; // hunter-271211: ukrywanie konsoli
|
static bool bHideConsole; // hunter-271211: ukrywanie konsoli
|
||||||
|
|
||||||
static TWorld *pWorld; // wskaźnik na świat do usuwania pojazdów
|
static TWorld *pWorld; // wskaźnik na świat do usuwania pojazdów
|
||||||
@@ -303,9 +274,6 @@ class Global
|
|||||||
static double fFpsDeviation; // odchylenie standardowe FPS
|
static double fFpsDeviation; // odchylenie standardowe FPS
|
||||||
static double fFpsMin; // dolna granica FPS, przy której promień scenerii będzie zmniejszany
|
static double fFpsMin; // dolna granica FPS, przy której promień scenerii będzie zmniejszany
|
||||||
static double fFpsMax; // górna granica FPS, przy której promień scenerii będzie zwiększany
|
static double fFpsMax; // górna granica FPS, przy której promień scenerii będzie zwiększany
|
||||||
static double fFpsRadiusMax; // maksymalny promień renderowania
|
|
||||||
static int iFpsRadiusMax; // maksymalny promień renderowania w rozmiarze tabeli sektorów
|
|
||||||
static double fRadiusFactor; // współczynnik zmiany promienia
|
|
||||||
static TCamera *pCamera; // parametry kamery
|
static TCamera *pCamera; // parametry kamery
|
||||||
static TDynamicObject *pUserDynamic; // pojazd użytkownika, renderowany bez trzęsienia
|
static TDynamicObject *pUserDynamic; // pojazd użytkownika, renderowany bez trzęsienia
|
||||||
static double fCalibrateIn[6][6]; // parametry kalibracyjne wejść z pulpitu
|
static double fCalibrateIn[6][6]; // parametry kalibracyjne wejść z pulpitu
|
||||||
|
|||||||
79
Ground.cpp
79
Ground.cpp
@@ -1935,7 +1935,7 @@ bool TGround::Init(std::string File)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ErrorLog("Scene parsing error in file \"" + parser.Name() + "\" (line " + std::to_string( parser.Line() ) + "), unexpected token \"" + token + "\"");
|
ErrorLog("Bad node: node parsing error, encountered in file \"" + parser.Name() + "\" (line " + std::to_string( parser.Line() - 1 ) + ")");
|
||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2033,10 +2033,13 @@ bool TGround::Init(std::string File)
|
|||||||
{ // Ra: ustawienie parametrów OpenGL przeniesione do FirstInit
|
{ // Ra: ustawienie parametrów OpenGL przeniesione do FirstInit
|
||||||
WriteLog("Scenery atmo definition");
|
WriteLog("Scenery atmo definition");
|
||||||
parser.getTokens(3);
|
parser.getTokens(3);
|
||||||
|
/*
|
||||||
|
// disabled, no longer used
|
||||||
parser
|
parser
|
||||||
>> Global::AtmoColor[0]
|
>> Global::AtmoColor[0]
|
||||||
>> Global::AtmoColor[1]
|
>> Global::AtmoColor[1]
|
||||||
>> Global::AtmoColor[2];
|
>> Global::AtmoColor[2];
|
||||||
|
*/
|
||||||
parser.getTokens(2);
|
parser.getTokens(2);
|
||||||
parser
|
parser
|
||||||
>> Global::fFogStart
|
>> Global::fFogStart
|
||||||
@@ -2186,11 +2189,11 @@ bool TGround::Init(std::string File)
|
|||||||
{ // możliwość przedefiniowania parametrów w scenerii
|
{ // możliwość przedefiniowania parametrów w scenerii
|
||||||
Global::ConfigParse(parser); // parsowanie dodatkowych ustawień
|
Global::ConfigParse(parser); // parsowanie dodatkowych ustawień
|
||||||
}
|
}
|
||||||
else if (str != "")
|
else if (str != "") {
|
||||||
{ // pomijanie od nierozpoznanej komendy do jej zakończenia
|
// pomijanie od nierozpoznanej komendy do jej zakończenia
|
||||||
if ((token.length() > 2) && (atof(token.c_str()) == 0.0))
|
if ((token.length() > 2) && (atof(token.c_str()) == 0.0)) {
|
||||||
{ // jeśli nie liczba, to spróbować pominąć komendę
|
// jeśli nie liczba, to spróbować pominąć komendę
|
||||||
WriteLog("Unrecognized command: " + str);
|
WriteLog( "Unrecognized command: \"" + str + "\" encountered in file \"" + parser.Name() + "\" (line " + std::to_string( parser.Line() - 1 ) + ")" );
|
||||||
str = "end" + str;
|
str = "end" + str;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -2199,8 +2202,10 @@ bool TGround::Init(std::string File)
|
|||||||
parser >> token;
|
parser >> token;
|
||||||
} while ((token != "") && (token.compare(str.c_str()) != 0));
|
} while ((token != "") && (token.compare(str.c_str()) != 0));
|
||||||
}
|
}
|
||||||
else // jak liczba to na pewno błąd
|
else {
|
||||||
Error("Unrecognized command: " + str);
|
// jak liczba to na pewno błąd
|
||||||
|
ErrorLog( "Unrecognized command: \"" + str + "\" encountered in file \"" + parser.Name() + "\" (line " + std::to_string( parser.Line() - 1 ) + ")" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
token = "";
|
token = "";
|
||||||
@@ -3390,46 +3395,76 @@ bool TGround::CheckQuery()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tp_WhoIs: // pobranie nazwy pociągu do komórki pamięci
|
case tp_WhoIs: {
|
||||||
if (tmpEvent->iFlags & update_load)
|
// pobranie nazwy pociągu do komórki pamięci
|
||||||
{ // jeśli pytanie o ładunek
|
if (tmpEvent->iFlags & update_load) {
|
||||||
if (tmpEvent->iFlags & update_memadd) // jeśli typ pojazdu
|
// jeśli pytanie o ładunek
|
||||||
|
if( tmpEvent->iFlags & update_memadd ) {
|
||||||
|
// jeśli typ pojazdu
|
||||||
|
// TODO: define and recognize individual request types
|
||||||
|
auto const owner = (
|
||||||
|
( ( tmpEvent->Activator->Mechanik != nullptr ) && ( tmpEvent->Activator->Mechanik->Primary() ) ) ?
|
||||||
|
tmpEvent->Activator->Mechanik :
|
||||||
|
tmpEvent->Activator->ctOwner );
|
||||||
|
auto const consistbrakelevel = (
|
||||||
|
owner != nullptr ?
|
||||||
|
owner->fReady :
|
||||||
|
-1.0 );
|
||||||
|
|
||||||
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
||||||
tmpEvent->Activator->MoverParameters->TypeName, // typ pojazdu
|
tmpEvent->Activator->MoverParameters->TypeName, // typ pojazdu
|
||||||
|
consistbrakelevel,
|
||||||
0, // na razie nic
|
0, // na razie nic
|
||||||
0, // na razie nic
|
tmpEvent->iFlags & ( update_memstring | update_memval1 | update_memval2 ) );
|
||||||
tmpEvent->iFlags &
|
|
||||||
(update_memstring | update_memval1 | update_memval2));
|
WriteLog(
|
||||||
else // jeśli parametry ładunku
|
"whois request (" + to_string( tmpEvent->iFlags ) + ") "
|
||||||
|
+ "[name: " + tmpEvent->Activator->MoverParameters->TypeName + "], "
|
||||||
|
+ "[consist brake level: " + to_string( consistbrakelevel, 2 ) + "], "
|
||||||
|
+ "[]" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// jeśli parametry ładunku
|
||||||
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
||||||
tmpEvent->Activator->MoverParameters->LoadType, // nazwa ładunku
|
tmpEvent->Activator->MoverParameters->LoadType, // nazwa ładunku
|
||||||
tmpEvent->Activator->MoverParameters->Load, // aktualna ilość
|
tmpEvent->Activator->MoverParameters->Load, // aktualna ilość
|
||||||
tmpEvent->Activator->MoverParameters->MaxLoad, // maksymalna ilość
|
tmpEvent->Activator->MoverParameters->MaxLoad, // maksymalna ilość
|
||||||
tmpEvent->iFlags &
|
tmpEvent->iFlags & ( update_memstring | update_memval1 | update_memval2 ) );
|
||||||
(update_memstring | update_memval1 | update_memval2));
|
|
||||||
|
WriteLog(
|
||||||
|
"whois request (" + to_string( tmpEvent->iFlags ) + ") "
|
||||||
|
+ "[load type: " + tmpEvent->Activator->MoverParameters->LoadType + "], "
|
||||||
|
+ "[current load: " + to_string( tmpEvent->Activator->MoverParameters->Load, 2 ) + "], "
|
||||||
|
+ "[max load: " + to_string( tmpEvent->Activator->MoverParameters->MaxLoad, 2 ) + "]" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (tmpEvent->iFlags & update_memadd)
|
else if (tmpEvent->iFlags & update_memadd)
|
||||||
{ // jeśli miejsce docelowe pojazdu
|
{ // jeśli miejsce docelowe pojazdu
|
||||||
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
||||||
tmpEvent->Activator->asDestination, // adres docelowy
|
tmpEvent->Activator->asDestination, // adres docelowy
|
||||||
tmpEvent->Activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny)
|
tmpEvent->Activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny)
|
||||||
tmpEvent->Activator->MoverParameters ->Power, // moc pojazdu silnikowego: 0 dla wagonu
|
tmpEvent->Activator->MoverParameters->Power, // moc pojazdu silnikowego: 0 dla wagonu
|
||||||
tmpEvent->iFlags & (update_memstring | update_memval1 | update_memval2));
|
tmpEvent->iFlags & (update_memstring | update_memval1 | update_memval2));
|
||||||
|
|
||||||
|
WriteLog(
|
||||||
|
"whois request (" + to_string( tmpEvent->iFlags ) + ") "
|
||||||
|
+ "[destination: " + tmpEvent->Activator->asDestination + "], "
|
||||||
|
+ "[direction: " + to_string( tmpEvent->Activator->DirectionGet() ) + "], "
|
||||||
|
+ "[engine power: " + to_string( tmpEvent->Activator->MoverParameters->Power, 2 ) + "]" );
|
||||||
}
|
}
|
||||||
else if (tmpEvent->Activator->Mechanik)
|
else if (tmpEvent->Activator->Mechanik)
|
||||||
if (tmpEvent->Activator->Mechanik->Primary())
|
if (tmpEvent->Activator->Mechanik->Primary())
|
||||||
{ // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera!
|
{ // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera!
|
||||||
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
||||||
tmpEvent->Activator->Mechanik->TrainName(),
|
tmpEvent->Activator->Mechanik->TrainName(),
|
||||||
tmpEvent->Activator->Mechanik->StationCount() -
|
tmpEvent->Activator->Mechanik->StationCount() - tmpEvent->Activator->Mechanik->StationIndex(), // ile przystanków do końca
|
||||||
tmpEvent->Activator->Mechanik
|
|
||||||
->StationIndex(), // ile przystanków do końca
|
|
||||||
tmpEvent->Activator->Mechanik->IsStop() ? 1 :
|
tmpEvent->Activator->Mechanik->IsStop() ? 1 :
|
||||||
0, // 1, gdy ma tu zatrzymanie
|
0, // 1, gdy ma tu zatrzymanie
|
||||||
tmpEvent->iFlags);
|
tmpEvent->iFlags);
|
||||||
WriteLog("Train detected: " + tmpEvent->Activator->Mechanik->TrainName());
|
WriteLog("Train detected: " + tmpEvent->Activator->Mechanik->TrainName());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case tp_LogValues: // zapisanie zawartości komórki pamięci do logu
|
case tp_LogValues: // zapisanie zawartości komórki pamięci do logu
|
||||||
if (tmpEvent->Params[9].asMemCell) // jeśli była podana nazwa komórki
|
if (tmpEvent->Params[9].asMemCell) // jeśli była podana nazwa komórki
|
||||||
WriteLog("Memcell \"" + tmpEvent->asNodeName + "\": " +
|
WriteLog("Memcell \"" + tmpEvent->asNodeName + "\": " +
|
||||||
|
|||||||
@@ -191,8 +191,6 @@ static int const sound_relay = 16;
|
|||||||
static int const sound_manyrelay = 32;
|
static int const sound_manyrelay = 32;
|
||||||
static int const sound_brakeacc = 64;
|
static int const sound_brakeacc = 64;
|
||||||
|
|
||||||
static bool PhysicActivationFlag = false;
|
|
||||||
|
|
||||||
//szczególne typy pojazdów (inna obsługa) dla zmiennej TrainType
|
//szczególne typy pojazdów (inna obsługa) dla zmiennej TrainType
|
||||||
//zamienione na flagi bitowe, aby szybko wybierać grupę (np. EZT+SZT)
|
//zamienione na flagi bitowe, aby szybko wybierać grupę (np. EZT+SZT)
|
||||||
static int const dt_Default = 0;
|
static int const dt_Default = 0;
|
||||||
@@ -813,7 +811,6 @@ public:
|
|||||||
voltage
|
voltage
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
int ScanCounter = 0; /*pomocnicze do skanowania sprzegow*/
|
|
||||||
bool EventFlag = false; /*!o true jesli cos nietypowego sie wydarzy*/
|
bool EventFlag = false; /*!o true jesli cos nietypowego sie wydarzy*/
|
||||||
int SoundFlag = 0; /*!o patrz stale sound_ */
|
int SoundFlag = 0; /*!o patrz stale sound_ */
|
||||||
double DistCounter = 0.0; /*! licznik kilometrow */
|
double DistCounter = 0.0; /*! licznik kilometrow */
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
|
|||||||
coupler.Connected = ConnectTo; // tak podpiąć (do siebie) zawsze można, najwyżej będzie wirtualny
|
coupler.Connected = ConnectTo; // tak podpiąć (do siebie) zawsze można, najwyżej będzie wirtualny
|
||||||
CouplerDist( ConnectNo ); // przeliczenie odległości pomiędzy sprzęgami
|
CouplerDist( ConnectNo ); // przeliczenie odległości pomiędzy sprzęgami
|
||||||
|
|
||||||
if (CouplingType == ctrain_virtual)
|
if (CouplingType == coupling::faux)
|
||||||
return false; // wirtualny więcej nic nie robi
|
return false; // wirtualny więcej nic nie robi
|
||||||
|
|
||||||
auto &othercoupler = ConnectTo->Couplers[ coupler.ConnectedNr ];
|
auto &othercoupler = ConnectTo->Couplers[ coupler.ConnectedNr ];
|
||||||
@@ -554,21 +554,29 @@ bool TMoverParameters::Dettach(int ConnectNo)
|
|||||||
return false; // jeszcze nie rozłączony
|
return false; // jeszcze nie rozłączony
|
||||||
};
|
};
|
||||||
|
|
||||||
void TMoverParameters::SetCoupleDist()
|
// przeliczenie odległości sprzęgów
|
||||||
{ // przeliczenie odległości sprzęgów
|
void TMoverParameters::SetCoupleDist() {
|
||||||
if (Couplers[0].Connected)
|
/*
|
||||||
{
|
double const MaxDist = 100.0; // 2x average max proximity distance. TODO: rearrange ito something more elegant
|
||||||
CouplerDist(0);
|
*/
|
||||||
if (CategoryFlag & 2)
|
for( int coupleridx = 0; coupleridx <= 1; ++coupleridx ) {
|
||||||
{ // Ra: dla samochodów zderzanie kul to za mało
|
|
||||||
|
if( Couplers[ coupleridx ].Connected == nullptr ) { continue; }
|
||||||
|
|
||||||
|
CouplerDist( coupleridx );
|
||||||
|
if( CategoryFlag & 2 ) {
|
||||||
|
// Ra: dla samochodów zderzanie kul to za mało
|
||||||
|
// NOTE: whatever calculation was supposed to be here, ain't
|
||||||
}
|
}
|
||||||
}
|
/*
|
||||||
if (Couplers[1].Connected)
|
if( ( Couplers[ coupleridx ].CouplingFlag == coupling::faux )
|
||||||
{
|
&& ( Couplers[ coupleridx ].CoupleDist > MaxDist ) ) {
|
||||||
CouplerDist(1);
|
// zerwij kontrolnie wirtualny sprzeg
|
||||||
if (CategoryFlag & 2)
|
// Connected.Couplers[CNext].Connected:=nil; //Ra: ten podłączony niekoniecznie jest wirtualny
|
||||||
{ // Ra: dla samochodów zderzanie kul to za mało
|
Couplers[ coupleridx ].Connected = nullptr;
|
||||||
|
Couplers[ coupleridx ].ConnectedNr = 2;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3724,14 +3732,12 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer)
|
|||||||
else {
|
else {
|
||||||
Voltage = 0;
|
Voltage = 0;
|
||||||
}
|
}
|
||||||
//if (Mains && /*(abs(CabNo) < 2) &&*/ (
|
|
||||||
// EngineType == ElectricInductionMotor)) // potem ulepszyc! pantogtrafy!
|
|
||||||
// Voltage = RunningTraction.TractionVoltage;
|
|
||||||
|
|
||||||
if (Power > 0)
|
if (Power > 0)
|
||||||
FTrain = TractionForce(dt);
|
FTrain = TractionForce(dt);
|
||||||
else
|
else
|
||||||
FTrain = 0;
|
FTrain = 0;
|
||||||
|
|
||||||
Fb = BrakeForce(RunningTrack);
|
Fb = BrakeForce(RunningTrack);
|
||||||
Fwheels = FTrain - Fb * Sign(V);
|
Fwheels = FTrain - Fb * Sign(V);
|
||||||
if( ( Vel > 0.001 ) // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test
|
if( ( Vel > 0.001 ) // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test
|
||||||
@@ -3784,9 +3790,6 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer)
|
|||||||
|
|
||||||
// McZapkie-031103: sprawdzanie czy warto liczyc fizyke i inne updaty
|
// McZapkie-031103: sprawdzanie czy warto liczyc fizyke i inne updaty
|
||||||
// ABu 300105: cos tu mieszalem , dziala teraz troche lepiej, wiec zostawiam
|
// ABu 300105: cos tu mieszalem , dziala teraz troche lepiej, wiec zostawiam
|
||||||
// zakomentowalem PhysicActivationFlag bo cos nie dzialalo i fizyka byla liczona zawsze.
|
|
||||||
// if (PhysicActivationFlag)
|
|
||||||
//{
|
|
||||||
if ((CabNo == 0) && (Vel < 0.0001) && (abs(AccS) < 0.0001) && (TrainType != dt_EZT))
|
if ((CabNo == 0) && (Vel < 0.0001) && (abs(AccS) < 0.0001) && (TrainType != dt_EZT))
|
||||||
{
|
{
|
||||||
if (!PhysicActivation)
|
if (!PhysicActivation)
|
||||||
@@ -3805,7 +3808,6 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
PhysicActivation = true;
|
PhysicActivation = true;
|
||||||
//};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double TMoverParameters::BrakeForceR(double ratio, double velocity)
|
double TMoverParameters::BrakeForceR(double ratio, double velocity)
|
||||||
@@ -3964,8 +3966,8 @@ double TMoverParameters::Adhesive(double staticfriction)
|
|||||||
}
|
}
|
||||||
// WriteLog(FloatToStr(adhesive)); // tutaj jest na poziomie 0.2 - 0.3
|
// WriteLog(FloatToStr(adhesive)); // tutaj jest na poziomie 0.2 - 0.3
|
||||||
return adhesion;
|
return adhesion;
|
||||||
*/
|
|
||||||
/* //wersja druga
|
//wersja druga
|
||||||
if( true == SlippingWheels ) {
|
if( true == SlippingWheels ) {
|
||||||
|
|
||||||
if( true == SandDose ) { adhesion = 0.48; }
|
if( true == SandDose ) { adhesion = 0.48; }
|
||||||
@@ -3976,12 +3978,15 @@ double TMoverParameters::Adhesive(double staticfriction)
|
|||||||
if( true == SandDose ) { adhesion = std::max( staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ) * 1.1, 0.48 ); }
|
if( true == SandDose ) { adhesion = std::max( staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ) * 1.1, 0.48 ); }
|
||||||
else { adhesion = staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ); }
|
else { adhesion = staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ); }
|
||||||
}
|
}
|
||||||
adhesion *= ( 11.0 - 2 * Random() ) / 10.0; */
|
// adhesion *= ( 0.9 + 0.2 * Random() );
|
||||||
|
*/
|
||||||
//wersja3 by youBy - uwzględnia naturalne mikropoślizgi i wpływ piasecznicy, usuwa losowość z pojazdu
|
//wersja3 by youBy - uwzględnia naturalne mikropoślizgi i wpływ piasecznicy, usuwa losowość z pojazdu
|
||||||
double Vwheels = nrot * M_PI * WheelDiameter; // predkosc liniowa koła wynikająca z obrotowej
|
double Vwheels = nrot * M_PI * WheelDiameter; // predkosc liniowa koła wynikająca z obrotowej
|
||||||
double deltaV = V - Vwheels; //poślizg - różnica prędkości w punkcie styku koła i szyny
|
double deltaV = V - Vwheels; //poślizg - różnica prędkości w punkcie styku koła i szyny
|
||||||
deltaV = std::max(0.0, std::abs(deltaV) - 0.25); //mikropoślizgi do ok. 0,25 m/s nie zrywają przyczepności
|
deltaV = std::max(0.0, std::abs(deltaV) - 0.25); //mikropoślizgi do ok. 0,25 m/s nie zrywają przyczepności
|
||||||
adhesion = staticfriction * (28 + Vwheels) / (14 + Vwheels) * ((SandDose? sandfactor : 1) - (1 - adh_factor)*(deltaV / (deltaV + slipfactor)));
|
Vwheels = std::abs( Vwheels );
|
||||||
|
adhesion = staticfriction * (28 + Vwheels) / (14 + Vwheels) * ((SandDose? sandfactor : 1) - (1 - adh_factor)*(deltaV / (deltaV + slipfactor)));
|
||||||
|
|
||||||
return adhesion;
|
return adhesion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4051,24 +4056,11 @@ double TMoverParameters::CouplerForce(int CouplerN, double dt)
|
|||||||
// blablabla
|
// blablabla
|
||||||
// ABu: proby znalezienia problemu ze zle odbijajacymi sie skladami
|
// ABu: proby znalezienia problemu ze zle odbijajacymi sie skladami
|
||||||
//if (Couplers[CouplerN].CouplingFlag=ctrain_virtual) and (newdist>0) then
|
//if (Couplers[CouplerN].CouplingFlag=ctrain_virtual) and (newdist>0) then
|
||||||
if ((Couplers[CouplerN].CouplingFlag == ctrain_virtual) && (Couplers[CouplerN].CoupleDist > 0))
|
if( ( Couplers[ CouplerN ].CouplingFlag != coupling::faux )
|
||||||
{
|
|| ( Couplers[ CouplerN ].CoupleDist < 0 ) ) {
|
||||||
CF = 0; // kontrola zderzania sie - OK
|
|
||||||
ScanCounter++;
|
if( Couplers[ CouplerN ].CouplingFlag == coupling::faux ) {
|
||||||
if ((newdist > MaxDist) || ((ScanCounter > MaxCount) && (newdist > MinDist)))
|
|
||||||
//if (tempdist>MaxDist) or ((ScanCounter>MaxCount)and(tempdist>MinDist)) then
|
|
||||||
{ // zerwij kontrolnie wirtualny sprzeg
|
|
||||||
// Connected.Couplers[CNext].Connected:=nil; //Ra: ten podłączony niekoniecznie jest
|
|
||||||
// wirtualny
|
|
||||||
// Couplers[CouplerN].Connected = NULL;
|
|
||||||
ScanCounter = static_cast<int>(Random(500.0)); // Q: TODO: cy dobrze przetlumaczone?
|
|
||||||
// WriteLog(FloatToStr(ScanCounter));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Couplers[CouplerN].CouplingFlag == ctrain_virtual)
|
|
||||||
{
|
|
||||||
BetaAvg = Couplers[CouplerN].beta;
|
BetaAvg = Couplers[CouplerN].beta;
|
||||||
Fmax = (Couplers[CouplerN].FmaxC + Couplers[CouplerN].FmaxB) * CouplerTune;
|
Fmax = (Couplers[CouplerN].FmaxC + Couplers[CouplerN].FmaxB) * CouplerTune;
|
||||||
}
|
}
|
||||||
@@ -4144,18 +4136,20 @@ double TMoverParameters::CouplerForce(int CouplerN, double dt)
|
|||||||
//***if -tempdist>(DmaxB+Connected^.Couplers[CNext].DmaxB)/10 then {zderzenie}
|
//***if -tempdist>(DmaxB+Connected^.Couplers[CNext].DmaxB)/10 then {zderzenie}
|
||||||
{
|
{
|
||||||
Couplers[CouplerN].CheckCollision = true;
|
Couplers[CouplerN].CheckCollision = true;
|
||||||
if ((Couplers[CouplerN].CouplerType == Automatic) &&
|
if( ( Couplers[ CouplerN ].CouplerType == Automatic )
|
||||||
(Couplers[CouplerN].CouplingFlag ==
|
&& ( Couplers[ CouplerN ].CouplingFlag == coupling::faux ) ) {
|
||||||
0)) // sprzeganie wagonow z samoczynnymi sprzegami}
|
// sprzeganie wagonow z samoczynnymi sprzegami}
|
||||||
// CouplingFlag:=ctrain_coupler+ctrain_pneumatic+ctrain_controll+ctrain_passenger+ctrain_scndpneumatic;
|
// CouplingFlag:=ctrain_coupler+ctrain_pneumatic+ctrain_controll+ctrain_passenger+ctrain_scndpneumatic;
|
||||||
Couplers[CouplerN].CouplingFlag =
|
// EN57
|
||||||
ctrain_coupler | ctrain_pneumatic | ctrain_controll; // EN57
|
Couplers[ CouplerN ].CouplingFlag = coupling::coupler | coupling::brakehose | coupling::mainhose | coupling::control;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Couplers[CouplerN].CouplingFlag != ctrain_virtual)
|
if( Couplers[ CouplerN ].CouplingFlag != coupling::faux ) {
|
||||||
// uzgadnianie prawa Newtona
|
// uzgadnianie prawa Newtona
|
||||||
Couplers[CouplerN].Connected->Couplers[1 - CouplerN].CForce = -CF;
|
Couplers[ CouplerN ].Connected->Couplers[ 1 - CouplerN ].CForce = -CF;
|
||||||
|
}
|
||||||
|
|
||||||
return CF;
|
return CF;
|
||||||
}
|
}
|
||||||
@@ -6806,7 +6800,6 @@ void TMoverParameters::LoadFIZ_Wheels( std::string const &line ) {
|
|||||||
|
|
||||||
extract_value( TrackW, "Tw", line, "" );
|
extract_value( TrackW, "Tw", line, "" );
|
||||||
extract_value( AxleInertialMoment, "AIM", line, "" );
|
extract_value( AxleInertialMoment, "AIM", line, "" );
|
||||||
if( AxleInertialMoment <= 0.0 ) { AxleInertialMoment = 1.0; }
|
|
||||||
|
|
||||||
extract_value( AxleArangement, "Axle", line, "" );
|
extract_value( AxleArangement, "Axle", line, "" );
|
||||||
NPoweredAxles = s2NPW( AxleArangement );
|
NPoweredAxles = s2NPW( AxleArangement );
|
||||||
@@ -6814,11 +6807,21 @@ void TMoverParameters::LoadFIZ_Wheels( std::string const &line ) {
|
|||||||
|
|
||||||
BearingType =
|
BearingType =
|
||||||
( extract_value( "BearingType", line ) == "Roll" ) ?
|
( extract_value( "BearingType", line ) == "Roll" ) ?
|
||||||
1 :
|
1 :
|
||||||
0;
|
0;
|
||||||
|
|
||||||
extract_value( ADist, "Ad", line, "" );
|
extract_value( ADist, "Ad", line, "" );
|
||||||
extract_value( BDist, "Bd", line, "" );
|
extract_value( BDist, "Bd", line, "" );
|
||||||
|
|
||||||
|
if( AxleInertialMoment <= 0.0 ) {
|
||||||
|
/*
|
||||||
|
AxleInertialMoment = 1.0;
|
||||||
|
*/
|
||||||
|
// approximation formula by youby
|
||||||
|
auto const k = 472.0; // arbitrary constant
|
||||||
|
AxleInertialMoment = k / 4.0 * std::pow( WheelDiameter, 4.0 ) * NAxles;
|
||||||
|
Mred = k * std::pow( WheelDiameter, 2.0 ) * NAxles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
|
void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ Copyright (C) 2007-2014 Maciej Cierniak
|
|||||||
|
|
||||||
bool DebugModeFlag = false;
|
bool DebugModeFlag = false;
|
||||||
bool FreeFlyModeFlag = false;
|
bool FreeFlyModeFlag = false;
|
||||||
|
bool EditorModeFlag = true;
|
||||||
bool DebugCameraFlag = false;
|
bool DebugCameraFlag = false;
|
||||||
|
|
||||||
double Max0R(double x1, double x2)
|
double Max0R(double x1, double x2)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
extern bool DebugModeFlag;
|
extern bool DebugModeFlag;
|
||||||
extern bool FreeFlyModeFlag;
|
extern bool FreeFlyModeFlag;
|
||||||
|
extern bool EditorModeFlag;
|
||||||
extern bool DebugCameraFlag;
|
extern bool DebugCameraFlag;
|
||||||
|
|
||||||
/*funkcje matematyczne*/
|
/*funkcje matematyczne*/
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ void UpdateTimers(bool pause)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
DeltaTime = 0.0; // wszystko stoi, bo czas nie płynie
|
DeltaTime = 0.0; // wszystko stoi, bo czas nie płynie
|
||||||
oldCount = count;
|
|
||||||
|
|
||||||
|
oldCount = count;
|
||||||
// Keep track of the time lapse and frame count
|
// Keep track of the time lapse and frame count
|
||||||
#if __linux__
|
#if __linux__
|
||||||
double fTime = (double)(count / 1000000000);
|
double fTime = (double)(count / 1000000000);
|
||||||
@@ -111,6 +111,7 @@ void UpdateTimers(bool pause)
|
|||||||
}
|
}
|
||||||
fSimulationTime += DeltaTime;
|
fSimulationTime += DeltaTime;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
}; // namespace timer
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2340,7 +2340,7 @@ void TTrack::ConnectionsLog()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TTrack * TTrack::Neightbour(int s, double &d)
|
TTrack * TTrack::Connected(int s, double &d) const
|
||||||
{ // zwraca wskaźnik na sąsiedni tor, w kierunku określonym znakiem (s), odwraca (d) w razie
|
{ // zwraca wskaźnik na sąsiedni tor, w kierunku określonym znakiem (s), odwraca (d) w razie
|
||||||
// niezgodności kierunku torów
|
// niezgodności kierunku torów
|
||||||
TTrack *t; // nie zmieniamy kierunku (d), jeśli nie ma toru dalej
|
TTrack *t; // nie zmieniamy kierunku (d), jeśli nie ma toru dalej
|
||||||
|
|||||||
2
Track.h
2
Track.h
@@ -205,7 +205,7 @@ public:
|
|||||||
return trNext; };
|
return trNext; };
|
||||||
inline TTrack *CurrentPrev() const {
|
inline TTrack *CurrentPrev() const {
|
||||||
return trPrev; };
|
return trPrev; };
|
||||||
TTrack * Neightbour(int s, double &d);
|
TTrack *Connected(int s, double &d) const;
|
||||||
bool SetConnections(int i);
|
bool SetConnections(int i);
|
||||||
bool Switch(int i, double t = -1.0, double d = -1.0);
|
bool Switch(int i, double t = -1.0, double d = -1.0);
|
||||||
bool SwitchForced(int i, TDynamicObject *o);
|
bool SwitchForced(int i, TDynamicObject *o);
|
||||||
|
|||||||
70
Train.cpp
70
Train.cpp
@@ -297,7 +297,6 @@ TTrain::TTrain() {
|
|||||||
fPPress = fNPress = 0;
|
fPPress = fNPress = 0;
|
||||||
|
|
||||||
// asMessage="";
|
// asMessage="";
|
||||||
fMechCroach = 0.25;
|
|
||||||
pMechShake = vector3(0, 0, 0);
|
pMechShake = vector3(0, 0, 0);
|
||||||
vMechMovement = vector3(0, 0, 0);
|
vMechMovement = vector3(0, 0, 0);
|
||||||
pMechOffset = vector3(0, 0, 0);
|
pMechOffset = vector3(0, 0, 0);
|
||||||
@@ -424,8 +423,7 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
|
|||||||
*/
|
*/
|
||||||
MechSpring.Init(0.015, 250);
|
MechSpring.Init(0.015, 250);
|
||||||
vMechVelocity = vector3(0, 0, 0);
|
vMechVelocity = vector3(0, 0, 0);
|
||||||
pMechOffset = vector3(-0.4, 3.3, 5.5);
|
pMechOffset = vector3( 0, 0, 0 );
|
||||||
fMechCroach = 0.5;
|
|
||||||
fMechSpringX = 1;
|
fMechSpringX = 1;
|
||||||
fMechSpringY = 0.5;
|
fMechSpringY = 0.5;
|
||||||
fMechSpringZ = 0.5;
|
fMechSpringZ = 0.5;
|
||||||
@@ -1465,10 +1463,14 @@ void TTrain::OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_d
|
|||||||
if( Train->mvControlled->bPantKurek3 == false ) {
|
if( Train->mvControlled->bPantKurek3 == false ) {
|
||||||
// connect pantographs with primary tank
|
// connect pantographs with primary tank
|
||||||
Train->mvControlled->bPantKurek3 = true;
|
Train->mvControlled->bPantKurek3 = true;
|
||||||
|
// visual feedback:
|
||||||
|
Train->ggPantCompressorValve.UpdateValue( 0.0 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// connect pantograps with pantograph compressor
|
// connect pantograps with pantograph compressor
|
||||||
Train->mvControlled->bPantKurek3 = false;
|
Train->mvControlled->bPantKurek3 = false;
|
||||||
|
// visual feedback:
|
||||||
|
Train->ggPantCompressorValve.UpdateValue( 1.0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1491,10 +1493,14 @@ void TTrain::OnCommand_pantographcompressoractivate( TTrain *Train, command_data
|
|||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
// press or hold to activate
|
// press or hold to activate
|
||||||
Train->mvControlled->PantCompFlag = true;
|
Train->mvControlled->PantCompFlag = true;
|
||||||
|
// visual feedback:
|
||||||
|
Train->ggPantCompressorButton.UpdateValue( 1.0 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// release to disable
|
// release to disable
|
||||||
Train->mvControlled->PantCompFlag = false;
|
Train->mvControlled->PantCompFlag = false;
|
||||||
|
// visual feedback:
|
||||||
|
Train->ggPantCompressorButton.UpdateValue( 0.0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4671,37 +4677,37 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
ggBrakeCtrl.UpdateValue(mvOccupied->fBrakeCtrlPos);
|
ggBrakeCtrl.UpdateValue(mvOccupied->fBrakeCtrlPos);
|
||||||
ggBrakeCtrl.Update();
|
ggBrakeCtrl.Update();
|
||||||
}
|
}
|
||||||
if (ggLocalBrake.SubModel)
|
if( ggLocalBrake.SubModel ) {
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (DynamicObject->Mechanik ?
|
if( ( DynamicObject->Mechanik != nullptr )
|
||||||
(DynamicObject->Mechanik->AIControllFlag ? false : (Global::iFeedbackMode == 4 || (Global::bMWDmasterEnable && Global::bMWDBreakEnable))) :
|
&& ( false == DynamicObject->Mechanik->AIControllFlag ) // nie blokujemy AI
|
||||||
false) // nie blokujemy AI
|
&& ( mvOccupied->BrakeLocHandle == FD1 )
|
||||||
{ // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
|
&& ( ( Global::iFeedbackMode == 4 )
|
||||||
// Firleju: dlatego kasujemy i zastepujemy funkcją w Console
|
|| ( Global::bMWDmasterEnable && Global::bMWDBreakEnable ) ) ) {
|
||||||
if ((mvOccupied->BrakeLocHandle == FD1))
|
// Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
|
||||||
{
|
// Firleju: dlatego kasujemy i zastepujemy funkcją w Console
|
||||||
double b = Console::AnalogCalibrateGet(1);
|
auto const b = clamp<double>(
|
||||||
b *= 10.0;
|
Console::AnalogCalibrateGet( 1 ) * 10.0,
|
||||||
b = clamp<double>( b, 0.0, LocalBrakePosNo); // przycięcie zmiennej do granic
|
0.0,
|
||||||
ggLocalBrake.UpdateValue(b); // przesów bez zaokrąglenia
|
ManualBrakePosNo );
|
||||||
if (Global::bMWDdebugEnable && Global::iMWDDebugMode & 4) WriteLog("FD1 break position = " + to_string(b));
|
ggLocalBrake.UpdateValue( b ); // przesów bez zaokrąglenia
|
||||||
mvOccupied->LocalBrakePos =
|
mvOccupied->LocalBrakePos = int( 1.09 * b ); // sposób zaokrąglania jest do ustalenia
|
||||||
int(1.09 * b); // sposób zaokrąglania jest do ustalenia
|
if( ( true == Global::bMWDdebugEnable )
|
||||||
|
&& ( ( Global::iMWDDebugMode & 4 ) != 0 ) ) {
|
||||||
|
WriteLog( "FD1 break position = " + to_string( b ) );
|
||||||
}
|
}
|
||||||
else // standardowa prodedura z kranem powiązanym z klawiaturą
|
|
||||||
ggLocalBrake.UpdateValue(double(mvOccupied->LocalBrakePos));
|
|
||||||
}
|
}
|
||||||
else // standardowa prodedura z kranem powiązanym z klawiaturą
|
else // standardowa prodedura z kranem powiązanym z klawiaturą
|
||||||
#endif
|
#endif
|
||||||
ggLocalBrake.UpdateValue(double(mvOccupied->LocalBrakePos));
|
ggLocalBrake.UpdateValue(double(mvOccupied->LocalBrakePos));
|
||||||
|
|
||||||
ggLocalBrake.Update();
|
ggLocalBrake.Update();
|
||||||
}
|
}
|
||||||
if (ggManualBrake.SubModel != NULL)
|
if (ggManualBrake.SubModel != nullptr) {
|
||||||
{
|
|
||||||
ggManualBrake.UpdateValue(double(mvOccupied->ManualBrakePos));
|
ggManualBrake.UpdateValue(double(mvOccupied->ManualBrakePos));
|
||||||
ggManualBrake.Update();
|
ggManualBrake.Update();
|
||||||
}
|
}
|
||||||
|
ggAlarmChain.Update();
|
||||||
ggBrakeProfileCtrl.Update();
|
ggBrakeProfileCtrl.Update();
|
||||||
ggBrakeProfileG.Update();
|
ggBrakeProfileG.Update();
|
||||||
ggBrakeProfileR.Update();
|
ggBrakeProfileR.Update();
|
||||||
@@ -5662,6 +5668,8 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
ggPantRearButtonOff.Update();
|
ggPantRearButtonOff.Update();
|
||||||
ggPantSelectedDownButton.Update();
|
ggPantSelectedDownButton.Update();
|
||||||
ggPantAllDownButton.Update();
|
ggPantAllDownButton.Update();
|
||||||
|
ggPantCompressorButton.Update();
|
||||||
|
ggPantCompressorValve.Update();
|
||||||
|
|
||||||
ggUpperLightButton.Update();
|
ggUpperLightButton.Update();
|
||||||
ggLeftLightButton.Update();
|
ggLeftLightButton.Update();
|
||||||
@@ -6335,8 +6343,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::MechStop()
|
void TTrain::MechStop()
|
||||||
{ // likwidacja ruchu kamery w kabinie (po powrocie
|
{ // likwidacja ruchu kamery w kabinie (po powrocie przez [F4])
|
||||||
// przez [F4])
|
|
||||||
pMechPosition = vector3(0, 0, 0);
|
pMechPosition = vector3(0, 0, 0);
|
||||||
pMechShake = vector3(0, 0, 0);
|
pMechShake = vector3(0, 0, 0);
|
||||||
vMechMovement = vector3(0, 0, 0);
|
vMechMovement = vector3(0, 0, 0);
|
||||||
@@ -6576,6 +6583,8 @@ void TTrain::clear_cab_controls()
|
|||||||
ggPantRearButtonOff.Clear();
|
ggPantRearButtonOff.Clear();
|
||||||
ggPantSelectedDownButton.Clear();
|
ggPantSelectedDownButton.Clear();
|
||||||
ggPantAllDownButton.Clear();
|
ggPantAllDownButton.Clear();
|
||||||
|
ggPantCompressorButton.Clear();
|
||||||
|
ggPantCompressorValve.Clear();
|
||||||
ggZbS.Clear();
|
ggZbS.Clear();
|
||||||
ggI1B.Clear();
|
ggI1B.Clear();
|
||||||
ggI2B.Clear();
|
ggI2B.Clear();
|
||||||
@@ -6722,6 +6731,15 @@ void TTrain::set_cab_controls() {
|
|||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
}
|
}
|
||||||
|
// auxiliary compressor
|
||||||
|
ggPantCompressorValve.PutValue(
|
||||||
|
mvControlled->bPantKurek3 ?
|
||||||
|
0.0 : // default setting is pantographs connected with primary tank
|
||||||
|
1.0 );
|
||||||
|
ggPantCompressorButton.PutValue(
|
||||||
|
mvControlled->PantCompFlag ?
|
||||||
|
1.0 :
|
||||||
|
0.0 );
|
||||||
// converter
|
// converter
|
||||||
if( mvOccupied->ConvSwitchType != "impulse" ) {
|
if( mvOccupied->ConvSwitchType != "impulse" ) {
|
||||||
ggConverterButton.PutValue(
|
ggConverterButton.PutValue(
|
||||||
@@ -7140,6 +7158,8 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
|||||||
{ "pantalloff_sw:", ggPantAllDownButton },
|
{ "pantalloff_sw:", ggPantAllDownButton },
|
||||||
{ "pantselected_sw:", ggPantSelectedButton },
|
{ "pantselected_sw:", ggPantSelectedButton },
|
||||||
{ "pantselectedoff_sw:", ggPantSelectedDownButton },
|
{ "pantselectedoff_sw:", ggPantSelectedDownButton },
|
||||||
|
{ "pantcompressor_sw:", ggPantCompressorButton },
|
||||||
|
{ "pantcompressorvalve_sw:", ggPantCompressorValve },
|
||||||
{ "trainheating_sw:", ggTrainHeatingButton },
|
{ "trainheating_sw:", ggTrainHeatingButton },
|
||||||
{ "signalling_sw:", ggSignallingButton },
|
{ "signalling_sw:", ggSignallingButton },
|
||||||
{ "door_signalling_sw:", ggDoorSignallingButton },
|
{ "door_signalling_sw:", ggDoorSignallingButton },
|
||||||
|
|||||||
3
Train.h
3
Train.h
@@ -298,6 +298,8 @@ public: // reszta może by?publiczna
|
|||||||
TGauge ggPantAllDownButton;
|
TGauge ggPantAllDownButton;
|
||||||
TGauge ggPantSelectedButton;
|
TGauge ggPantSelectedButton;
|
||||||
TGauge ggPantSelectedDownButton;
|
TGauge ggPantSelectedDownButton;
|
||||||
|
TGauge ggPantCompressorButton;
|
||||||
|
TGauge ggPantCompressorValve;
|
||||||
// Winger 020304 - wlacznik ogrzewania
|
// Winger 020304 - wlacznik ogrzewania
|
||||||
TGauge ggTrainHeatingButton;
|
TGauge ggTrainHeatingButton;
|
||||||
TGauge ggSignallingButton;
|
TGauge ggSignallingButton;
|
||||||
@@ -375,7 +377,6 @@ public: // reszta może by?publiczna
|
|||||||
vector3 pMechShake;
|
vector3 pMechShake;
|
||||||
vector3 vMechVelocity;
|
vector3 vMechVelocity;
|
||||||
// McZapkie: do poruszania sie po kabinie
|
// McZapkie: do poruszania sie po kabinie
|
||||||
double fMechCroach;
|
|
||||||
// McZapkie: opis kabiny - obszar poruszania sie mechanika oraz zajetosc
|
// McZapkie: opis kabiny - obszar poruszania sie mechanika oraz zajetosc
|
||||||
TCab Cabine[maxcab + 1]; // przedzial maszynowy, kabina 1 (A), kabina 2 (B)
|
TCab Cabine[maxcab + 1]; // przedzial maszynowy, kabina 1 (A), kabina 2 (B)
|
||||||
int iCabn;
|
int iCabn;
|
||||||
|
|||||||
@@ -206,10 +206,10 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
|||||||
dir = fDirection;
|
dir = fDirection;
|
||||||
if (pCurrentTrack->eType == tt_Cross)
|
if (pCurrentTrack->eType == tt_Cross)
|
||||||
{
|
{
|
||||||
if (!SetCurrentTrack(pCurrentTrack->Neightbour(iSegment, fDirection), 0))
|
if (!SetCurrentTrack(pCurrentTrack->Connected(iSegment, fDirection), 0))
|
||||||
return false; // wyjście z błędem
|
return false; // wyjście z błędem
|
||||||
}
|
}
|
||||||
else if (!SetCurrentTrack(pCurrentTrack->Neightbour(-1, fDirection),
|
else if (!SetCurrentTrack(pCurrentTrack->Connected(-1, fDirection),
|
||||||
0)) // ustawia fDirection
|
0)) // ustawia fDirection
|
||||||
return false; // wyjście z błędem
|
return false; // wyjście z błędem
|
||||||
if (dir == fDirection) //(pCurrentTrack->iPrevDirection)
|
if (dir == fDirection) //(pCurrentTrack->iPrevDirection)
|
||||||
@@ -243,10 +243,10 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
|||||||
dir = fDirection;
|
dir = fDirection;
|
||||||
if (pCurrentTrack->eType == tt_Cross)
|
if (pCurrentTrack->eType == tt_Cross)
|
||||||
{
|
{
|
||||||
if (!SetCurrentTrack(pCurrentTrack->Neightbour(iSegment, fDirection), 1))
|
if (!SetCurrentTrack(pCurrentTrack->Connected(iSegment, fDirection), 1))
|
||||||
return false; // wyjście z błędem
|
return false; // wyjście z błędem
|
||||||
}
|
}
|
||||||
else if (!SetCurrentTrack(pCurrentTrack->Neightbour(1, fDirection),
|
else if (!SetCurrentTrack(pCurrentTrack->Connected(1, fDirection),
|
||||||
1)) // ustawia fDirection
|
1)) // ustawia fDirection
|
||||||
return false; // wyjście z błędem
|
return false; // wyjście z błędem
|
||||||
if (dir != fDirection) //(pCurrentTrack->iNextDirection)
|
if (dir != fDirection) //(pCurrentTrack->iNextDirection)
|
||||||
|
|||||||
108
World.cpp
108
World.cpp
@@ -199,14 +199,10 @@ simulation_time::julian_day() const {
|
|||||||
|
|
||||||
TWorld::TWorld()
|
TWorld::TWorld()
|
||||||
{
|
{
|
||||||
// randomize();
|
|
||||||
// Randomize();
|
|
||||||
Train = NULL;
|
Train = NULL;
|
||||||
// Aspect=1;
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
KeyEvents[i] = NULL; // eventy wyzwalane klawiszami cyfrowymi
|
KeyEvents[i] = NULL; // eventy wyzwalane klawiszami cyfrowymi
|
||||||
Global::iSlowMotion = 0;
|
Global::iSlowMotion = 0;
|
||||||
// Global::changeDynObj=NULL;
|
|
||||||
pDynamicNearest = NULL;
|
pDynamicNearest = NULL;
|
||||||
fTimeBuffer = 0.0; // bufor czasu aktualizacji dla stałego kroku fizyki
|
fTimeBuffer = 0.0; // bufor czasu aktualizacji dla stałego kroku fizyki
|
||||||
fMaxDt = 0.01; //[s] początkowy krok czasowy fizyki
|
fMaxDt = 0.01; //[s] początkowy krok czasowy fizyki
|
||||||
@@ -215,7 +211,6 @@ TWorld::TWorld()
|
|||||||
|
|
||||||
TWorld::~TWorld()
|
TWorld::~TWorld()
|
||||||
{
|
{
|
||||||
Global::bManageNodes = false; // Ra: wyłączenie wyrejestrowania, bo się sypie
|
|
||||||
TrainDelete();
|
TrainDelete();
|
||||||
// Ground.Free(); //Ra: usunięcie obiektów przed usunięciem dźwięków - sypie się
|
// Ground.Free(); //Ra: usunięcie obiektów przed usunięciem dźwięków - sypie się
|
||||||
}
|
}
|
||||||
@@ -233,61 +228,6 @@ void TWorld::TrainDelete(TDynamicObject *d)
|
|||||||
Global::pUserDynamic = NULL; // tego też nie ma
|
Global::pUserDynamic = NULL; // tego też nie ma
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Ra: do opracowania: wybor karty graficznej ~Intel gdy są dwie...
|
|
||||||
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)
|
|
||||||
{
|
|
||||||
FARPROC EnumDisplayDevices;
|
|
||||||
HINSTANCE hInstUser32;
|
|
||||||
DISPLAY_DEVICE DispDev;
|
|
||||||
char szSaveDeviceName[33]; // 32 + 1 for the null-terminator
|
|
||||||
BOOL bRet = TRUE;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
hInstUser32 = LoadLibrary("c:\\windows\User32.DLL");
|
|
||||||
if (!hInstUser32) return FALSE;
|
|
||||||
|
|
||||||
// Get the address of the EnumDisplayDevices function
|
|
||||||
EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
|
|
||||||
if (!EnumDisplayDevices) {
|
|
||||||
FreeLibrary(hInstUser32);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZeroMemory(&DispDev, sizeof(DispDev));
|
|
||||||
DispDev.cb = sizeof(DispDev);
|
|
||||||
|
|
||||||
// After the first call to EnumDisplayDevices,
|
|
||||||
// DispDev.DeviceString is the adapter name
|
|
||||||
if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0))
|
|
||||||
{
|
|
||||||
hr = StringCchCopy(szSaveDeviceName, 33, DispDev.DeviceName);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
// TODO: write error handler
|
|
||||||
}
|
|
||||||
|
|
||||||
// After second call, DispDev.DeviceString is the
|
|
||||||
// monitor name for that device
|
|
||||||
EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);
|
|
||||||
|
|
||||||
// In the following, lpszMonitorInfo must be 128 + 1 for
|
|
||||||
// the null-terminator.
|
|
||||||
hr = StringCchCopy(lpszMonitorInfo, 129, DispDev.DeviceString);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
// TODO: write error handler
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
bRet = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
FreeLibrary(hInstUser32);
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool TWorld::Init( GLFWwindow *Window ) {
|
bool TWorld::Init( GLFWwindow *Window ) {
|
||||||
|
|
||||||
auto timestart = std::chrono::system_clock::now();
|
auto timestart = std::chrono::system_clock::now();
|
||||||
@@ -825,11 +765,6 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// switch (cKey)
|
|
||||||
//{case 'a': //ignorowanie repetycji
|
|
||||||
// case 'A': Global::iKeyLast=cKey; break;
|
|
||||||
// default: Global::iKeyLast=0;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TWorld::OnMouseMove(double x, double y)
|
void TWorld::OnMouseMove(double x, double y)
|
||||||
@@ -840,12 +775,14 @@ void TWorld::OnMouseMove(double x, double y)
|
|||||||
void TWorld::InOutKey( bool const Near )
|
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) {
|
||||||
{ // jeżeli poza kabiną, przestawiamy w jej okolicę - OK
|
// jeżeli poza kabiną, przestawiamy w jej okolicę - OK
|
||||||
Global::pUserDynamic = NULL; // bez renderowania względem kamery
|
Global::pUserDynamic = NULL; // bez renderowania względem kamery
|
||||||
if (Train)
|
if (Train) {
|
||||||
{ // Train->Dynamic()->ABuSetModelShake(vector3(0,0,0));
|
// cache current cab position so there's no need to set it all over again after each out-in switch
|
||||||
Train->Silence(); // wyłączenie dźwięków kabiny
|
Train->pMechSittingPosition = Train->pMechOffset;
|
||||||
|
// wyłączenie dźwięków kabiny
|
||||||
|
Train->Silence();
|
||||||
Train->Dynamic()->bDisplayCab = false;
|
Train->Dynamic()->bDisplayCab = false;
|
||||||
DistantView( Near );
|
DistantView( Near );
|
||||||
}
|
}
|
||||||
@@ -1053,8 +990,15 @@ bool TWorld::Update()
|
|||||||
// this means at count > 20 simulation and render are going to desync. is that right?
|
// this means at count > 20 simulation and render are going to desync. is that right?
|
||||||
// NOTE: experimentally changing this to prevent the desync.
|
// NOTE: experimentally changing this to prevent the desync.
|
||||||
// TODO: test what happens if we hit more than 20 * 0.01 sec slices, i.e. less than 5 fps
|
// TODO: test what happens if we hit more than 20 * 0.01 sec slices, i.e. less than 5 fps
|
||||||
for( int updateidx = 0; updateidx < updatecount; ++updateidx ) {
|
if( true == Global::FullPhysics ) {
|
||||||
Ground.Update( dt / updatecount, 1 ); // tu zrobić tylko coklatkową aktualizację przesunięć
|
// default calculation mode, each step calculated separately
|
||||||
|
for( int updateidx = 0; updateidx < updatecount; ++updateidx ) {
|
||||||
|
Ground.Update( dt / updatecount, 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// slightly simplified calculation mode; can lead to errors
|
||||||
|
Ground.Update( dt / updatecount, updatecount );
|
||||||
}
|
}
|
||||||
|
|
||||||
// yB dodał przyspieszacz fizyki
|
// yB dodał przyspieszacz fizyki
|
||||||
@@ -2035,26 +1979,6 @@ void TWorld::OnCommandGet(DaneRozkaz *pRozkaz)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
void TWorld::ModifyTGA(const std::string &dir)
|
|
||||||
{ // rekurencyjna modyfikacje plików TGA
|
|
||||||
/* TODO: implement version without Borland stuff
|
|
||||||
TSearchRec sr;
|
|
||||||
if (FindFirst(dir + "*.*", faDirectory | faArchive, sr) == 0)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (sr.Name[1] != '.')
|
|
||||||
if ((sr.Attr & faDirectory)) // jeśli katalog, to rekurencja
|
|
||||||
ModifyTGA(dir + sr.Name + "/");
|
|
||||||
else if (sr.Name.LowerCase().SubString(sr.Name.Length() - 3, 4) == ".tga")
|
|
||||||
TTexturesManager::GetTextureID(NULL, NULL, AnsiString(dir + sr.Name).c_str());
|
|
||||||
} while (FindNext(sr) == 0);
|
|
||||||
FindClose(sr);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void TWorld::CreateE3D(std::string const &Path, bool Dynamic)
|
void TWorld::CreateE3D(std::string const &Path, bool Dynamic)
|
||||||
|
|||||||
1
World.h
1
World.h
@@ -141,7 +141,6 @@ private:
|
|||||||
bool m_init{ false }; // indicates whether initial update of the world was performed
|
bool m_init{ false }; // indicates whether initial update of the world was performed
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void ModifyTGA(std::string const &dir = "");
|
|
||||||
void CreateE3D(std::string const &dir = "", bool dyn = false);
|
void CreateE3D(std::string const &dir = "", bool dyn = false);
|
||||||
void CabChange(TDynamicObject *old, TDynamicObject *now);
|
void CabChange(TDynamicObject *old, TDynamicObject *now);
|
||||||
// handles vehicle change flag
|
// handles vehicle change flag
|
||||||
|
|||||||
164
mouseinput.cpp
164
mouseinput.cpp
@@ -68,93 +68,105 @@ void
|
|||||||
mouse_input::button( int const Button, int const Action ) {
|
mouse_input::button( int const Button, int const Action ) {
|
||||||
|
|
||||||
if( false == Global::ControlPicking ) { return; }
|
if( false == Global::ControlPicking ) { return; }
|
||||||
|
|
||||||
if( true == FreeFlyModeFlag ) {
|
if( true == FreeFlyModeFlag ) {
|
||||||
// for now we're only interested in cab controls
|
// world editor controls
|
||||||
return;
|
// currently we only handle view panning in this mode
|
||||||
}
|
if( Action == GLFW_RELEASE ) {
|
||||||
|
// if it's the right mouse button that got released we were potentially in view panning mode; stop it
|
||||||
user_command &mousecommand = (
|
|
||||||
Button == GLFW_MOUSE_BUTTON_LEFT ?
|
|
||||||
m_mousecommandleft :
|
|
||||||
m_mousecommandright
|
|
||||||
);
|
|
||||||
|
|
||||||
if( Action == GLFW_RELEASE ) {
|
|
||||||
if( mousecommand != user_command::none ) {
|
|
||||||
// NOTE: basic keyboard controls don't have any parameters
|
|
||||||
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
|
||||||
// TODO: pass correct entity id once the missing systems are in place
|
|
||||||
m_relay.post( mousecommand, 0, 0, Action, 0 );
|
|
||||||
mousecommand = user_command::none;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// if it's the right mouse button that got released and we had no command active, we were potentially in view panning mode; stop it
|
|
||||||
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
||||||
m_pickmodepanning = false;
|
m_pickmodepanning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if we were in varying command repeat rate, we can stop that now. done without any conditions, to catch some unforeseen edge cases
|
else {
|
||||||
m_varyingpollrate = false;
|
// button press
|
||||||
|
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
||||||
|
// the right button activates mouse panning mode
|
||||||
|
m_pickmodepanning = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// if not release then it's press
|
// cab controls mode
|
||||||
auto train = World.train();
|
user_command &mousecommand = (
|
||||||
if( train != nullptr ) {
|
Button == GLFW_MOUSE_BUTTON_LEFT ?
|
||||||
auto lookup = m_mousecommands.find( train->GetLabel( GfxRenderer.Update_Pick_Control() ) );
|
m_mousecommandleft :
|
||||||
if( lookup != m_mousecommands.end() ) {
|
m_mousecommandright
|
||||||
mousecommand = (
|
);
|
||||||
Button == GLFW_MOUSE_BUTTON_LEFT ?
|
|
||||||
lookup->second.left :
|
if( Action == GLFW_RELEASE ) {
|
||||||
lookup->second.right
|
if( mousecommand != user_command::none ) {
|
||||||
);
|
// NOTE: basic keyboard controls don't have any parameters
|
||||||
if( mousecommand != user_command::none ) {
|
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
||||||
// check manually for commands which have 'fast' variants launched with shift modifier
|
// TODO: pass correct entity id once the missing systems are in place
|
||||||
if( Global::shiftState ) {
|
m_relay.post( mousecommand, 0, 0, Action, 0 );
|
||||||
|
mousecommand = user_command::none;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// if it's the right mouse button that got released and we had no command active, we were potentially in view panning mode; stop it
|
||||||
|
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
||||||
|
m_pickmodepanning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if we were in varying command repeat rate, we can stop that now. done without any conditions, to catch some unforeseen edge cases
|
||||||
|
m_varyingpollrate = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// if not release then it's press
|
||||||
|
auto train = World.train();
|
||||||
|
if( train != nullptr ) {
|
||||||
|
auto lookup = m_mousecommands.find( train->GetLabel( GfxRenderer.Update_Pick_Control() ) );
|
||||||
|
if( lookup != m_mousecommands.end() ) {
|
||||||
|
mousecommand = (
|
||||||
|
Button == GLFW_MOUSE_BUTTON_LEFT ?
|
||||||
|
lookup->second.left :
|
||||||
|
lookup->second.right
|
||||||
|
);
|
||||||
|
if( mousecommand != user_command::none ) {
|
||||||
|
// check manually for commands which have 'fast' variants launched with shift modifier
|
||||||
|
if( Global::shiftState ) {
|
||||||
|
switch( mousecommand ) {
|
||||||
|
case user_command::mastercontrollerincrease: { mousecommand = user_command::mastercontrollerincreasefast; break; }
|
||||||
|
case user_command::mastercontrollerdecrease: { mousecommand = user_command::mastercontrollerdecreasefast; break; }
|
||||||
|
case user_command::secondcontrollerincrease: { mousecommand = user_command::secondcontrollerincreasefast; break; }
|
||||||
|
case user_command::secondcontrollerdecrease: { mousecommand = user_command::secondcontrollerdecreasefast; break; }
|
||||||
|
case user_command::independentbrakeincrease: { mousecommand = user_command::independentbrakeincreasefast; break; }
|
||||||
|
case user_command::independentbrakedecrease: { mousecommand = user_command::independentbrakedecreasefast; break; }
|
||||||
|
default: { break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// NOTE: basic keyboard controls don't have any parameters
|
||||||
|
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
||||||
|
// TODO: pass correct entity id once the missing systems are in place
|
||||||
|
m_relay.post( mousecommand, 0, 0, Action, 0 );
|
||||||
|
m_updateaccumulator = 0.0; // prevent potential command repeat right after issuing one
|
||||||
|
|
||||||
switch( mousecommand ) {
|
switch( mousecommand ) {
|
||||||
case user_command::mastercontrollerincrease: { mousecommand = user_command::mastercontrollerincreasefast; break; }
|
case user_command::mastercontrollerincrease:
|
||||||
case user_command::mastercontrollerdecrease: { mousecommand = user_command::mastercontrollerdecreasefast; break; }
|
case user_command::mastercontrollerdecrease:
|
||||||
case user_command::secondcontrollerincrease: { mousecommand = user_command::secondcontrollerincreasefast; break; }
|
case user_command::secondcontrollerincrease:
|
||||||
case user_command::secondcontrollerdecrease: { mousecommand = user_command::secondcontrollerdecreasefast; break; }
|
case user_command::secondcontrollerdecrease:
|
||||||
case user_command::independentbrakeincrease: { mousecommand = user_command::independentbrakeincreasefast; break; }
|
case user_command::trainbrakeincrease:
|
||||||
case user_command::independentbrakedecrease: { mousecommand = user_command::independentbrakedecreasefast; break; }
|
case user_command::trainbrakedecrease:
|
||||||
default: { break; }
|
case user_command::independentbrakeincrease:
|
||||||
}
|
case user_command::independentbrakedecrease: {
|
||||||
}
|
// these commands trigger varying repeat rate mode,
|
||||||
// NOTE: basic keyboard controls don't have any parameters
|
// which scales the rate based on the distance of the cursor from its point when the command was first issued
|
||||||
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
m_commandstartcursor = m_cursorposition;
|
||||||
// TODO: pass correct entity id once the missing systems are in place
|
m_varyingpollrate = true;
|
||||||
m_relay.post( mousecommand, 0, 0, Action, 0 );
|
break;
|
||||||
m_updateaccumulator = 0.0; // prevent potential command repeat right after issuing one
|
}
|
||||||
/*
|
default: {
|
||||||
if( mousecommand == user_command::mastercontrollerincrease ) {
|
break;
|
||||||
m_updateaccumulator -= 0.15; // extra pause on first increase of master controller
|
}
|
||||||
}
|
|
||||||
*/
|
|
||||||
switch( mousecommand ) {
|
|
||||||
case user_command::mastercontrollerincrease:
|
|
||||||
case user_command::mastercontrollerdecrease:
|
|
||||||
case user_command::secondcontrollerincrease:
|
|
||||||
case user_command::secondcontrollerdecrease:
|
|
||||||
case user_command::trainbrakeincrease:
|
|
||||||
case user_command::trainbrakedecrease:
|
|
||||||
case user_command::independentbrakeincrease:
|
|
||||||
case user_command::independentbrakedecrease: {
|
|
||||||
// these commands trigger varying repeat rate mode,
|
|
||||||
// which scales the rate based on the distance of the cursor from its point when the command was first issued
|
|
||||||
m_commandstartcursor = m_cursorposition;
|
|
||||||
m_varyingpollrate = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
else {
|
// if we don't have any recognized element under the cursor and the right button was pressed, enter view panning mode
|
||||||
// if we don't have any recognized element under the cursor and the right button was pressed, enter view panning mode
|
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
||||||
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
m_pickmodepanning = true;
|
||||||
m_pickmodepanning = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
renderer.cpp
42
renderer.cpp
@@ -425,14 +425,23 @@ opengl_renderer::Render_pass( rendermode const Mode ) {
|
|||||||
::glEnable( GL_TEXTURE_2D );
|
::glEnable( GL_TEXTURE_2D );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef EU07_NEW_CAB_RENDERCODE
|
||||||
|
if( World.Train != nullptr ) {
|
||||||
|
// cab render is performed without shadows, due to low resolution and number of models without windows :|
|
||||||
|
switch_units( true, false, false );
|
||||||
|
Render_cab( World.Train->Dynamic(), false );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
switch_units( true, true, true );
|
||||||
Render( &World.Ground );
|
Render( &World.Ground );
|
||||||
// ...translucent parts
|
// ...translucent parts
|
||||||
setup_drawing( true );
|
setup_drawing( true );
|
||||||
Render_Alpha( &World.Ground );
|
Render_Alpha( &World.Ground );
|
||||||
// cab render is performed without shadows, due to low resolution and number of models without windows :|
|
if( World.Train != nullptr ) {
|
||||||
switch_units( true, false, false );
|
// cab render is performed without shadows, due to low resolution and number of models without windows :|
|
||||||
// cab render is done in translucent phase to deal with badly configured vehicles
|
switch_units( true, false, false );
|
||||||
if( World.Train != nullptr ) { Render_cab( World.Train->Dynamic() ); }
|
Render_cab( World.Train->Dynamic(), true );
|
||||||
|
}
|
||||||
|
|
||||||
if( m_environmentcubetexturesupport ) {
|
if( m_environmentcubetexturesupport ) {
|
||||||
// restore default texture matrix for reflections cube map
|
// restore default texture matrix for reflections cube map
|
||||||
@@ -1622,8 +1631,8 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ( distancesquared > Node->fSquareRadius )
|
if( ( distancesquared < Node->fSquareMinRadius )
|
||||||
|| ( distancesquared < Node->fSquareMinRadius ) ) {
|
|| ( distancesquared >= Node->fSquareRadius ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1907,7 +1916,7 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) {
|
|||||||
|
|
||||||
// rendering kabiny gdy jest oddzielnym modelem i ma byc wyswietlana
|
// rendering kabiny gdy jest oddzielnym modelem i ma byc wyswietlana
|
||||||
bool
|
bool
|
||||||
opengl_renderer::Render_cab( TDynamicObject *Dynamic ) {
|
opengl_renderer::Render_cab( TDynamicObject *Dynamic, bool const Alpha ) {
|
||||||
|
|
||||||
if( Dynamic == nullptr ) {
|
if( Dynamic == nullptr ) {
|
||||||
|
|
||||||
@@ -1944,8 +1953,19 @@ opengl_renderer::Render_cab( TDynamicObject *Dynamic ) {
|
|||||||
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( Dynamic->InteriorLight * Dynamic->InteriorLightLevel ) );
|
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( Dynamic->InteriorLight * Dynamic->InteriorLightLevel ) );
|
||||||
}
|
}
|
||||||
// render
|
// render
|
||||||
|
#ifdef EU07_NEW_CAB_RENDERCODE
|
||||||
|
if( true == Alpha ) {
|
||||||
|
// translucent parts
|
||||||
|
Render_Alpha( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// opaque parts
|
||||||
|
Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
|
||||||
|
}
|
||||||
|
#else
|
||||||
Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
|
Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
|
||||||
Render_Alpha( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
|
Render_Alpha( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
|
||||||
|
#endif
|
||||||
// post-render restore
|
// post-render restore
|
||||||
if( Dynamic->fShade > 0.0f ) {
|
if( Dynamic->fShade > 0.0f ) {
|
||||||
// change light level based on light level of the occupied track
|
// change light level based on light level of the occupied track
|
||||||
@@ -2031,7 +2051,7 @@ opengl_renderer::Render( TSubModel *Submodel ) {
|
|||||||
|
|
||||||
if( ( Submodel->iVisible )
|
if( ( Submodel->iVisible )
|
||||||
&& ( TSubModel::fSquareDist >= Submodel->fSquareMinDist )
|
&& ( TSubModel::fSquareDist >= Submodel->fSquareMinDist )
|
||||||
&& ( TSubModel::fSquareDist <= Submodel->fSquareMaxDist ) ) {
|
&& ( TSubModel::fSquareDist < Submodel->fSquareMaxDist ) ) {
|
||||||
|
|
||||||
if( Submodel->iFlags & 0xC000 ) {
|
if( Submodel->iFlags & 0xC000 ) {
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
@@ -2413,8 +2433,8 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ( distancesquared > Node->fSquareRadius )
|
if( ( distancesquared < Node->fSquareMinRadius )
|
||||||
|| ( distancesquared < Node->fSquareMinRadius ) ) {
|
|| ( distancesquared >= Node->fSquareRadius ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2676,7 +2696,7 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
|
|||||||
// renderowanie przezroczystych przez DL
|
// renderowanie przezroczystych przez DL
|
||||||
if( ( Submodel->iVisible )
|
if( ( Submodel->iVisible )
|
||||||
&& ( TSubModel::fSquareDist >= Submodel->fSquareMinDist )
|
&& ( TSubModel::fSquareDist >= Submodel->fSquareMinDist )
|
||||||
&& ( TSubModel::fSquareDist <= Submodel->fSquareMaxDist ) ) {
|
&& ( TSubModel::fSquareDist < Submodel->fSquareMaxDist ) ) {
|
||||||
|
|
||||||
if( Submodel->iFlags & 0xC000 ) {
|
if( Submodel->iFlags & 0xC000 ) {
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ private:
|
|||||||
void
|
void
|
||||||
Render( TTrack *Track );
|
Render( TTrack *Track );
|
||||||
bool
|
bool
|
||||||
Render_cab( TDynamicObject *Dynamic );
|
Render_cab( TDynamicObject *Dynamic, bool const Alpha = false );
|
||||||
void
|
void
|
||||||
Render( TMemCell *Memcell );
|
Render( TMemCell *Memcell );
|
||||||
bool
|
bool
|
||||||
|
|||||||
Reference in New Issue
Block a user