mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 12:09:18 +02:00
merged upstream changes
This commit is contained in:
273
Console.cpp
273
Console.cpp
@@ -114,7 +114,7 @@ int Console::iMode = 0;
|
|||||||
int Console::iConfig = 0;
|
int Console::iConfig = 0;
|
||||||
TPoKeys55 *Console::PoKeys55[2] = {NULL, NULL};
|
TPoKeys55 *Console::PoKeys55[2] = {NULL, NULL};
|
||||||
TLPT *Console::LPT = NULL;
|
TLPT *Console::LPT = NULL;
|
||||||
MWDComm *Console::MWD = NULL; // maciek001: obiekt dla MWD
|
TMWDComm *Console::MWDComm = NULL; // maciek001: obiekt dla MWD
|
||||||
int Console::iSwitch[8]; // bistabilne w kabinie, załączane z [Shift], wyłączane bez
|
int Console::iSwitch[8]; // bistabilne w kabinie, załączane z [Shift], wyłączane bez
|
||||||
int Console::iButton[8]; // monostabilne w kabinie, załączane podczas trzymania klawisza
|
int Console::iButton[8]; // monostabilne w kabinie, załączane podczas trzymania klawisza
|
||||||
|
|
||||||
@@ -126,13 +126,14 @@ Console::Console()
|
|||||||
iSwitch[i] = 0; // bity 0..127 - bez [Ctrl], 128..255 - z [Ctrl]
|
iSwitch[i] = 0; // bity 0..127 - bez [Ctrl], 128..255 - z [Ctrl]
|
||||||
iButton[i] = 0; // bity 0..127 - bez [Shift], 128..255 - z [Shift]
|
iButton[i] = 0; // bity 0..127 - bez [Shift], 128..255 - z [Shift]
|
||||||
}
|
}
|
||||||
|
MWDComm = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
Console::~Console()
|
Console::~Console()
|
||||||
{
|
{
|
||||||
delete PoKeys55[0];
|
delete PoKeys55[0];
|
||||||
delete PoKeys55[1];
|
delete PoKeys55[1];
|
||||||
delete MWD;
|
delete MWDComm;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Console::ModeSet(int m, int h)
|
void Console::ModeSet(int m, int h)
|
||||||
@@ -177,17 +178,20 @@ int Console::On()
|
|||||||
PoKeys55[0] = NULL;
|
PoKeys55[0] = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5: // maciek001: MWD OK
|
}
|
||||||
MWD = new MWDComm();
|
|
||||||
if (!(MWD->Open()))
|
if (Global::bMWDmasterEnable)
|
||||||
{
|
{
|
||||||
delete MWD;
|
WriteLog("Opening ComPort");
|
||||||
iMode = 0;
|
MWDComm = new TMWDComm();
|
||||||
Global::iFeedbackMode = 0;
|
if (!(MWDComm->Open())) // jeżeli nie otwarł portu
|
||||||
WriteLog("COM Port not open!");
|
{
|
||||||
|
WriteLog("ERROR: ComPort is NOT OPEN!");
|
||||||
|
delete MWDComm;
|
||||||
|
MWDComm = NULL;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -206,8 +210,8 @@ void Console::Off()
|
|||||||
PoKeys55[1] = NULL;
|
PoKeys55[1] = NULL;
|
||||||
delete LPT;
|
delete LPT;
|
||||||
LPT = NULL;
|
LPT = NULL;
|
||||||
delete MWD; // maciek001: zamykanie portu COM i takie tam inne ;)
|
delete MWDComm;
|
||||||
MWD = NULL;
|
MWDComm = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Console::BitsSet(int mask, int entry)
|
void Console::BitsSet(int mask, int entry)
|
||||||
@@ -296,103 +300,56 @@ void Console::BitsUpdate(int mask)
|
|||||||
PoKeys55[0]->Write(0x40, 16 - 1, (iBits & 0x4000) ? 1 : 0);
|
PoKeys55[0]->Write(0x40, 16 - 1, (iBits & 0x4000) ? 1 : 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5: // maciek001: MWD lampki i kontrolki
|
|
||||||
/* out3: ogrzewanie sk?adu, opory rozruchowe, poslizg, zaluzjewent, -, -, czuwak, shp
|
|
||||||
out4: stycz.liniowe, pezekaznikróżnicobwpomoc, nadmiarprzetw, roznicowy obw. gł,
|
|
||||||
nadmiarsilniki, wylszybki, zanikprąduprzyjeździenaoporach, nadmiarsprezarki
|
|
||||||
out5: HASLER */
|
|
||||||
if (mask & 0x0001)
|
|
||||||
if (iBits & 1)
|
|
||||||
{
|
|
||||||
MWD->WriteDataBuff[4] |= 1 << 7; // SHP HASLER też
|
|
||||||
if (!MWD->bSHPstate)
|
|
||||||
{
|
|
||||||
MWD->bSHPstate = true;
|
|
||||||
MWD->bPrzejazdSHP = true;
|
|
||||||
}
|
}
|
||||||
else
|
if (Global::bMWDmasterEnable)
|
||||||
MWD->bPrzejazdSHP = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
MWD->WriteDataBuff[4] &= ~(1 << 7);
|
// maciek001: MWDComm lampki i kontrolki
|
||||||
MWD->bPrzejazdSHP = false;
|
// out3: ogrzewanie sk?adu, opory rozruchowe, poslizg, zaluzjewent, -, -, czuwak, shp
|
||||||
MWD->bSHPstate = false;
|
// out4: stycz.liniowe, pezekaznikr??nicobwpomoc, nadmiarprzetw, roznicowy obw. g?, nadmiarsilniki, wylszybki, zanikpr?duprzyje?dzienaoporach, nadmiarsprezarki
|
||||||
|
// out5: HASLER */
|
||||||
|
if (mask & 0x0001) if (iBits & 1) {
|
||||||
|
MWDComm->WriteDataBuff[4] |= 1 << 7; // SHP HASLER też
|
||||||
|
if (!MWDComm->bSHPstate) {
|
||||||
|
MWDComm->bSHPstate = true;
|
||||||
|
MWDComm->bPrzejazdSHP = true;
|
||||||
}
|
}
|
||||||
if (mask & 0x0002)
|
else MWDComm->bPrzejazdSHP = false;
|
||||||
if (iBits & 2)
|
}
|
||||||
MWD->WriteDataBuff[4] |= 1 << 6; // CA
|
else {
|
||||||
else
|
MWDComm->WriteDataBuff[4] &= ~(1 << 7);
|
||||||
MWD->WriteDataBuff[4] &= ~(1 << 6);
|
MWDComm->bPrzejazdSHP = false;
|
||||||
if (mask & 0x0004)
|
MWDComm->bSHPstate = false;
|
||||||
if (iBits & 4)
|
}
|
||||||
MWD->WriteDataBuff[4] |= 1 << 1; // jazda na oporach rozruchowych
|
if (mask & 0x0002) if (iBits & 2) MWDComm->WriteDataBuff[4] |= 1 << 6; // CA
|
||||||
else
|
else MWDComm->WriteDataBuff[4] &= ~(1 << 6);
|
||||||
MWD->WriteDataBuff[4] &= ~(1 << 1);
|
if (mask & 0x0004) if (iBits & 4) MWDComm->WriteDataBuff[4] |= 1 << 1; // jazda na oporach rozruchowych
|
||||||
if (mask & 0x0008)
|
else MWDComm->WriteDataBuff[4] &= ~(1 << 1);
|
||||||
if (iBits & 8)
|
if (mask & 0x0008) if (iBits & 8) MWDComm->WriteDataBuff[5] |= 1 << 5; // wy??cznik szybki
|
||||||
MWD->WriteDataBuff[5] |= 1 << 5; // wyłącznik szybki
|
else MWDComm->WriteDataBuff[5] &= ~(1 << 5);
|
||||||
else
|
if (mask & 0x0010) if (iBits & 0x10) MWDComm->WriteDataBuff[5] |= 1 << 4; // nadmiarowy silnik?w trakcyjnych
|
||||||
MWD->WriteDataBuff[5] &= ~(1 << 5);
|
else MWDComm->WriteDataBuff[5] &= ~(1 << 4);
|
||||||
if (mask & 0x0010)
|
if (mask & 0x0020) if (iBits & 0x20) MWDComm->WriteDataBuff[4] |= 1 << 0; // styczniki liniowe
|
||||||
if (iBits & 0x10)
|
else MWDComm->WriteDataBuff[5] &= ~(1 << 0);
|
||||||
MWD->WriteDataBuff[5] |= 1 << 4; // nadmiarowy silników trakcyjnych
|
if (mask & 0x0040) if (iBits & 0x40) MWDComm->WriteDataBuff[4] |= 1 << 2; // po?lizg
|
||||||
else
|
else MWDComm->WriteDataBuff[4] &= ~(1 << 2);
|
||||||
MWD->WriteDataBuff[5] &= ~(1 << 4);
|
if (mask & 0x0080) if (iBits & 0x80) MWDComm->WriteDataBuff[5] |= 1 << 2; // (nadmiarowy) przetwornicy? ++
|
||||||
if (mask & 0x0020)
|
else MWDComm->WriteDataBuff[5] &= ~(1 << 2);
|
||||||
if (iBits & 0x20)
|
if (mask & 0x0100) if (iBits & 0x100) MWDComm->WriteDataBuff[5] |= 1 << 7; // nadmiarowy spr??arki
|
||||||
MWD->WriteDataBuff[4] |= 1 << 0; // styczniki liniowe
|
else MWDComm->WriteDataBuff[5] &= ~(1 << 7);
|
||||||
else
|
if (mask & 0x0200) if (iBits & 0x200) MWDComm->WriteDataBuff[2] |= 1 << 1; // wentylatory i opory
|
||||||
MWD->WriteDataBuff[5] &= ~(1 << 0);
|
else MWDComm->WriteDataBuff[2] &= ~(1 << 1);
|
||||||
if (mask & 0x0040)
|
if (mask & 0x0400) if (iBits & 0x400) MWDComm->WriteDataBuff[2] |= 1 << 2; // wysoki rozruch
|
||||||
if (iBits & 0x40)
|
else MWDComm->WriteDataBuff[2] &= ~(1 << 2);
|
||||||
MWD->WriteDataBuff[4] |= 1 << 2; // poślizg
|
if (mask & 0x0800) if (iBits & 0x800) MWDComm->WriteDataBuff[4] |= 1 << 0; // ogrzewanie poci?gu
|
||||||
else
|
else MWDComm->WriteDataBuff[4] &= ~(1 << 0);
|
||||||
MWD->WriteDataBuff[4] &= ~(1 << 2);
|
if (mask & 0x1000) if (iBits & 0x1000) MWDComm->bHamowanie = true; // hasler: ci?nienie w hamulcach HASLER rysik 2
|
||||||
if (mask & 0x0080)
|
else MWDComm->bHamowanie = false;
|
||||||
if (iBits & 0x80)
|
if (mask & 0x2000) if (iBits & 0x2000) MWDComm->WriteDataBuff[6] |= 1 << 4; // hasler: pr?d "na" silnikach HASLER rysik 3
|
||||||
MWD->WriteDataBuff[5] |= 1 << 2; // (nadmiarowy) przetwornicy? ++
|
else MWDComm->WriteDataBuff[6] &= ~(1 << 4);
|
||||||
else
|
if (mask & 0x4000) if (iBits & 0x4000) MWDComm->WriteDataBuff[6] |= 1 << 7; // brz?czyk SHP/CA
|
||||||
MWD->WriteDataBuff[5] &= ~(1 << 2);
|
else MWDComm->WriteDataBuff[6] &= ~(1 << 7);
|
||||||
if (mask & 0x0100)
|
//if(mask & 0x8000) if(iBits & 0x8000) MWDComm->WriteDataBuff[1] |= 1<<7; (puste)
|
||||||
if (iBits & 0x100)
|
//else MWDComm->WriteDataBuff[0] &= ~(1<<7);
|
||||||
MWD->WriteDataBuff[5] |= 1 << 7; // nadmiarowy sprężarki
|
|
||||||
else
|
|
||||||
MWD->WriteDataBuff[5] &= ~(1 << 7);
|
|
||||||
if (mask & 0x0200)
|
|
||||||
if (iBits & 0x200)
|
|
||||||
MWD->WriteDataBuff[2] |= 1 << 1; // wentylatory i opory
|
|
||||||
else
|
|
||||||
MWD->WriteDataBuff[2] &= ~(1 << 1);
|
|
||||||
if (mask & 0x0400)
|
|
||||||
if (iBits & 0x400)
|
|
||||||
MWD->WriteDataBuff[2] |= 1 << 2; // wysoki rozruch
|
|
||||||
else
|
|
||||||
MWD->WriteDataBuff[2] &= ~(1 << 2);
|
|
||||||
if (mask & 0x0800)
|
|
||||||
if (iBits & 0x800)
|
|
||||||
MWD->WriteDataBuff[4] |= 1 << 0; // ogrzewanie pociągu
|
|
||||||
else
|
|
||||||
MWD->WriteDataBuff[4] &= ~(1 << 0);
|
|
||||||
if (mask & 0x1000)
|
|
||||||
if (iBits & 0x1000)
|
|
||||||
MWD->bHamowanie = true; // hasler: ciśnienie w hamulcach HASLER rysik 2
|
|
||||||
else
|
|
||||||
MWD->bHamowanie = false;
|
|
||||||
if (mask & 0x2000)
|
|
||||||
if (iBits & 0x2000)
|
|
||||||
MWD->WriteDataBuff[6] |=
|
|
||||||
1 << 4; // hasler: prąd "na" silnikach HASLER rysik 3
|
|
||||||
else
|
|
||||||
MWD->WriteDataBuff[6] &= ~(1 << 4);
|
|
||||||
if (mask & 0x4000)
|
|
||||||
if (iBits & 0x4000)
|
|
||||||
MWD->WriteDataBuff[6] |= 1 << 7; // brzęczyk SHP/CA
|
|
||||||
else
|
|
||||||
MWD->WriteDataBuff[6] &= ~(1 << 7);
|
|
||||||
// if(mask & 0x8000) if(iBits & 0x8000) MWD->WriteDataBuff[1] |= 1<<7; (puste)
|
|
||||||
// else MWD->WriteDataBuff[0] &= ~(1<<7);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -431,60 +388,42 @@ void Console::ValueSet(int x, double y)
|
|||||||
WriteLog(" calibrated=" + std::to_string(temp));
|
WriteLog(" calibrated=" + std::to_string(temp));
|
||||||
PoKeys55[0]->PWM(x, temp);
|
PoKeys55[0]->PWM(x, temp);
|
||||||
}
|
}
|
||||||
if (iMode == 5 && MWD) // pwm-y i prędkość
|
if (Global::bMWDmasterEnable)
|
||||||
{
|
{
|
||||||
unsigned int iliczba;
|
unsigned int iliczba;
|
||||||
if (x == 0)
|
switch (x)
|
||||||
{
|
{
|
||||||
iliczba = (unsigned int)floor((y / (Global::fMWDzg[0] * 10) * Global::fMWDzg[1]) +
|
case 0: iliczba = (unsigned int)floor((y / (Global::fMWDzg[0] * 10) * Global::fMWDzg[1]) + 0.5); // zbiornik g??wny
|
||||||
0.5); // zbiornik główny
|
MWDComm->WriteDataBuff[12] = (unsigned char)(iliczba >> 8);
|
||||||
MWD->WriteDataBuff[12] = (unsigned char)(iliczba >> 8);
|
MWDComm->WriteDataBuff[11] = (unsigned char)iliczba;
|
||||||
MWD->WriteDataBuff[11] = (unsigned char)iliczba;
|
break;
|
||||||
|
case 1: iliczba = (unsigned int)floor((y / (Global::fMWDpg[0] * 10) * Global::fMWDpg[1]) + 0.5); // przew?d g??wny
|
||||||
|
MWDComm->WriteDataBuff[10] = (unsigned char)(iliczba >> 8);
|
||||||
|
MWDComm->WriteDataBuff[9] = (unsigned char)iliczba;
|
||||||
|
break;
|
||||||
|
case 2: iliczba = (unsigned int)floor((y / (Global::fMWDph[0] * 10) * Global::fMWDph[1]) + 0.5); // cylinder hamulcowy
|
||||||
|
MWDComm->WriteDataBuff[8] = (unsigned char)(iliczba >> 8);
|
||||||
|
MWDComm->WriteDataBuff[7] = (unsigned char)iliczba;
|
||||||
|
break;
|
||||||
|
case 3: iliczba = (unsigned int)floor((y / Global::fMWDvolt[0] * Global::fMWDvolt[1]) + 0.5); // woltomierz WN
|
||||||
|
MWDComm->WriteDataBuff[14] = (unsigned char)(iliczba >> 8);
|
||||||
|
MWDComm->WriteDataBuff[13] = (unsigned char)iliczba;
|
||||||
|
break;
|
||||||
|
case 4: iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) + 0.5); // amp WN 1
|
||||||
|
MWDComm->WriteDataBuff[16] = (unsigned char)(iliczba >> 8);
|
||||||
|
MWDComm->WriteDataBuff[15] = (unsigned char)iliczba;
|
||||||
|
break;
|
||||||
|
case 5: iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) + 0.5); // amp WN 2
|
||||||
|
MWDComm->WriteDataBuff[18] = (unsigned char)(iliczba >> 8);
|
||||||
|
MWDComm->WriteDataBuff[17] = (unsigned char)iliczba;
|
||||||
|
break;
|
||||||
|
case 6: iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) + 0.5); // amp WN 3
|
||||||
|
MWDComm->WriteDataBuff[20] = (unsigned int)(iliczba >> 8);
|
||||||
|
MWDComm->WriteDataBuff[19] = (unsigned char)iliczba;
|
||||||
|
break;
|
||||||
|
case 7: MWDComm->WriteDataBuff[0] = (unsigned char)floor(y); // prędkość
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (x == 1)
|
|
||||||
{
|
|
||||||
iliczba = (unsigned int)floor((y / (Global::fMWDpg[0] * 10) * Global::fMWDpg[1]) +
|
|
||||||
0.5); // przewód główny
|
|
||||||
MWD->WriteDataBuff[10] = (unsigned char)(iliczba >> 8);
|
|
||||||
MWD->WriteDataBuff[9] = (unsigned char)iliczba;
|
|
||||||
}
|
|
||||||
else if (x == 2)
|
|
||||||
{
|
|
||||||
iliczba = (unsigned int)floor((y / (Global::fMWDph[0] * 10) * Global::fMWDph[1]) +
|
|
||||||
0.5); // cylinder hamulcowy
|
|
||||||
MWD->WriteDataBuff[8] = (unsigned char)(iliczba >> 8);
|
|
||||||
MWD->WriteDataBuff[7] = (unsigned char)iliczba;
|
|
||||||
}
|
|
||||||
else if (x == 3)
|
|
||||||
{
|
|
||||||
iliczba = (unsigned int)floor((y / Global::fMWDvolt[0] * Global::fMWDvolt[1]) +
|
|
||||||
0.5); // woltomierz WN
|
|
||||||
MWD->WriteDataBuff[14] = (unsigned char)(iliczba >> 8);
|
|
||||||
MWD->WriteDataBuff[13] = (unsigned char)iliczba;
|
|
||||||
}
|
|
||||||
else if (x == 4)
|
|
||||||
{
|
|
||||||
iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) +
|
|
||||||
0.5); // amp WN 1
|
|
||||||
MWD->WriteDataBuff[16] = (unsigned char)(iliczba >> 8);
|
|
||||||
MWD->WriteDataBuff[15] = (unsigned char)iliczba;
|
|
||||||
}
|
|
||||||
else if (x == 5)
|
|
||||||
{
|
|
||||||
iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) +
|
|
||||||
0.5); // amp WN 2
|
|
||||||
MWD->WriteDataBuff[18] = (unsigned char)(iliczba >> 8);
|
|
||||||
MWD->WriteDataBuff[17] = (unsigned char)iliczba;
|
|
||||||
}
|
|
||||||
else if (x == 6)
|
|
||||||
{
|
|
||||||
iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) +
|
|
||||||
0.5); // amp WN 3
|
|
||||||
MWD->WriteDataBuff[20] = (unsigned int)(iliczba >> 8);
|
|
||||||
MWD->WriteDataBuff[19] = (unsigned char)iliczba;
|
|
||||||
}
|
|
||||||
else if (x == 7)
|
|
||||||
MWD->WriteDataBuff[0] = (unsigned char)floor(y); // prędkość
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -503,9 +442,10 @@ void Console::Update()
|
|||||||
Global::iPause |= 8; // tak???
|
Global::iPause |= 8; // tak???
|
||||||
PoKeys55[0]->Connect(); // próba ponownego podłączenia
|
PoKeys55[0]->Connect(); // próba ponownego podłączenia
|
||||||
}
|
}
|
||||||
if (iMode == 5) // Obs?uga MWD OK
|
if (Global::bMWDmasterEnable)
|
||||||
{
|
{
|
||||||
MWD->Run();
|
if (MWDComm->GetMWDState()) MWDComm->Run();
|
||||||
|
else MWDComm->Close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -531,23 +471,18 @@ float Console::AnalogCalibrateGet(int x)
|
|||||||
b +
|
b +
|
||||||
Global::fCalibrateIn[x][0];
|
Global::fCalibrateIn[x][0];
|
||||||
}
|
}
|
||||||
if (iMode == 5 && MWD) // maciek001: obs?uga hamulc?w (wej?? analogowych) OK
|
if (Global::bMWDmasterEnable && Global::bMWDBreakEnable)
|
||||||
{
|
{
|
||||||
float b = MWD->fAnalog[x];
|
float b = (float)MWDComm->uiAnalog[x];
|
||||||
// b =
|
b = (b - Global::fMWDAnalogInCalib[x][0]) / (Global::fMWDAnalogInCalib[x][1] - Global::fMWDAnalogInCalib[x][0]);
|
||||||
// b*(Global::fMWDAnalogCalib[x][0]-Global::fMWDAnalogCalib[x][1])/Global::fMWDAnalogCalib[x][3]+Global::fMWDAnalogCalib[x][1]/Global::fMWDAnalogCalib[x][3];
|
|
||||||
b = (b - Global::fMWDAnalogCalib[x][1]) /
|
|
||||||
(Global::fMWDAnalogCalib[x][1] - Global::fMWDAnalogCalib[x][0]);
|
|
||||||
switch (x)
|
switch (x)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: if (Global::bMWDdebugEnable && Global::iMWDDebugMode & 4) WriteLog("Pozycja kranu = " + to_string(b * 8 - 2));
|
||||||
return (b * 8 - 2);
|
return (b * 8 - 2);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: return (b * 10);
|
||||||
return (b * 10);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default: return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1.0; // odcięcie
|
return -1.0; // odcięcie
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
class TConsoleDevice; // urządzenie podłączalne za pomocą DLL
|
class TConsoleDevice; // urządzenie podłączalne za pomocą DLL
|
||||||
class TPoKeys55;
|
class TPoKeys55;
|
||||||
class TLPT;
|
class TLPT;
|
||||||
class MWDComm; // maciek001: dodana obsluga portu COM
|
class TMWDComm; // maciek001: dodana obsluga portu COM
|
||||||
|
|
||||||
// klasy konwersji znaków wprowadzanych z klawiatury
|
// klasy konwersji znaków wprowadzanych z klawiatury
|
||||||
class TKeyTrans
|
class TKeyTrans
|
||||||
@@ -32,7 +32,7 @@ class Console
|
|||||||
static int iBits; // podstawowy zestaw lampek
|
static int iBits; // podstawowy zestaw lampek
|
||||||
static TPoKeys55 *PoKeys55[2]; // może ich być kilka
|
static TPoKeys55 *PoKeys55[2]; // może ich być kilka
|
||||||
static TLPT *LPT;
|
static TLPT *LPT;
|
||||||
static MWDComm *MWD; // maciek001: na potrzeby MWD
|
static TMWDComm *MWDComm; // maciek001: na potrzeby MWD
|
||||||
static void BitsUpdate(int mask);
|
static void BitsUpdate(int mask);
|
||||||
// zmienne dla trybu "jednokabinowego", potrzebne do współpracy z pulpitem (PoKeys)
|
// zmienne dla trybu "jednokabinowego", potrzebne do współpracy z pulpitem (PoKeys)
|
||||||
// używając klawiatury, każdy pojazd powinien mieć własny stan przełączników
|
// używając klawiatury, każdy pojazd powinien mieć własny stan przełączników
|
||||||
|
|||||||
293
Console/MWD.cpp
293
Console/MWD.cpp
@@ -22,18 +22,15 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define BYTETOWRITE 31 /* ilość bajtów przesyłanych z MaSzyny*/
|
|
||||||
#define BYTETOREAD 16 /* ilość bajtów przesyłanych do MaSzyny*/
|
|
||||||
|
|
||||||
HANDLE hComm;
|
HANDLE hComm;
|
||||||
|
|
||||||
MWDComm::MWDComm() // konstruktor
|
TMWDComm::TMWDComm() // konstruktor
|
||||||
{
|
{
|
||||||
MWDTime = 0;
|
MWDTime = 0;
|
||||||
bSHPstate = false;
|
bSHPstate = false;
|
||||||
bPrzejazdSHP = false;
|
bPrzejazdSHP = false;
|
||||||
bKabina1 = true; // pasuje wyciągnąć dane na temat kabiny i ustawiać te dwa parametry!
|
bKabina1 = true; // pasuje wyciągnąć dane na temat kabiny
|
||||||
bKabina2 = false;
|
bKabina2 = false; // i ustawiać te dwa parametry!
|
||||||
bHamowanie = false;
|
bHamowanie = false;
|
||||||
bCzuwak = false;
|
bCzuwak = false;
|
||||||
|
|
||||||
@@ -47,16 +44,26 @@ MWDComm::MWDComm() // konstruktor
|
|||||||
kierunek = 0;
|
kierunek = 0;
|
||||||
bnkMask = 0;
|
bnkMask = 0;
|
||||||
|
|
||||||
int i = 0;
|
int i = 6;
|
||||||
while (i < BYTETOWRITE)
|
|
||||||
|
while (i)
|
||||||
{
|
{
|
||||||
if (i < BYTETOREAD)
|
i--;
|
||||||
ReadDataBuff[i] = 0;
|
lastStateData[i] = 0;
|
||||||
|
maskData[i] = 0;
|
||||||
|
maskSwitch[i] = 0;
|
||||||
|
bitSwitch[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (i<BYTETOWRITE)
|
||||||
|
{
|
||||||
|
if (i<BYTETOREAD)ReadDataBuff[i] = 0;
|
||||||
WriteDataBuff[i] = 0;
|
WriteDataBuff[i] = 0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < 6)
|
while (i<6)
|
||||||
{
|
{
|
||||||
lastStateData[i] = 0;
|
lastStateData[i] = 0;
|
||||||
maskSwitch[i] = 0;
|
maskSwitch[i] = 0;
|
||||||
@@ -65,12 +72,12 @@ MWDComm::MWDComm() // konstruktor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MWDComm::~MWDComm() // destruktor
|
TMWDComm::~TMWDComm() // destruktor
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWDComm::Open() // otwieranie portu COM
|
bool TMWDComm::Open() // otwieranie portu COM
|
||||||
{
|
{
|
||||||
LPCSTR portId = Global::sMWDPortId.c_str();
|
LPCSTR portId = Global::sMWDPortId.c_str();
|
||||||
hComm = CreateFile(portId, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
|
hComm = CreateFile(portId, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
|
||||||
@@ -124,8 +131,12 @@ bool MWDComm::Open() // otwieranie portu COM
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWDComm::Close() // zamykanie portu COM
|
bool TMWDComm::Close() // zamykanie portu COM
|
||||||
{
|
{
|
||||||
|
Global::bMWDmasterEnable = false; // główne włączenie portu!
|
||||||
|
Global::bMWDInputEnable = false; // włącz wejścia
|
||||||
|
Global::bMWDBreakEnable = false; // włącz wejścia analogowe
|
||||||
|
|
||||||
WriteLog("COM Port is closing...");
|
WriteLog("COM Port is closing...");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < BYTETOWRITE) // zerowanie danych...
|
while (i < BYTETOWRITE) // zerowanie danych...
|
||||||
@@ -141,7 +152,7 @@ bool MWDComm::Close() // zamykanie portu COM
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool MWDComm::GetMWDState() // sprawdzanie otwarcia portu COM
|
bool TMWDComm::GetMWDState() // sprawdzanie otwarcia portu COM
|
||||||
{
|
{
|
||||||
if (hComm > 0)
|
if (hComm > 0)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -149,26 +160,33 @@ inline bool MWDComm::GetMWDState() // sprawdzanie otwarcia portu COM
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWDComm::ReadData() // odbieranie danych + odczyta danych analogowych i zapis do zmiennych
|
bool TMWDComm::ReadData() // odbieranie danych + odczyta danych analogowych i zapis do zmiennych
|
||||||
{
|
{
|
||||||
DWORD bytes_read;
|
DWORD bytes_read;
|
||||||
ReadFile(hComm, &ReadDataBuff[0], BYTETOREAD, &bytes_read, NULL);
|
ReadFile(hComm, &ReadDataBuff[0], BYTETOREAD, &bytes_read, NULL);
|
||||||
|
|
||||||
fAnalog[0] =
|
if (Global::bMWDBreakEnable)
|
||||||
(float)((ReadDataBuff[9] << 8) + ReadDataBuff[8]) /
|
{
|
||||||
Global::fMWDAnalogCalib[0][2]; // 4095.0f; //max wartosc wynikająca z rozdzielczości
|
uiAnalog[0] = (ReadDataBuff[9] << 8) + ReadDataBuff[8];
|
||||||
fAnalog[1] =
|
uiAnalog[1] = (ReadDataBuff[11] << 8) + ReadDataBuff[10];
|
||||||
(float)((ReadDataBuff[11] << 8) + ReadDataBuff[10]) / Global::fMWDAnalogCalib[1][2];
|
uiAnalog[2] = (ReadDataBuff[13] << 8) + ReadDataBuff[12];
|
||||||
fAnalog[2] =
|
uiAnalog[3] = (ReadDataBuff[15] << 8) + ReadDataBuff[14];
|
||||||
(float)((ReadDataBuff[13] << 8) + ReadDataBuff[12]) / Global::fMWDAnalogCalib[2][2];
|
if (Global::bMWDdebugEnable && (Global::iMWDDebugMode & 1))
|
||||||
fAnalog[3] =
|
{
|
||||||
(float)((ReadDataBuff[15] << 8) + ReadDataBuff[14]) / Global::fMWDAnalogCalib[3][2];
|
WriteLog("Main Break = " + to_string(uiAnalog[0]));
|
||||||
CheckData();
|
WriteLog("Locomotiv Break = " + to_string(uiAnalog[1]));
|
||||||
|
}
|
||||||
|
if (Global::bMWDdebugEnable && (Global::iMWDDebugMode & 2))
|
||||||
|
{
|
||||||
|
WriteLog("Analog input 1 = " + to_string(uiAnalog[2]));
|
||||||
|
WriteLog("Analog imput 2 = " + to_string(uiAnalog[3]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Global::bMWDInputEnable) CheckData();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWDComm::SendData() // wysyłanie danych
|
bool TMWDComm::SendData() // wysyłanie danych
|
||||||
{
|
{
|
||||||
DWORD bytes_write;
|
DWORD bytes_write;
|
||||||
DWORD fdwEvtMask;
|
DWORD fdwEvtMask;
|
||||||
@@ -178,29 +196,30 @@ bool MWDComm::SendData() // wysyłanie danych
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWDComm::Run() // wywoływanie obsługi MWD + generacja większego opóźnienia
|
bool TMWDComm::Run() // wywoływanie obsługi MWD + generacja większego opóźnienia
|
||||||
{
|
{
|
||||||
MWDTime++;
|
|
||||||
if (!(MWDTime % 5))
|
|
||||||
{
|
|
||||||
if (GetMWDState())
|
if (GetMWDState())
|
||||||
{
|
{
|
||||||
|
MWDTime++;
|
||||||
|
if (!(MWDTime % Global::iMWDdivider))
|
||||||
|
{
|
||||||
|
MWDTime = 0;
|
||||||
SendData();
|
SendData();
|
||||||
if (Global::bMWDInputDataEnable)
|
|
||||||
ReadData();
|
ReadData();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteLog("Port COM: connection ERROR!");
|
WriteLog("Port COM: connection ERROR!");
|
||||||
|
Close();
|
||||||
// może spróbować się połączyć znowu?
|
// może spróbować się połączyć znowu?
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
MWDTime = 0;
|
return 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWDComm::CheckData() // sprawdzanie wejść cyfrowych i odpowiednie sterowanie maszyną
|
void TMWDComm::CheckData() // sprawdzanie wejść cyfrowych i odpowiednie sterowanie maszyną
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < 6)
|
while (i < 6)
|
||||||
@@ -257,235 +276,185 @@ void MWDComm::CheckData() // sprawdzanie wejść cyfrowych i odpowiednie sterowa
|
|||||||
|
|
||||||
// wciskanie przycisków klawiatury
|
// wciskanie przycisków klawiatury
|
||||||
/*PORT0*/
|
/*PORT0*/
|
||||||
if (maskData[0] & 0x02 && lastStateData[0] & 0x02)
|
if (maskData[0] & 0x02) if (lastStateData[0] & 0x02) KeyBoard('M', 1); // wyłączenie wyłącznika szybkiego
|
||||||
KeyBoard('M', 1); // wyłączenie wyłącznika szybkiego
|
else KeyBoard('M', 0); // monostabilny
|
||||||
else
|
if (maskData[0] & 0x04) if (lastStateData[0] & 0x04) { // impuls załączający wyłącznik szybki
|
||||||
KeyBoard('M', 0); // monostabilny
|
|
||||||
if (maskData[0] & 0x04 && lastStateData[0] & 0x04)
|
|
||||||
{ // impuls załączający wyłącznik szybki
|
|
||||||
KeyBoard(0x10, 1); // monostabilny
|
KeyBoard(0x10, 1); // monostabilny
|
||||||
KeyBoard('M', 1);
|
KeyBoard('M', 1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
KeyBoard('M', 0);
|
KeyBoard('M', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
if (maskData[0] & 0x08 && lastStateData[0] & 0x08)
|
if (maskData[0] & 0x08) if (lastStateData[0] & 0x08) KeyBoard('N', 1); // odblok nadmiarowego silników trakcyjnych
|
||||||
KeyBoard('N', 1); // odblok nadmiarowego silników trakcyjnych
|
else KeyBoard('N', 0); // monostabilny
|
||||||
else
|
if (maskData[0] & 0x20) if (lastStateData[0] & 0x20) { // odblok nadmiarowego przetwornicy, ogrzewania poc.
|
||||||
KeyBoard('N', 0); // monostabilny
|
|
||||||
if (maskData[0] & 0x20 && lastStateData[0] & 0x20)
|
|
||||||
{ // odblok nadmiarowego przetwornicy, ogrzewania poc.
|
|
||||||
KeyBoard(0x11, 1); // różnicowego obwodów pomocniczych
|
KeyBoard(0x11, 1); // różnicowego obwodów pomocniczych
|
||||||
KeyBoard('N', 1); // monostabilny
|
KeyBoard('N', 1); // monostabilny
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
KeyBoard('N', 0);
|
KeyBoard('N', 0);
|
||||||
KeyBoard(0x11, 0);
|
KeyBoard(0x11, 0);
|
||||||
}
|
}
|
||||||
if (maskData[0] & 0x40 && lastStateData[0] & 0x40)
|
if (maskData[0] & 0x40) if (lastStateData[0] & 0x40) KeyBoard('L', 1); // wył. styczników liniowych
|
||||||
KeyBoard('L', 1); // wył. styczników liniowych
|
else KeyBoard('L', 0); // monostabilny
|
||||||
else
|
if (maskData[0] & 0x80) if (lastStateData[0] & 0x80) KeyBoard(0x20, 1); // kasowanie czuwaka/SHP
|
||||||
KeyBoard('L', 0); // monostabilny
|
else KeyBoard(0x20, 0); // kasowanie czuwaka/SHP
|
||||||
if (maskData[0] & 0x80 && lastStateData[0] & 0x80)
|
|
||||||
KeyBoard(0x20, 1); // kasowanie czuwaka/SHP
|
|
||||||
else
|
|
||||||
KeyBoard(0x20, 0); // kasowanie czuwaka/SHP
|
|
||||||
|
|
||||||
/*PORT1*/
|
/*PORT1*/
|
||||||
|
|
||||||
// puszczanie przycisku bistabilnego klawiatury
|
// puszczanie przycisku bistabilnego klawiatury
|
||||||
if (maskSwitch[1] & 0x02)
|
if (maskSwitch[1] & 0x02) {
|
||||||
{
|
if (bitSwitch[1] & 0x02) {
|
||||||
if (bitSwitch[1] & 0x02)
|
|
||||||
{
|
|
||||||
KeyBoard('X', 0);
|
KeyBoard('X', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
else
|
else KeyBoard('X', 0);
|
||||||
KeyBoard('X', 0);
|
|
||||||
maskSwitch[1] &= ~0x02;
|
maskSwitch[1] &= ~0x02;
|
||||||
}
|
}
|
||||||
if (maskSwitch[1] & 0x04)
|
if (maskSwitch[1] & 0x04) {
|
||||||
{
|
if (bitSwitch[1] & 0x04) {
|
||||||
if (bitSwitch[1] & 0x04)
|
|
||||||
{
|
|
||||||
KeyBoard('C', 0);
|
KeyBoard('C', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
else
|
else KeyBoard('C', 0);
|
||||||
KeyBoard('C', 0);
|
|
||||||
maskSwitch[1] &= ~0x04;
|
maskSwitch[1] &= ~0x04;
|
||||||
}
|
}
|
||||||
if (maskSwitch[1] & 0x10)
|
if (maskSwitch[1] & 0x10) {
|
||||||
{
|
if (bitSwitch[1] & 0x10) {
|
||||||
if (bitSwitch[1] & 0x10)
|
|
||||||
{
|
|
||||||
KeyBoard('H', 0);
|
KeyBoard('H', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
else
|
else KeyBoard('H', 0);
|
||||||
KeyBoard('H', 0);
|
|
||||||
maskSwitch[1] &= ~0x10;
|
maskSwitch[1] &= ~0x10;
|
||||||
}
|
}
|
||||||
if (maskSwitch[1] & 0x20 || maskSwitch[1] & 0x40)
|
if (maskSwitch[1] & 0x20 || maskSwitch[1] & 0x40) {
|
||||||
{
|
if (maskSwitch[1] & 0x20) KeyBoard(0x10, 0);
|
||||||
if (maskSwitch[1] & 0x20)
|
if (maskSwitch[1] & 0x40) KeyBoard(0x11, 0);
|
||||||
KeyBoard(0x10, 0);
|
|
||||||
if (maskSwitch[1] & 0x40)
|
|
||||||
KeyBoard(0x11, 0);
|
|
||||||
KeyBoard('B', 0);
|
KeyBoard('B', 0);
|
||||||
maskSwitch[1] &= ~0x60;
|
maskSwitch[1] &= ~0x60;
|
||||||
}
|
}
|
||||||
if (maskSwitch[1] & 0x80)
|
if (maskSwitch[1] & 0x80) {
|
||||||
{
|
if (bitSwitch[1] & 0x80) {
|
||||||
if (bitSwitch[1] & 0x80)
|
|
||||||
{
|
|
||||||
KeyBoard('F', 0);
|
KeyBoard('F', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
else
|
else KeyBoard('F', 0);
|
||||||
KeyBoard('F', 0);
|
|
||||||
maskSwitch[1] &= ~0x80;
|
maskSwitch[1] &= ~0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maskData[1] & 0x02 && lastStateData[1] & 0x02)
|
|
||||||
{ // przetwornica
|
if (maskData[1] & 0x02) if (lastStateData[1] & 0x02) { // przetwornica
|
||||||
KeyBoard(0x10, 1); // bistabilny
|
KeyBoard(0x10, 1); // bistabilny
|
||||||
KeyBoard('X', 1);
|
KeyBoard('X', 1);
|
||||||
maskSwitch[1] |= 0x02;
|
maskSwitch[1] |= 0x02;
|
||||||
bitSwitch[1] |= 0x02;
|
bitSwitch[1] |= 0x02;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
maskSwitch[1] |= 0x02;
|
maskSwitch[1] |= 0x02;
|
||||||
bitSwitch[1] &= ~0x02;
|
bitSwitch[1] &= ~0x02;
|
||||||
KeyBoard('X', 1);
|
KeyBoard('X', 1);
|
||||||
}
|
}
|
||||||
if (maskData[1] & 0x04 && lastStateData[1] & 0x04)
|
if (maskData[1] & 0x04) if (lastStateData[1] & 0x04) { // sprężarka
|
||||||
{ // sprężarka
|
|
||||||
KeyBoard(0x10, 1); // bistabilny
|
KeyBoard(0x10, 1); // bistabilny
|
||||||
KeyBoard('C', 1);
|
KeyBoard('C', 1);
|
||||||
maskSwitch[1] |= 0x04;
|
maskSwitch[1] |= 0x04;
|
||||||
bitSwitch[1] |= 0x04;
|
bitSwitch[1] |= 0x04;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
maskSwitch[1] |= 0x04;
|
maskSwitch[1] |= 0x04;
|
||||||
bitSwitch[1] &= ~0x04;
|
bitSwitch[1] &= ~0x04;
|
||||||
KeyBoard('C', 1);
|
KeyBoard('C', 1);
|
||||||
}
|
}
|
||||||
if (maskData[1] & 0x08 && lastStateData[1] & 0x08)
|
if (maskData[1] & 0x08) if (lastStateData[1] & 0x08) KeyBoard('S', 1); // piasecznica
|
||||||
KeyBoard('S', 1); // piasecznica
|
else KeyBoard('S', 0); // monostabilny
|
||||||
else
|
if (maskData[1] & 0x10) if (lastStateData[1] & 0x10) { // ogrzewanie składu
|
||||||
KeyBoard('S', 0); // monostabilny
|
|
||||||
if (maskData[1] & 0x10 && lastStateData[1] & 0x10)
|
|
||||||
{ // ogrzewanie składu
|
|
||||||
KeyBoard(0x11, 1); // bistabilny
|
KeyBoard(0x11, 1); // bistabilny
|
||||||
KeyBoard('H', 1);
|
KeyBoard('H', 1);
|
||||||
maskSwitch[1] |= 0x10;
|
maskSwitch[1] |= 0x10;
|
||||||
bitSwitch[1] |= 0x10;
|
bitSwitch[1] |= 0x10;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
maskSwitch[1] |= 0x10;
|
maskSwitch[1] |= 0x10;
|
||||||
bitSwitch[1] &= ~0x10;
|
bitSwitch[1] &= ~0x10;
|
||||||
KeyBoard('H', 1);
|
KeyBoard('H', 1);
|
||||||
}
|
}
|
||||||
if (maskData[1] & 0x20 || maskData[1] & 0x40)
|
if (maskData[1] & 0x20 || maskData[1] & 0x40) { // przełącznik hamowania
|
||||||
{ // przełącznik hamowania
|
if (lastStateData[1] & 0x20) { // Shift+B
|
||||||
if (lastStateData[1] & 0x20)
|
|
||||||
{ // Shift+B
|
|
||||||
KeyBoard(0x10, 1);
|
KeyBoard(0x10, 1);
|
||||||
maskSwitch[1] |= 0x20;
|
maskSwitch[1] |= 0x20;
|
||||||
}
|
}
|
||||||
else if (lastStateData[1] & 0x40)
|
else if (lastStateData[1] & 0x40) { // Ctrl+B
|
||||||
{ // Ctrl+B
|
|
||||||
KeyBoard(0x11, 1);
|
KeyBoard(0x11, 1);
|
||||||
maskSwitch[1] |= 0x40;
|
maskSwitch[1] |= 0x40;
|
||||||
}
|
}
|
||||||
KeyBoard('B', 1);
|
KeyBoard('B', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maskData[1] & 0x80 && lastStateData[1] & 0x80)
|
if (maskData[1] & 0x80) if (lastStateData[1] & 0x80) { // rozruch wysoki/niski
|
||||||
{ // rozruch wysoki/niski
|
|
||||||
KeyBoard(0x10, 1); // bistabilny
|
KeyBoard(0x10, 1); // bistabilny
|
||||||
KeyBoard('F', 1);
|
KeyBoard('F', 1);
|
||||||
maskSwitch[1] |= 0x80;
|
maskSwitch[1] |= 0x80;
|
||||||
bitSwitch[1] |= 0x80;
|
bitSwitch[1] |= 0x80;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
maskSwitch[1] |= 0x80;
|
maskSwitch[1] |= 0x80;
|
||||||
bitSwitch[1] &= ~0x80;
|
bitSwitch[1] &= ~0x80;
|
||||||
KeyBoard('F', 1);
|
KeyBoard('F', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PORT2*/
|
|
||||||
|
|
||||||
if (maskSwitch[2] & 0x01)
|
//PORT2
|
||||||
{
|
if (maskSwitch[2] & 0x01) {
|
||||||
if (bitSwitch[2] & 0x01)
|
if (bitSwitch[2] & 0x01) {
|
||||||
{
|
|
||||||
KeyBoard('P', 0);
|
KeyBoard('P', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
else
|
else KeyBoard('P', 0);
|
||||||
KeyBoard('P', 0);
|
|
||||||
maskSwitch[2] &= ~0x01;
|
maskSwitch[2] &= ~0x01;
|
||||||
}
|
}
|
||||||
if (maskSwitch[2] & 0x02)
|
if (maskSwitch[2] & 0x02) {
|
||||||
{
|
if (bitSwitch[2] & 0x02) {
|
||||||
if (bitSwitch[2] & 0x02)
|
|
||||||
{
|
|
||||||
KeyBoard('O', 0);
|
KeyBoard('O', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
else
|
else KeyBoard('O', 0);
|
||||||
KeyBoard('O', 0);
|
|
||||||
maskSwitch[2] &= ~0x02;
|
maskSwitch[2] &= ~0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maskData[2] & 0x01 && lastStateData[2] & 0x01)
|
|
||||||
{ // pantograf przedni
|
if (maskData[2] & 0x01) if (lastStateData[2] & 0x01) { // pantograf przedni
|
||||||
KeyBoard(0x10, 1); // bistabilny
|
KeyBoard(0x10, 1); // bistabilny
|
||||||
KeyBoard('P', 1);
|
KeyBoard('P', 1);
|
||||||
maskSwitch[2] |= 0x01;
|
maskSwitch[2] |= 0x01;
|
||||||
bitSwitch[2] |= 0x01;
|
bitSwitch[2] |= 0x01;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
maskSwitch[2] |= 0x01;
|
maskSwitch[2] |= 0x01;
|
||||||
bitSwitch[2] &= ~0x01;
|
bitSwitch[2] &= ~0x01;
|
||||||
KeyBoard('P', 1);
|
KeyBoard('P', 1);
|
||||||
}
|
}
|
||||||
if (maskData[2] & 0x02 && lastStateData[2] & 0x02)
|
if (maskData[2] & 0x02) if (lastStateData[2] & 0x02) { // pantograf tylni
|
||||||
{ // pantograf tylni
|
|
||||||
KeyBoard(0x10, 1); // bistabilny
|
KeyBoard(0x10, 1); // bistabilny
|
||||||
KeyBoard('O', 1);
|
KeyBoard('O', 1);
|
||||||
maskSwitch[2] |= 0x02;
|
maskSwitch[2] |= 0x02;
|
||||||
bitSwitch[2] |= 0x02;
|
bitSwitch[2] |= 0x02;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
maskSwitch[2] |= 0x02;
|
maskSwitch[2] |= 0x02;
|
||||||
bitSwitch[2] &= ~0x02;
|
bitSwitch[2] &= ~0x02;
|
||||||
KeyBoard('O', 1);
|
KeyBoard('O', 1);
|
||||||
}
|
}
|
||||||
if (maskData[2] & 0x04 && lastStateData[2] & 0x04)
|
if (maskData[2] & 0x04) if (lastStateData[2] & 0x04) { // przyhamowanie przy poślizgu
|
||||||
{ // przyhamowanie przy poślizgu
|
|
||||||
KeyBoard(0x10, 1); // monostabilny
|
KeyBoard(0x10, 1); // monostabilny
|
||||||
KeyBoard(0x0D, 1);
|
KeyBoard(0x0D, 1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
|
|
||||||
KeyBoard(0x0D, 0);
|
KeyBoard(0x0D, 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
/*if(maskData[2] & 0x08 && lastStateData[2] & 0x08){ // przyciemnienie świateł
|
/*if(maskData[2] & 0x08) if (lastStateData[2] & 0x08){ // przyciemnienie świateł
|
||||||
KeyBoard(' ',0); // bistabilny
|
KeyBoard(' ',0); // bistabilny
|
||||||
KeyBoard(0x10,1);
|
KeyBoard(0x10,1);
|
||||||
KeyBoard(' ',1);
|
KeyBoard(' ',1);
|
||||||
@@ -494,7 +463,7 @@ void MWDComm::CheckData() // sprawdzanie wejść cyfrowych i odpowiednie sterowa
|
|||||||
KeyBoard(0x10,0);
|
KeyBoard(0x10,0);
|
||||||
KeyBoard(' ',1);
|
KeyBoard(' ',1);
|
||||||
}
|
}
|
||||||
if(maskData[2] & 0x10 && lastStateData[2] & 0x10) { // przyciemnienie świateł
|
if(maskData[2] & 0x10) if (lastStateData[2] & 0x10) { // przyciemnienie świateł
|
||||||
KeyBoard(' ',0); // bistabilny
|
KeyBoard(' ',0); // bistabilny
|
||||||
KeyBoard(0x11,1);
|
KeyBoard(0x11,1);
|
||||||
KeyBoard(' ',1);
|
KeyBoard(' ',1);
|
||||||
@@ -503,48 +472,38 @@ void MWDComm::CheckData() // sprawdzanie wejść cyfrowych i odpowiednie sterowa
|
|||||||
KeyBoard(0x11,0);
|
KeyBoard(0x11,0);
|
||||||
KeyBoard(' ',1);
|
KeyBoard(' ',1);
|
||||||
}*/
|
}*/
|
||||||
if (maskData[2] & 0x20 && lastStateData[2] & 0x20)
|
if (maskData[2] & 0x20) if (lastStateData[2] & 0x20) KeyBoard(0x66, 1); // odluźniacz
|
||||||
KeyBoard(0x66, 1); // odluźniacz
|
else KeyBoard(0x66, 0); // monostabilny
|
||||||
else
|
if (maskData[2] & 0x40) if (lastStateData[2] & 0x40) { // syrena wysoka
|
||||||
KeyBoard(0x66, 0); // monostabilny
|
|
||||||
if (maskData[2] & 0x40 && lastStateData[2] & 0x40)
|
|
||||||
{ // syrena wysoka
|
|
||||||
KeyBoard(0x10, 1); // monostabilny
|
KeyBoard(0x10, 1); // monostabilny
|
||||||
KeyBoard('A', 1);
|
KeyBoard('A', 1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
KeyBoard('A', 0);
|
KeyBoard('A', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
if (maskData[2] & 0x80 && lastStateData[2] & 0x80)
|
if (maskData[2] & 0x80) if (lastStateData[2] & 0x80) KeyBoard('A', 1); // syrena niska
|
||||||
KeyBoard('A', 1); // syrena niska
|
else KeyBoard('A', 0); // monostabilny
|
||||||
else
|
|
||||||
KeyBoard('A', 0); // monostabilny
|
|
||||||
|
|
||||||
/*PORT3*/
|
|
||||||
|
|
||||||
if (maskSwitch[3] & 0x01)
|
//PORT3
|
||||||
{
|
|
||||||
if (bitSwitch[3] & 0x01)
|
if (maskSwitch[3] & 0x01) {
|
||||||
{
|
if (bitSwitch[3] & 0x01) {
|
||||||
KeyBoard('J', 0);
|
KeyBoard('J', 0);
|
||||||
KeyBoard(0x10, 0);
|
KeyBoard(0x10, 0);
|
||||||
}
|
}
|
||||||
else
|
else KeyBoard('J', 0);
|
||||||
KeyBoard('J', 0);
|
|
||||||
maskSwitch[3] &= ~0x01;
|
maskSwitch[3] &= ~0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maskData[3] & 0x01 && lastStateData[3] & 0x01)
|
if (maskData[3] & 0x01) if (lastStateData[3] & 0x01) { // bateria
|
||||||
{ // bateria
|
|
||||||
KeyBoard(0x10, 1); // bistabilny
|
KeyBoard(0x10, 1); // bistabilny
|
||||||
KeyBoard('J', 1);
|
KeyBoard('J', 1);
|
||||||
maskSwitch[3] |= 0x01;
|
maskSwitch[3] |= 0x01;
|
||||||
bitSwitch[3] |= 0x01;
|
bitSwitch[3] |= 0x01;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
maskSwitch[3] |= 0x01;
|
maskSwitch[3] |= 0x01;
|
||||||
bitSwitch[3] &= ~0x01;
|
bitSwitch[3] &= ~0x01;
|
||||||
KeyBoard('J', 1);
|
KeyBoard('J', 1);
|
||||||
@@ -790,7 +749,7 @@ void MWDComm::CheckData() // sprawdzanie wejść cyfrowych i odpowiednie sterowa
|
|||||||
WriteDataBuff[6] &= ~(1 << 3);
|
WriteDataBuff[6] &= ~(1 << 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWDComm::KeyBoard(int key, bool s) // emulacja klawiatury
|
void TMWDComm::KeyBoard(int key, bool s) // emulacja klawiatury
|
||||||
{
|
{
|
||||||
INPUT ip;
|
INPUT ip;
|
||||||
// Set up a generic keyboard event.
|
// Set up a generic keyboard event.
|
||||||
|
|||||||
@@ -19,28 +19,33 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#define MWDH
|
#define MWDH
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define BYTETOWRITE 31 // ilość bajtów przesyłanych z MaSzyny
|
||||||
|
#define BYTETOREAD 16 // ilość bajtów przesyłanych do MaSzyny
|
||||||
|
|
||||||
typedef unsigned char BYTE;
|
typedef unsigned char BYTE;
|
||||||
typedef unsigned long DWORD;
|
typedef unsigned long DWORD;
|
||||||
|
|
||||||
class MWDComm
|
class TMWDComm
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int MWDTime; //
|
int MWDTime; //
|
||||||
char lastStateData[6], maskData[6], maskSwitch[6], bitSwitch[6];
|
char lastStateData[6], maskData[6], maskSwitch[6], bitSwitch[6];
|
||||||
int bocznik, nastawnik, kierunek;
|
int bocznik, nastawnik, kierunek;
|
||||||
char bnkMask;
|
char bnkMask;
|
||||||
|
|
||||||
bool ReadData(); // BYTE *pReadDataBuff);
|
bool ReadData(); //BYTE *pReadDataBuff);
|
||||||
bool SendData(); // BYTE *pWriteDataBuff);
|
bool SendData(); //BYTE *pWriteDataBuff);
|
||||||
void CheckData(); // sprawdzanie zmian wejść i kontrola mazaków HASLERA
|
void CheckData(); //sprawdzanie zmian wejść i kontrola mazaków HASLERA
|
||||||
void KeyBoard(int key, bool s);
|
void KeyBoard(int key, bool s);
|
||||||
|
|
||||||
|
//void CheckData2();
|
||||||
|
|
||||||
bool bRysik1H;
|
bool bRysik1H;
|
||||||
bool bRysik1L;
|
bool bRysik1L;
|
||||||
bool bRysik2H;
|
bool bRysik2H;
|
||||||
bool bRysik2L;
|
bool bRysik2L;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Open(); // Otwarcie portu
|
bool Open(); // Otwarcie portu
|
||||||
bool Close(); // Zamknięcie portu
|
bool Close(); // Zamknięcie portu
|
||||||
bool Run(); // Obsługa portu
|
bool Run(); // Obsługa portu
|
||||||
@@ -54,13 +59,13 @@ class MWDComm
|
|||||||
bool bHamowanie;
|
bool bHamowanie;
|
||||||
bool bCzuwak;
|
bool bCzuwak;
|
||||||
|
|
||||||
float fAnalog[4]; // trzymanie danych z wejść analogowych
|
unsigned int uiAnalog[4]; // trzymanie danych z wejść analogowych
|
||||||
|
|
||||||
BYTE ReadDataBuff[17]; // bufory danych
|
BYTE ReadDataBuff[BYTETOREAD]; //17]; // bufory danych
|
||||||
BYTE WriteDataBuff[31];
|
BYTE WriteDataBuff[BYTETOWRITE]; //31];
|
||||||
|
|
||||||
MWDComm(); // konstruktor
|
TMWDComm(); // konstruktor
|
||||||
~MWDComm(); // destruktor
|
~TMWDComm(); // destruktor
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1171,6 +1171,10 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
|||||||
iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest
|
iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest
|
||||||
d_to_next_sem = Min0R(sSpeedTable[i].fDist, d_to_next_sem);
|
d_to_next_sem = Min0R(sSpeedTable[i].fDist, d_to_next_sem);
|
||||||
}
|
}
|
||||||
|
if( sSpeedTable[ i ].fDist <= d_to_next_sem )
|
||||||
|
{
|
||||||
|
VelSignalNext = sSpeedTable[ i ].fVelNext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (sSpeedTable[i].iFlags & spRoadVel)
|
else if (sSpeedTable[i].iFlags & spRoadVel)
|
||||||
{ // to W6
|
{ // to W6
|
||||||
|
|||||||
32
DynObj.cpp
32
DynObj.cpp
@@ -3100,7 +3100,11 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
dDOMoveLen =
|
dDOMoveLen =
|
||||||
GetdMoveLen() + MoverParameters->ComputeMovement(dt, dt1, ts, tp, tmpTraction, l, r);
|
GetdMoveLen() + MoverParameters->ComputeMovement(dt, dt1, ts, tp, tmpTraction, l, r);
|
||||||
// yB: zeby zawsze wrzucalo w jedna strone zakretu
|
// yB: zeby zawsze wrzucalo w jedna strone zakretu
|
||||||
|
/*
|
||||||
|
// this seemed to have opposite effect, if anything -- the sway direction would be affected
|
||||||
|
// by the 'direction' of the track, making the sway go sometimes inward, sometimes outward
|
||||||
MoverParameters->AccN *= -ABuGetDirection();
|
MoverParameters->AccN *= -ABuGetDirection();
|
||||||
|
*/
|
||||||
// if (dDOMoveLen!=0.0) //Ra: nie może być, bo blokuje Event0
|
// if (dDOMoveLen!=0.0) //Ra: nie może być, bo blokuje Event0
|
||||||
Move(dDOMoveLen);
|
Move(dDOMoveLen);
|
||||||
if (!bEnabled) // usuwane pojazdy nie mają toru
|
if (!bEnabled) // usuwane pojazdy nie mają toru
|
||||||
@@ -3530,24 +3534,24 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
// NBMX Obsluga drzwi, MC: zuniwersalnione
|
// NBMX Obsluga drzwi, MC: zuniwersalnione
|
||||||
if ((dDoorMoveL < MoverParameters->DoorMaxShiftL) && (MoverParameters->DoorLeftOpened))
|
if ((dDoorMoveL < MoverParameters->DoorMaxShiftL) && (MoverParameters->DoorLeftOpened))
|
||||||
{
|
{
|
||||||
rsDoorOpen.Play(vol, 0, MechInside, vPosition);
|
rsDoorOpen.Play(1, 0, MechInside, vPosition);
|
||||||
dDoorMoveL += dt1 * 0.5 * MoverParameters->DoorOpenSpeed;
|
dDoorMoveL += dt1 * 0.5 * MoverParameters->DoorOpenSpeed;
|
||||||
}
|
}
|
||||||
if ((dDoorMoveL > 0) && (!MoverParameters->DoorLeftOpened))
|
if ((dDoorMoveL > 0) && (!MoverParameters->DoorLeftOpened))
|
||||||
{
|
{
|
||||||
rsDoorClose.Play(vol, 0, MechInside, vPosition);
|
rsDoorClose.Play(1, 0, MechInside, vPosition);
|
||||||
dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed;
|
dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed;
|
||||||
if (dDoorMoveL < 0)
|
if (dDoorMoveL < 0)
|
||||||
dDoorMoveL = 0;
|
dDoorMoveL = 0;
|
||||||
}
|
}
|
||||||
if ((dDoorMoveR < MoverParameters->DoorMaxShiftR) && (MoverParameters->DoorRightOpened))
|
if ((dDoorMoveR < MoverParameters->DoorMaxShiftR) && (MoverParameters->DoorRightOpened))
|
||||||
{
|
{
|
||||||
rsDoorOpen.Play(vol, 0, MechInside, vPosition);
|
rsDoorOpen.Play(1, 0, MechInside, vPosition);
|
||||||
dDoorMoveR += dt1 * 0.5 * MoverParameters->DoorOpenSpeed;
|
dDoorMoveR += dt1 * 0.5 * MoverParameters->DoorOpenSpeed;
|
||||||
}
|
}
|
||||||
if ((dDoorMoveR > 0) && (!MoverParameters->DoorRightOpened))
|
if ((dDoorMoveR > 0) && (!MoverParameters->DoorRightOpened))
|
||||||
{
|
{
|
||||||
rsDoorClose.Play(vol, 0, MechInside, vPosition);
|
rsDoorClose.Play(1, 0, MechInside, vPosition);
|
||||||
dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed;
|
dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed;
|
||||||
if (dDoorMoveR < 0)
|
if (dDoorMoveR < 0)
|
||||||
dDoorMoveR = 0;
|
dDoorMoveR = 0;
|
||||||
@@ -3706,7 +3710,7 @@ void TDynamicObject::Render()
|
|||||||
// zmienne
|
// zmienne
|
||||||
renderme = false;
|
renderme = false;
|
||||||
// przeklejka
|
// przeklejka
|
||||||
double ObjSqrDist = SquareMagnitude(Global::pCameraPosition - vPosition);
|
double ObjSqrDist = SquareMagnitude(Global::pCameraPosition - vPosition) / Global::ZoomFactor;
|
||||||
// koniec przeklejki
|
// koniec przeklejki
|
||||||
if (ObjSqrDist < 500) // jak jest blisko - do 70m
|
if (ObjSqrDist < 500) // jak jest blisko - do 70m
|
||||||
modelrotate = 0.01; // mały kąt, żeby nie znikało
|
modelrotate = 0.01; // mały kąt, żeby nie znikało
|
||||||
@@ -3733,7 +3737,7 @@ void TDynamicObject::Render()
|
|||||||
{
|
{
|
||||||
TSubModel::iInstance = (int)this; //żeby nie robić cudzych animacji
|
TSubModel::iInstance = (int)this; //żeby nie robić cudzych animacji
|
||||||
// AnsiString asLoadName="";
|
// AnsiString asLoadName="";
|
||||||
double ObjSqrDist = SquareMagnitude(Global::pCameraPosition - vPosition);
|
double ObjSqrDist = SquareMagnitude(Global::pCameraPosition - vPosition) / Global::ZoomFactor;
|
||||||
ABuLittleUpdate(ObjSqrDist); // ustawianie zmiennych submodeli dla wspólnego modelu
|
ABuLittleUpdate(ObjSqrDist); // ustawianie zmiennych submodeli dla wspólnego modelu
|
||||||
|
|
||||||
// Cone(vCoulpler[0],modelRot.z,0);
|
// Cone(vCoulpler[0],modelRot.z,0);
|
||||||
@@ -5322,10 +5326,6 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
token, 50,
|
token, 50,
|
||||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||||
true );
|
true );
|
||||||
sPantUp.AM = 50000;
|
|
||||||
sPantUp.AA = -1 * ( 105 - Random( 10 ) ) / 100;
|
|
||||||
sPantUp.FM = 1.0;
|
|
||||||
sPantUp.FA = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( token == "pantographdown:" ) {
|
else if( token == "pantographdown:" ) {
|
||||||
@@ -5335,10 +5335,6 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
token, 50,
|
token, 50,
|
||||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||||
true );
|
true );
|
||||||
sPantDown.AM = 50000;
|
|
||||||
sPantDown.AA = -1 * ( 105 - Random( 10 ) ) / 100;
|
|
||||||
sPantDown.FM = 1.0;
|
|
||||||
sPantDown.FA = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( token == "compressor:" ) {
|
else if( token == "compressor:" ) {
|
||||||
@@ -5369,10 +5365,6 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
token, 50,
|
token, 50,
|
||||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||||
true );
|
true );
|
||||||
rsDoorOpen.AM = 50000;
|
|
||||||
rsDoorOpen.AA = -1 * ( 105 - Random( 10 ) ) / 100;
|
|
||||||
rsDoorOpen.FM = 1.0;
|
|
||||||
rsDoorOpen.FA = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( token == "doorclose:" ) {
|
else if( token == "doorclose:" ) {
|
||||||
@@ -5382,10 +5374,6 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
token, 50,
|
token, 50,
|
||||||
GetPosition().x, GetPosition().y, GetPosition().z,
|
GetPosition().x, GetPosition().y, GetPosition().z,
|
||||||
true );
|
true );
|
||||||
rsDoorClose.AM = 50000;
|
|
||||||
rsDoorClose.AA = -1 * ( 105 - Random( 10 ) ) / 100;
|
|
||||||
rsDoorClose.FM = 1.0;
|
|
||||||
rsDoorClose.FA = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( token == "sand:" ) {
|
else if( token == "sand:" ) {
|
||||||
|
|||||||
6
EU07.cpp
6
EU07.cpp
@@ -85,17 +85,19 @@ int InitGL(GLvoid) // All Setup For OpenGL Goes Here
|
|||||||
|
|
||||||
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // resize and initialize the GL Window
|
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // resize and initialize the GL Window
|
||||||
{
|
{
|
||||||
WindowWidth = width;
|
Global::ScreenWidth = WindowWidth = width;
|
||||||
WindowHeight = height;
|
Global::ScreenHeight = WindowHeight = height;
|
||||||
if (height == 0) // prevent a divide by zero by
|
if (height == 0) // prevent a divide by zero by
|
||||||
height = 1; // making height equal one
|
height = 1; // making height equal one
|
||||||
glViewport(0, 0, width, height); // Reset The Current Viewport
|
glViewport(0, 0, width, height); // Reset The Current Viewport
|
||||||
|
/*
|
||||||
glMatrixMode(GL_PROJECTION); // select the Projection Matrix
|
glMatrixMode(GL_PROJECTION); // select the Projection Matrix
|
||||||
glLoadIdentity(); // reset the Projection Matrix
|
glLoadIdentity(); // reset the Projection Matrix
|
||||||
// calculate the aspect ratio of the window
|
// calculate the aspect ratio of the window
|
||||||
gluPerspective(45.0f, (GLdouble)width / (GLdouble)height, 0.2f, 2500.0f);
|
gluPerspective(45.0f, (GLdouble)width / (GLdouble)height, 0.2f, 2500.0f);
|
||||||
glMatrixMode(GL_MODELVIEW); // select the Modelview Matrix
|
glMatrixMode(GL_MODELVIEW); // select the Modelview Matrix
|
||||||
glLoadIdentity(); // reset the Modelview Matrix
|
glLoadIdentity(); // reset the Modelview Matrix
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
18
Gauge.cpp
18
Gauge.cpp
@@ -175,14 +175,16 @@ void TGauge::Update()
|
|||||||
*/ std::string n( "000000000" + std::to_string( static_cast<int>( std::floor( fValue ) ) ) );
|
*/ std::string n( "000000000" + std::to_string( static_cast<int>( std::floor( fValue ) ) ) );
|
||||||
if( n.length() > 10 ) { n.erase( 0, n.length() - 10 ); } // also dumb but should work for now
|
if( n.length() > 10 ) { n.erase( 0, n.length() - 10 ); } // also dumb but should work for now
|
||||||
do
|
do
|
||||||
{ // pętla po submodelach potomnych i obracanie ich o kąt zależy od
|
{ // pętla po submodelach potomnych i obracanie ich o kąt zależy od cyfry w (fValue)
|
||||||
// cyfry w (fValue)
|
if( sm->pName ) {
|
||||||
if (sm->pName)
|
// musi mieć niepustą nazwę
|
||||||
{ // musi mieć niepustą nazwę
|
if( ( sm->pName[ 0 ] >= '0' )
|
||||||
if (sm->pName[0] >= '0')
|
&& ( sm->pName[ 0 ] <= '9' ) ) {
|
||||||
if (sm->pName[0] <= '9')
|
|
||||||
sm->SetRotate(float3(0, 1, 0),
|
sm->SetRotate(
|
||||||
-36.0 * (n['0' + 10 - sm->pName[0]] - '0'));
|
float3( 0, 1, 0 ),
|
||||||
|
-36.0 * ( n[ '0' + 9 - sm->pName[ 0 ] ] - '0' ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sm = sm->NextGet();
|
sm = sm->NextGet();
|
||||||
} while (sm);
|
} while (sm);
|
||||||
|
|||||||
162
Globals.cpp
162
Globals.cpp
@@ -49,6 +49,10 @@ bool Global::bOpenGL_1_5 = false; // czy są dostępne funkcje OpenGL 1.5
|
|||||||
double Global::fLuminance = 1.0; // jasność światła do automatycznego zapalania
|
double Global::fLuminance = 1.0; // jasność światła do automatycznego zapalania
|
||||||
int Global::iReCompile = 0; // zwiększany, gdy trzeba odświeżyć siatki
|
int Global::iReCompile = 0; // zwiększany, gdy trzeba odświeżyć siatki
|
||||||
HWND Global::hWnd = NULL; // uchwyt okna
|
HWND Global::hWnd = NULL; // uchwyt okna
|
||||||
|
int Global::ScreenWidth = 1;
|
||||||
|
int Global::ScreenHeight = 1;
|
||||||
|
float Global::ZoomFactor = 1.0f;
|
||||||
|
float Global::FieldOfView = 45.0f;
|
||||||
int Global::iCameraLast = -1;
|
int Global::iCameraLast = -1;
|
||||||
std::string Global::asRelease = "16.0.1172.482";
|
std::string Global::asRelease = "16.0.1172.482";
|
||||||
std::string Global::asVersion =
|
std::string Global::asVersion =
|
||||||
@@ -134,6 +138,7 @@ bool Global::bAdjustScreenFreq = true;
|
|||||||
bool Global::bEnableTraction = true;
|
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
|
||||||
int Global::iDefaultFiltering = 9; // domyślne rozmywanie tekstur TGA bez alfa
|
int Global::iDefaultFiltering = 9; // domyślne rozmywanie tekstur TGA bez alfa
|
||||||
int Global::iBallastFiltering = 9; // domyślne rozmywanie tekstur podsypki
|
int Global::iBallastFiltering = 9; // domyślne rozmywanie tekstur podsypki
|
||||||
int Global::iRailProFiltering = 5; // domyślne rozmywanie tekstur szyn
|
int Global::iRailProFiltering = 5; // domyślne rozmywanie tekstur szyn
|
||||||
@@ -195,17 +200,20 @@ int Global::iBpp = 32; // chyba już nie używa się kart, na których 16bpp co
|
|||||||
//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
|
||||||
bool Global::bMWDdebugEnable = false;
|
bool Global::bMWDmasterEnable = false; // główne włączenie portu!
|
||||||
bool Global::bMWDInputDataEnable = false;
|
bool Global::bMWDdebugEnable = false; // włącz dodawanie do logu
|
||||||
unsigned int Global::iMWDBaudrate = 500000;
|
int Global::iMWDDebugMode = 0; // co ma wyświetlać w logu
|
||||||
std::string Global::sMWDPortId = "COM1"; // nazwa portu z którego korzystamy - na razie nie działa
|
std::string Global::sMWDPortId = "COM1"; // nazwa portu z którego korzystamy
|
||||||
bool Global::bMWDBreakEnable = false; // zmienić na FALSE!!! jak już będzie działać wczytywanie z *.ini
|
unsigned long int Global::iMWDBaudrate = 9600; // prędkość transmisji danych
|
||||||
double Global::fMWDAnalogCalib[4][3] = {{1023, 0, 1023},{1023, 0, 1023},{1023, 0, 1023},{1023, 0, 1023}}; // wartość max potencjometru, wartość min potencjometru, rozdzielczość (max. wartość jaka może być -1)
|
bool Global::bMWDInputEnable = false; // włącz wejścia
|
||||||
double Global::fMWDzg[2] = {0.9, 1023};
|
bool Global::bMWDBreakEnable = false; // włącz wejścia analogowe
|
||||||
double Global::fMWDpg[2] = {0.8, 1023};
|
double Global::fMWDAnalogInCalib[4][2] = { { 0, 1023 },{ 0, 1023 },{ 0, 1023 },{ 0, 1023 } }; // wartość max potencjometru, wartość min potencjometru, rozdzielczość (max. wartość jaka może być)
|
||||||
double Global::fMWDph[2] = {0.6, 1023};
|
double Global::fMWDzg[2] = { 0.9, 1023 };
|
||||||
double Global::fMWDvolt[2] = {4000, 1023};
|
double Global::fMWDpg[2] = { 0.8, 1023 };
|
||||||
double Global::fMWDamp[2] = {800, 1023};
|
double Global::fMWDph[2] = { 0.6, 1023 };
|
||||||
|
double Global::fMWDvolt[2] = { 4000, 1023 };
|
||||||
|
double Global::fMWDamp[2] = { 800, 1023 };
|
||||||
|
int Global::iMWDdivider = 5;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -258,6 +266,14 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> Global::asHumanCtrlVehicle;
|
Parser >> Global::asHumanCtrlVehicle;
|
||||||
}
|
}
|
||||||
|
else if( token == "fieldofview" ) {
|
||||||
|
|
||||||
|
Parser.getTokens( 1, false );
|
||||||
|
Parser >> Global::FieldOfView;
|
||||||
|
// guard against incorrect values
|
||||||
|
Global::FieldOfView = std::min( 75.0f, Global::FieldOfView );
|
||||||
|
Global::FieldOfView = std::max( 15.0f, Global::FieldOfView );
|
||||||
|
}
|
||||||
else if (token == "width")
|
else if (token == "width")
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -466,7 +482,12 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser.getTokens(1, false);
|
Parser.getTokens(1, false);
|
||||||
Parser >> Global::iDynamicFiltering;
|
Parser >> Global::iDynamicFiltering;
|
||||||
}
|
}
|
||||||
else if (token == "usevbo")
|
else if( token == "anisotropicfiltering" ) {
|
||||||
|
|
||||||
|
Parser.getTokens( 1, false );
|
||||||
|
Parser >> Global::AnisotropicFiltering;
|
||||||
|
}
|
||||||
|
else if( token == "usevbo" )
|
||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
@@ -799,92 +820,99 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
>> Global::Background[2]; // b
|
>> Global::Background[2]; // b
|
||||||
}
|
}
|
||||||
// maciek001: ustawienia MWD
|
// maciek001: ustawienia MWD
|
||||||
else if (token == "mwddebug")
|
else if (token == "mwdmasterenable") { // główne włączenie maszyny!
|
||||||
{ // czy włączyć obslugę hamulców
|
Parser.getTokens();
|
||||||
|
Parser >> token;
|
||||||
|
bMWDmasterEnable = (token == "yes");
|
||||||
|
if (bMWDdebugEnable) WriteLog("SerialPort Master Enable");
|
||||||
|
}
|
||||||
|
else if (token == "mwddebugenable") { // logowanie pracy
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> token;
|
||||||
bMWDdebugEnable = (token == "yes");
|
bMWDdebugEnable = (token == "yes");
|
||||||
|
if (bMWDdebugEnable) WriteLog("MWD Debug Mode On");
|
||||||
}
|
}
|
||||||
else if (token == "comportname")
|
else if (token == "mwddebugmode") { // co ma być debugowane?
|
||||||
{
|
Parser.getTokens(1, false);
|
||||||
|
Parser >> iMWDDebugMode;
|
||||||
|
if (bMWDdebugEnable) WriteLog("Debug Mode = " + to_string(iMWDDebugMode));
|
||||||
|
}
|
||||||
|
else if (token == "mwdcomportname") { // nazwa portu COM
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> sMWDPortId;
|
Parser >> sMWDPortId;
|
||||||
if (bMWDdebugEnable)
|
if (bMWDdebugEnable) WriteLog("PortName " + sMWDPortId);
|
||||||
WriteLog("PortName " + sMWDPortId);
|
|
||||||
}
|
}
|
||||||
else if (token == "mwdbaudrate")
|
else if (token == "mwdbaudrate") { // prędkość transmisji danych
|
||||||
{ // pobierz prędkość transmisji danych
|
|
||||||
Parser.getTokens(1, false);
|
Parser.getTokens(1, false);
|
||||||
Parser >> iMWDBaudrate;
|
Parser >> iMWDBaudrate;
|
||||||
if (bMWDdebugEnable)
|
if (bMWDdebugEnable) WriteLog("Baud rate = " + to_string((int)(iMWDBaudrate / 1000)) + (" kbps"));
|
||||||
WriteLog("PortName " + to_string(iMWDBaudrate));
|
|
||||||
}
|
}
|
||||||
else if (token == "mwdbreakenable")
|
else if (token == "mwdinputenable") { // włącz wejścia
|
||||||
{ // czy włączyć obsługę hamulców
|
Parser.getTokens();
|
||||||
|
Parser >> token;
|
||||||
|
bMWDInputEnable = (token == "yes");
|
||||||
|
if (bMWDdebugEnable && bMWDInputEnable) WriteLog("MWD Input Enable");
|
||||||
|
}
|
||||||
|
else if (token == "mwdbreakenable") { // włącz obsługę hamulców
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> token;
|
||||||
bMWDBreakEnable = (token == "yes");
|
bMWDBreakEnable = (token == "yes");
|
||||||
|
if (bMWDdebugEnable && bMWDBreakEnable) WriteLog("MWD Break Enable");
|
||||||
}
|
}
|
||||||
else if (token == "mwdinputenable")
|
else if (token == "mwdmainbreakconfig") { // ustawienia hamulca zespolonego
|
||||||
{
|
Parser.getTokens(2, false);
|
||||||
Parser.getTokens();
|
Parser >> fMWDAnalogInCalib[0][0] >> fMWDAnalogInCalib[0][1];
|
||||||
Parser >> token;
|
if (bMWDdebugEnable) WriteLog("Main break settings: " + to_string(fMWDAnalogInCalib[0][0]) + (" ") + to_string(fMWDAnalogInCalib[0][1]));
|
||||||
bMWDInputDataEnable = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "mwdbreak") // wartość max dla potencjometru hamulca zasadniczego
|
else if (token == "mwdlocbreakconfig") { // ustawienia hamulca lokomotywy
|
||||||
{
|
Parser.getTokens(2, false);
|
||||||
Parser.getTokens();
|
Parser >> fMWDAnalogInCalib[1][0] >> fMWDAnalogInCalib[1][1];
|
||||||
Parser >> token;
|
if (bMWDdebugEnable) WriteLog("Locomotive break settings: " + to_string(fMWDAnalogInCalib[1][0]) + (" ") + to_string(fMWDAnalogInCalib[1][1]));
|
||||||
int i = stol_def(token, -1); // numer wej�cia
|
|
||||||
if ((i >= 0) && (i <= 3))
|
|
||||||
{
|
|
||||||
Parser.getTokens(3, false);
|
|
||||||
Parser >> fMWDAnalogCalib[i][0] // max -> 2^16 -1
|
|
||||||
>> fMWDAnalogCalib[i][1] // min -> 0
|
|
||||||
>>
|
|
||||||
fMWDAnalogCalib[i][2]; // rozdzielczość -> 255 maksymalna możliwa wartość z ADC
|
|
||||||
if (bMWDdebugEnable)
|
|
||||||
WriteLog("Break settings " + to_string(i) + ": " +
|
|
||||||
to_string(fMWDAnalogCalib[i][0]) + " " +
|
|
||||||
to_string(fMWDAnalogCalib[i][1]) + " " +
|
|
||||||
to_string(fMWDAnalogCalib[i][2]));
|
|
||||||
}
|
}
|
||||||
|
else if (token == "mwdanalogin1config") { // ustawienia hamulca zespolonego
|
||||||
|
Parser.getTokens(2, false);
|
||||||
|
Parser >> fMWDAnalogInCalib[2][0] >> fMWDAnalogInCalib[2][1];
|
||||||
|
if (bMWDdebugEnable) WriteLog("Analog input 1 settings: " + to_string(fMWDAnalogInCalib[2][0]) + (" ") + to_string(fMWDAnalogInCalib[2][1]));
|
||||||
}
|
}
|
||||||
else if (token == "mwdzbiornikglowny")
|
else if (token == "mwdanalogin2config") { // ustawienia hamulca lokomotywy
|
||||||
{
|
Parser.getTokens(2, false);
|
||||||
|
Parser >> fMWDAnalogInCalib[3][0] >> fMWDAnalogInCalib[3][1];
|
||||||
|
if (bMWDdebugEnable) WriteLog("Analog input 2 settings: " + to_string(fMWDAnalogInCalib[3][0]) + (" ") + to_string(fMWDAnalogInCalib[3][1]));
|
||||||
|
}
|
||||||
|
else if (token == "mwdmaintankpress") { // max ciśnienie w zbiorniku głownym i rozdzielczość
|
||||||
Parser.getTokens(2, false);
|
Parser.getTokens(2, false);
|
||||||
Parser >> fMWDzg[0] >> fMWDzg[1];
|
Parser >> fMWDzg[0] >> fMWDzg[1];
|
||||||
if (bMWDdebugEnable)
|
if (bMWDdebugEnable) WriteLog("MainAirTank settings: " + to_string(fMWDzg[0]) + (" ") + to_string(fMWDzg[1]));
|
||||||
WriteLog("AirTank settings: " + to_string(fMWDzg[0]) + " " + to_string(fMWDzg[1]));
|
|
||||||
}
|
}
|
||||||
else if (token == "mwdprzewodglowny")
|
else if (token == "mwdmainpipepress") { // max ciśnienie w przewodzie głownym i rozdzielczość
|
||||||
{
|
|
||||||
Parser.getTokens(2, false);
|
Parser.getTokens(2, false);
|
||||||
Parser >> fMWDpg[0] >> fMWDpg[1];
|
Parser >> fMWDpg[0] >> fMWDpg[1];
|
||||||
if (bMWDdebugEnable)
|
if (bMWDdebugEnable) WriteLog("MainAirPipe settings: " + to_string(fMWDpg[0]) + (" ") + to_string(fMWDpg[1]));
|
||||||
WriteLog("MainAirPipe settings: " + to_string(fMWDpg[0]) + " " +
|
|
||||||
to_string(fMWDpg[1]));
|
|
||||||
}
|
}
|
||||||
else if (token == "mwdcylinderhamulcowy")
|
else if (token == "mwdbreakpress") { // max ciśnienie w hamulcach i rozdzielczość
|
||||||
{
|
|
||||||
Parser.getTokens(2, false);
|
Parser.getTokens(2, false);
|
||||||
Parser >> fMWDph[0] >> fMWDph[1];
|
Parser >> fMWDph[0] >> fMWDph[1];
|
||||||
if (bMWDdebugEnable)
|
if (bMWDdebugEnable) WriteLog("AirPipe settings: " + to_string(fMWDph[0]) + (" ") + to_string(fMWDph[1]));
|
||||||
WriteLog("AirPipe settings: " + to_string(fMWDph[0]) + " " + to_string(fMWDph[1]));
|
|
||||||
}
|
}
|
||||||
else if (token == "mwdwoltomierzwn")
|
else if (token == "mwdhivoltmeter") { // max napięcie na woltomierzu WN
|
||||||
{
|
|
||||||
Parser.getTokens(2, false);
|
Parser.getTokens(2, false);
|
||||||
Parser >> fMWDvolt[0] >> fMWDvolt[1];
|
Parser >> fMWDvolt[0] >> fMWDvolt[1];
|
||||||
if (bMWDdebugEnable)
|
if (bMWDdebugEnable) WriteLog("VoltMeter settings: " + to_string(fMWDvolt[0]) + (" ") + to_string(fMWDvolt[1]));
|
||||||
WriteLog("Volt settings: " + to_string(fMWDvolt[0]) + " " + to_string(fMWDvolt[1]));
|
|
||||||
}
|
}
|
||||||
else if (token == "mwdamperomierzwn")
|
else if (token == "mwdhiampmeter") {
|
||||||
{
|
|
||||||
Parser.getTokens(2, false);
|
Parser.getTokens(2, false);
|
||||||
Parser >> fMWDamp[0] >> fMWDamp[1];
|
Parser >> fMWDamp[0] >> fMWDamp[1];
|
||||||
if (bMWDdebugEnable)
|
if (bMWDdebugEnable) WriteLog("Amp settings: " + to_string(fMWDamp[0]) + (" ") + to_string(fMWDamp[1]));
|
||||||
WriteLog("Amp settings: " + to_string(fMWDamp[0]) + " " + to_string(fMWDamp[1]));
|
}
|
||||||
|
else if (token == "mwddivider") {
|
||||||
|
Parser.getTokens(1, false);
|
||||||
|
Parser >> iMWDdivider;
|
||||||
|
if (iMWDdivider == 0)
|
||||||
|
{
|
||||||
|
WriteLog("Dzielnik nie może być równy ZERO! Ustawiam na 1!");
|
||||||
|
iMWDdivider = 1;
|
||||||
|
}
|
||||||
|
if (bMWDdebugEnable) WriteLog("Divider = " + to_string(iMWDdivider));
|
||||||
}
|
}
|
||||||
} while ((token != "") && (token != "endconfig")); //(!Parser->EndOfFile)
|
} while ((token != "") && (token != "endconfig")); //(!Parser->EndOfFile)
|
||||||
// na koniec trochę zależności
|
// na koniec trochę zależności
|
||||||
|
|||||||
22
Globals.h
22
Globals.h
@@ -244,6 +244,7 @@ class Global
|
|||||||
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 iDefaultFiltering; // domyślne rozmywanie tekstur TGA
|
||||||
static int iBallastFiltering; // domyślne rozmywanie tekstury podsypki
|
static int iBallastFiltering; // domyślne rozmywanie tekstury podsypki
|
||||||
static int iRailProFiltering; // domyślne rozmywanie tekstury szyn
|
static int iRailProFiltering; // domyślne rozmywanie tekstury szyn
|
||||||
@@ -259,6 +260,10 @@ class Global
|
|||||||
static double fLuminance; // jasność światła do automatycznego zapalania
|
static double fLuminance; // jasność światła do automatycznego zapalania
|
||||||
static int iMultiplayer; // blokada działania niektórych eventów na rzecz kominikacji
|
static int iMultiplayer; // blokada działania niektórych eventów na rzecz kominikacji
|
||||||
static HWND hWnd; // uchwyt okna
|
static HWND hWnd; // uchwyt okna
|
||||||
|
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 asRelease; // numer
|
static std::string asRelease; // numer
|
||||||
static std::string asVersion; // z opisem
|
static std::string asVersion; // z opisem
|
||||||
@@ -340,16 +345,19 @@ class Global
|
|||||||
static double CutValueToRange(double min, double value, double max);
|
static double CutValueToRange(double min, double value, double max);
|
||||||
|
|
||||||
// maciek001: zmienne dla MWD
|
// maciek001: zmienne dla MWD
|
||||||
static bool bMWDdebugEnable;
|
static bool bMWDmasterEnable; // główne włączenie portu COM
|
||||||
static unsigned int iMWDBaudrate;
|
static bool bMWDdebugEnable; // logowanie pracy
|
||||||
static std::string sMWDPortId;
|
static int iMWDDebugMode;
|
||||||
static bool bMWDBreakEnable;
|
static std::string sMWDPortId; // nazwa portu COM
|
||||||
static bool bMWDInputDataEnable;
|
static unsigned long int iMWDBaudrate; // prędkość transmisji
|
||||||
static double fMWDAnalogCalib[4][3];
|
static bool bMWDInputEnable; // włącz wejścia
|
||||||
static double fMWDzg[2];
|
static bool bMWDBreakEnable; // włącz wejścia analogowe (hamulce)
|
||||||
|
static double fMWDAnalogInCalib[4][2]; // ustawienia kranów hamulca zespolonego i dodatkowego - min i max
|
||||||
|
static double fMWDzg[2]; // max wartość wskazywana i max wartość generowana (rozdzielczość)
|
||||||
static double fMWDpg[2];
|
static double fMWDpg[2];
|
||||||
static double fMWDph[2];
|
static double fMWDph[2];
|
||||||
static double fMWDvolt[2];
|
static double fMWDvolt[2];
|
||||||
static double fMWDamp[2];
|
static double fMWDamp[2];
|
||||||
|
static int iMWDdivider;
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ void TGroundNode::RenderDL()
|
|||||||
return smTerrain->RenderDL();
|
return smTerrain->RenderDL();
|
||||||
}
|
}
|
||||||
// if (pTriGroup) if (pTriGroup!=this) return; //wyświetla go inny obiekt
|
// if (pTriGroup) if (pTriGroup!=this) return; //wyświetla go inny obiekt
|
||||||
double mgn = SquareMagnitude(pCenter - Global::pCameraPosition);
|
double mgn = SquareMagnitude(pCenter - Global::pCameraPosition) / Global::ZoomFactor;
|
||||||
if ((mgn > fSquareRadius) || (mgn < fSquareMinRadius)) // McZapkie-070602: nie rysuj odleglych
|
if ((mgn > fSquareRadius) || (mgn < fSquareMinRadius)) // McZapkie-070602: nie rysuj odleglych
|
||||||
// obiektow ale sprawdzaj wyzwalacz
|
// obiektow ale sprawdzaj wyzwalacz
|
||||||
// zdarzen
|
// zdarzen
|
||||||
@@ -633,7 +633,7 @@ void TGroundNode::RenderAlphaDL()
|
|||||||
// i jezeli tak to odpowiedni GL_GREATER w przeciwnym wypadku standardowy 0.04
|
// i jezeli tak to odpowiedni GL_GREATER w przeciwnym wypadku standardowy 0.04
|
||||||
|
|
||||||
// if (pTriGroup) if (pTriGroup!=this) return; //wyświetla go inny obiekt
|
// if (pTriGroup) if (pTriGroup!=this) return; //wyświetla go inny obiekt
|
||||||
double mgn = SquareMagnitude(pCenter - Global::pCameraPosition);
|
double mgn = SquareMagnitude(pCenter - Global::pCameraPosition) / Global::ZoomFactor;
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
if (mgn < fSquareMinRadius)
|
if (mgn < fSquareMinRadius)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -219,6 +219,9 @@ template <typename ColorT> inline void readColor(cParser &parser, ColorT *color)
|
|||||||
double discard;
|
double discard;
|
||||||
parser.getTokens(4, false);
|
parser.getTokens(4, false);
|
||||||
parser >> discard >> color[0] >> color[1] >> color[2];
|
parser >> discard >> color[0] >> color[1] >> color[2];
|
||||||
|
color[ 0 ] /= 255.0;
|
||||||
|
color[ 1 ] /= 255.0;
|
||||||
|
color[ 2 ] /= 255.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void readColor(cParser &parser, int &color)
|
inline void readColor(cParser &parser, int &color)
|
||||||
@@ -726,7 +729,7 @@ void TSubModel::DisplayLists()
|
|||||||
glColorMaterial(GL_FRONT, GL_EMISSION);
|
glColorMaterial(GL_FRONT, GL_EMISSION);
|
||||||
glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie blendowaly
|
glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie blendowaly
|
||||||
glBegin(GL_POINTS);
|
glBegin(GL_POINTS);
|
||||||
glVertex3f(0, 0, 0);
|
glVertex3f( 0.0f, 0.0f, -0.025f ); // shift point towards the viewer, to avoid z-fighting with the light polygons
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
|
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ opengl_texture::set_filtering() {
|
|||||||
|
|
||||||
if( GLEW_EXT_texture_filter_anisotropic ) {
|
if( GLEW_EXT_texture_filter_anisotropic ) {
|
||||||
// anisotropic filtering
|
// anisotropic filtering
|
||||||
::glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0f );
|
::glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, Global::AnisotropicFiltering );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sharpen{ false };
|
bool sharpen{ false };
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ struct opengl_texture {
|
|||||||
void load();
|
void load();
|
||||||
void create();
|
void create();
|
||||||
// members
|
// members
|
||||||
GLuint id{ -1 }; // associated GL resource
|
GLuint id{ (GLuint) -1 }; // associated GL resource
|
||||||
bool has_alpha{ false }; // indicates the texture has alpha channel
|
bool has_alpha{ false }; // indicates the texture has alpha channel
|
||||||
bool is_ready{ false }; // indicates the texture was processed and is ready for use
|
bool is_ready{ false }; // indicates the texture was processed and is ready for use
|
||||||
std::string traits; // requested texture attributes: wrapping modes etc
|
std::string traits; // requested texture attributes: wrapping modes etc
|
||||||
|
|||||||
294
Train.cpp
294
Train.cpp
@@ -24,6 +24,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
#include "McZapkie\hamulce.h"
|
#include "McZapkie\hamulce.h"
|
||||||
#include "McZapkie\MOVER.h"
|
#include "McZapkie\MOVER.h"
|
||||||
|
#include "Camera.h"
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
using namespace Timer;
|
using namespace Timer;
|
||||||
@@ -891,56 +892,56 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) ||
|
|||||||
if (false == (mvOccupied->LightsPosNo > 0))
|
if (false == (mvOccupied->LightsPosNo > 0))
|
||||||
{
|
{
|
||||||
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
|
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
|
||||||
(ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu
|
(ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu.
|
||||||
|
// 17.02.17 changed rear to opposite side, so the same key actually controls both lights on the left side, from the driver's point of view
|
||||||
|
// TODO: do it a more elegant way. preferably along with the rest of the controlling code
|
||||||
{
|
{
|
||||||
//------------------------------
|
|
||||||
if (mvOccupied->ActiveCab == 1)
|
if (mvOccupied->ActiveCab == 1)
|
||||||
{ // kabina 1
|
{ // kabina 1
|
||||||
if (((DynamicObject->iLights[1]) & 3) == 0)
|
if (((DynamicObject->iLights[1]) & 48) == 0)
|
||||||
{
|
{
|
||||||
DynamicObject->iLights[1] |= 1;
|
DynamicObject->iLights[1] |= 16;
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
||||||
dsbSwitch->Play(0, 0, 0);
|
dsbSwitch->Play(0, 0, 0);
|
||||||
ggRearLeftLightButton.PutValue(1);
|
ggRearRightLightButton.PutValue(1);
|
||||||
}
|
}
|
||||||
if (((DynamicObject->iLights[1]) & 3) == 2)
|
if (((DynamicObject->iLights[1]) & 48) == 32)
|
||||||
{
|
{
|
||||||
DynamicObject->iLights[1] &= (255 - 2);
|
DynamicObject->iLights[1] &= (255 - 32);
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
||||||
dsbSwitch->Play(0, 0, 0);
|
dsbSwitch->Play(0, 0, 0);
|
||||||
if (ggRearLeftEndLightButton.SubModel)
|
if (ggRearRightEndLightButton.SubModel)
|
||||||
{
|
{
|
||||||
ggRearLeftEndLightButton.PutValue(0);
|
ggRearRightEndLightButton.PutValue(0);
|
||||||
ggRearLeftLightButton.PutValue(0);
|
ggRearRightLightButton.PutValue(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ggRearLeftLightButton.PutValue(0);
|
ggRearRightLightButton.PutValue(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // kabina -1
|
{ // kabina -1
|
||||||
if (((DynamicObject->iLights[0]) & 3) == 0)
|
if (((DynamicObject->iLights[0]) & 48) == 0)
|
||||||
{
|
{
|
||||||
DynamicObject->iLights[0] |= 1;
|
DynamicObject->iLights[0] |= 16;
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
||||||
dsbSwitch->Play(0, 0, 0);
|
dsbSwitch->Play(0, 0, 0);
|
||||||
ggRearLeftLightButton.PutValue(1);
|
ggRearRightLightButton.PutValue(1);
|
||||||
}
|
}
|
||||||
if (((DynamicObject->iLights[0]) & 3) == 2)
|
if (((DynamicObject->iLights[0]) & 48) == 32)
|
||||||
{
|
{
|
||||||
DynamicObject->iLights[0] &= (255 - 2);
|
DynamicObject->iLights[0] &= (255 - 32);
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
||||||
dsbSwitch->Play(0, 0, 0);
|
dsbSwitch->Play(0, 0, 0);
|
||||||
if (ggRearLeftEndLightButton.SubModel)
|
if (ggRearRightEndLightButton.SubModel)
|
||||||
{
|
{
|
||||||
ggRearLeftEndLightButton.PutValue(0);
|
ggRearRightEndLightButton.PutValue(0);
|
||||||
ggRearLeftLightButton.PutValue(0);
|
ggRearRightLightButton.PutValue(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ggRearLeftLightButton.PutValue(0);
|
ggRearRightLightButton.PutValue(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1066,53 +1067,46 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) ||
|
|||||||
if (false == (mvOccupied->LightsPosNo > 0))
|
if (false == (mvOccupied->LightsPosNo > 0))
|
||||||
{
|
{
|
||||||
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
|
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
|
||||||
(ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu
|
(ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu
|
||||||
|
// 17.02.17 changed rear to opposite side, so the same key actually controls both lights on the left side, from the driver's point of view
|
||||||
|
// TODO: do it a more elegant way. preferably along with the rest of the controlling code
|
||||||
{
|
{
|
||||||
//------------------------------
|
if( mvOccupied->ActiveCab == 1 ) { // kabina 1
|
||||||
if (mvOccupied->ActiveCab == 1)
|
if( ( ( DynamicObject->iLights[ 1 ] ) & 3 ) == 0 ) {
|
||||||
{ // kabina 1
|
DynamicObject->iLights[ 1 ] |= 1;
|
||||||
if (((DynamicObject->iLights[1]) & 48) == 0)
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
{
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
DynamicObject->iLights[1] |= 16;
|
ggRearLeftLightButton.PutValue( 1 );
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
|
||||||
dsbSwitch->Play(0, 0, 0);
|
|
||||||
ggRearRightLightButton.PutValue(1);
|
|
||||||
}
|
}
|
||||||
if (((DynamicObject->iLights[1]) & 48) == 32)
|
if( ( ( DynamicObject->iLights[ 1 ] ) & 3 ) == 2 ) {
|
||||||
{
|
DynamicObject->iLights[ 1 ] &= ( 255 - 2 );
|
||||||
DynamicObject->iLights[1] &= (255 - 32);
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
dsbSwitch->Play(0, 0, 0);
|
if( ggRearLeftEndLightButton.SubModel ) {
|
||||||
if (ggRearRightEndLightButton.SubModel)
|
ggRearLeftEndLightButton.PutValue( 0 );
|
||||||
{
|
ggRearLeftLightButton.PutValue( 0 );
|
||||||
ggRearRightEndLightButton.PutValue(0);
|
|
||||||
ggRearRightLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ggRearRightLightButton.PutValue(0);
|
ggRearLeftLightButton.PutValue( 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else { // kabina -1
|
||||||
|
if( ( ( DynamicObject->iLights[ 0 ] ) & 3 ) == 0 ) {
|
||||||
|
DynamicObject->iLights[ 0 ] |= 1;
|
||||||
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
|
ggRearLeftLightButton.PutValue( 1 );
|
||||||
|
}
|
||||||
|
if( ( ( DynamicObject->iLights[ 0 ] ) & 3 ) == 2 ) {
|
||||||
|
DynamicObject->iLights[ 0 ] &= ( 255 - 2 );
|
||||||
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
|
if( ggRearLeftEndLightButton.SubModel ) {
|
||||||
|
ggRearLeftEndLightButton.PutValue( 0 );
|
||||||
|
ggRearLeftLightButton.PutValue( 0 );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ // kabina -1
|
ggRearLeftLightButton.PutValue( 0 );
|
||||||
if (((DynamicObject->iLights[0]) & 48) == 0)
|
|
||||||
{
|
|
||||||
DynamicObject->iLights[0] |= 16;
|
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
|
||||||
dsbSwitch->Play(0, 0, 0);
|
|
||||||
ggRearRightLightButton.PutValue(1);
|
|
||||||
}
|
|
||||||
if (((DynamicObject->iLights[0]) & 48) == 32)
|
|
||||||
{
|
|
||||||
DynamicObject->iLights[0] &= (255 - 32);
|
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
|
||||||
dsbSwitch->Play(0, 0, 0);
|
|
||||||
if (ggRearRightEndLightButton.SubModel)
|
|
||||||
{
|
|
||||||
ggRearRightEndLightButton.PutValue(0);
|
|
||||||
ggRearRightLightButton.PutValue(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ggRearRightLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //------------------------------
|
} //------------------------------
|
||||||
@@ -2099,52 +2093,46 @@ if
|
|||||||
{
|
{
|
||||||
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
|
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
|
||||||
(ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu
|
(ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu
|
||||||
|
// 17.02.17 changed rear to opposite side, so the same key actually controls both lights on the left side, from the driver's point of view
|
||||||
|
// TODO: do it a more elegant way. preferably along with the rest of the controlling code
|
||||||
{
|
{
|
||||||
//------------------------------
|
//------------------------------
|
||||||
if (mvOccupied->ActiveCab == 1)
|
if( mvOccupied->ActiveCab == 1 ) { // kabina 1 (od strony 0)
|
||||||
{ // kabina 1
|
if( ( ( DynamicObject->iLights[ 1 ] ) & 48 ) == 0 ) {
|
||||||
if (((DynamicObject->iLights[1]) & 3) == 0)
|
DynamicObject->iLights[ 1 ] |= 32;
|
||||||
{
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
DynamicObject->iLights[1] |= 2;
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
if( ggRearRightEndLightButton.SubModel ) {
|
||||||
dsbSwitch->Play(0, 0, 0);
|
ggRearRightEndLightButton.PutValue( 1 );
|
||||||
if (ggRearLeftEndLightButton.SubModel)
|
ggRearRightLightButton.PutValue( 0 );
|
||||||
{
|
|
||||||
ggRearLeftEndLightButton.PutValue(1);
|
|
||||||
ggRearLeftLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ggRearLeftLightButton.PutValue(-1);
|
ggRearRightLightButton.PutValue( -1 );
|
||||||
}
|
}
|
||||||
if (((DynamicObject->iLights[1]) & 3) == 1)
|
if( ( ( DynamicObject->iLights[ 1 ] ) & 48 ) == 16 ) {
|
||||||
{
|
DynamicObject->iLights[ 1 ] &= ( 255 - 16 );
|
||||||
DynamicObject->iLights[1] &= (255 - 1);
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
dsbSwitch->Play(0, 0, 0);
|
ggRearRightLightButton.PutValue( 0 );
|
||||||
ggRearLeftLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else { // kabina -1
|
||||||
|
if( ( ( DynamicObject->iLights[ 0 ] ) & 48 ) == 0 ) {
|
||||||
|
DynamicObject->iLights[ 0 ] |= 32;
|
||||||
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
|
if( ggRearRightEndLightButton.SubModel ) {
|
||||||
|
ggRearRightEndLightButton.PutValue( 1 );
|
||||||
|
ggRearRightLightButton.PutValue( 0 );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ // kabina -1
|
ggRearRightLightButton.PutValue( -1 );
|
||||||
if (((DynamicObject->iLights[0]) & 3) == 0)
|
|
||||||
{
|
|
||||||
DynamicObject->iLights[0] |= 2;
|
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
|
||||||
dsbSwitch->Play(0, 0, 0);
|
|
||||||
if (ggRearLeftEndLightButton.SubModel)
|
|
||||||
{
|
|
||||||
ggRearLeftEndLightButton.PutValue(1);
|
|
||||||
ggRearLeftLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
else
|
if( ( ( DynamicObject->iLights[ 0 ] ) & 48 ) == 16 ) {
|
||||||
ggRearLeftLightButton.PutValue(-1);
|
DynamicObject->iLights[ 0 ] &= ( 255 - 16 );
|
||||||
}
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
if (((DynamicObject->iLights[1]) & 3) == 1)
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
{
|
ggRearRightLightButton.PutValue( 0 );
|
||||||
DynamicObject->iLights[1] &= (255 - 1);
|
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
|
||||||
dsbSwitch->Play(0, 0, 0);
|
|
||||||
ggLeftLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //------------------------------
|
} //------------------------------
|
||||||
@@ -2272,52 +2260,46 @@ if
|
|||||||
{
|
{
|
||||||
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
|
if ((GetAsyncKeyState(VK_CONTROL) < 0) &&
|
||||||
(ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu
|
(ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu
|
||||||
|
// 17.02.17 changed rear to opposite side, so the same key actually controls both lights on the left side, from the driver's point of view
|
||||||
|
// TODO: do it a more elegant way. preferably along with the rest of the controlling code
|
||||||
{
|
{
|
||||||
//------------------------------
|
//------------------------------
|
||||||
if (mvOccupied->ActiveCab == 1)
|
if( mvOccupied->ActiveCab == 1 ) { // kabina 1
|
||||||
{ // kabina 1 (od strony 0)
|
if( ( ( DynamicObject->iLights[ 1 ] ) & 3 ) == 0 ) {
|
||||||
if (((DynamicObject->iLights[1]) & 48) == 0)
|
DynamicObject->iLights[ 1 ] |= 2;
|
||||||
{
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
DynamicObject->iLights[1] |= 32;
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
if( ggRearLeftEndLightButton.SubModel ) {
|
||||||
dsbSwitch->Play(0, 0, 0);
|
ggRearLeftEndLightButton.PutValue( 1 );
|
||||||
if (ggRearRightEndLightButton.SubModel)
|
ggRearLeftLightButton.PutValue( 0 );
|
||||||
{
|
|
||||||
ggRearRightEndLightButton.PutValue(1);
|
|
||||||
ggRearRightLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ggRearRightLightButton.PutValue(-1);
|
ggRearLeftLightButton.PutValue( -1 );
|
||||||
}
|
}
|
||||||
if (((DynamicObject->iLights[1]) & 48) == 16)
|
if( ( ( DynamicObject->iLights[ 1 ] ) & 3 ) == 1 ) {
|
||||||
{
|
DynamicObject->iLights[ 1 ] &= ( 255 - 1 );
|
||||||
DynamicObject->iLights[1] &= (255 - 16);
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
dsbSwitch->Play(0, 0, 0);
|
ggRearLeftLightButton.PutValue( 0 );
|
||||||
ggRearRightLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else { // kabina -1
|
||||||
|
if( ( ( DynamicObject->iLights[ 0 ] ) & 3 ) == 0 ) {
|
||||||
|
DynamicObject->iLights[ 0 ] |= 2;
|
||||||
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
|
if( ggRearLeftEndLightButton.SubModel ) {
|
||||||
|
ggRearLeftEndLightButton.PutValue( 1 );
|
||||||
|
ggRearLeftLightButton.PutValue( 0 );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ // kabina -1
|
ggRearLeftLightButton.PutValue( -1 );
|
||||||
if (((DynamicObject->iLights[0]) & 48) == 0)
|
|
||||||
{
|
|
||||||
DynamicObject->iLights[0] |= 32;
|
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
|
||||||
dsbSwitch->Play(0, 0, 0);
|
|
||||||
if (ggRearRightEndLightButton.SubModel)
|
|
||||||
{
|
|
||||||
ggRearRightEndLightButton.PutValue(1);
|
|
||||||
ggRearRightLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
else
|
if( ( ( DynamicObject->iLights[ 1 ] ) & 3 ) == 1 ) {
|
||||||
ggRearRightLightButton.PutValue(-1);
|
DynamicObject->iLights[ 1 ] &= ( 255 - 1 );
|
||||||
}
|
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||||
if (((DynamicObject->iLights[0]) & 48) == 16)
|
dsbSwitch->Play( 0, 0, 0 );
|
||||||
{
|
ggLeftLightButton.PutValue( 0 );
|
||||||
DynamicObject->iLights[0] &= (255 - 16);
|
|
||||||
dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
|
||||||
dsbSwitch->Play(0, 0, 0);
|
|
||||||
ggRearRightLightButton.PutValue(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //------------------------------
|
} //------------------------------
|
||||||
@@ -2402,17 +2384,25 @@ if
|
|||||||
{
|
{
|
||||||
// McZapkie: poruszanie sie po kabinie, w updatemechpos zawarte sa wiezy
|
// McZapkie: poruszanie sie po kabinie, w updatemechpos zawarte sa wiezy
|
||||||
|
|
||||||
// double dt=Timer::GetDeltaTime();
|
auto step = 60.0f * Timer::GetDeltaTime();
|
||||||
if (mvOccupied->ActiveCab < 0)
|
auto const camerayaw = Global::pCamera->Yaw;
|
||||||
fMechCroach = -0.5;
|
Math3D::vector3 direction( 0.0f, 0.0f, step );
|
||||||
else
|
direction.RotateY( camerayaw );
|
||||||
fMechCroach = 0.5;
|
Math3D::vector3 right( -step, 0.0f, 0.0f );
|
||||||
|
right.RotateY( camerayaw );
|
||||||
|
// auto right = Math3D::CrossProduct( direction, Math3D::vector3( 0.0f, 1.0f, 0.0f ) );
|
||||||
|
|
||||||
|
if( mvOccupied->ActiveCab < 0 ) {
|
||||||
|
|
||||||
|
direction *= -1.0f;
|
||||||
|
right *= -1.0f;
|
||||||
|
}
|
||||||
// if (!GetAsyncKeyState(VK_SHIFT)<0) // bez shifta
|
// if (!GetAsyncKeyState(VK_SHIFT)<0) // bez shifta
|
||||||
if (!Console::Pressed(VK_CONTROL)) // gdy [Ctrl] zwolniony (dodatkowe widoki)
|
if (!Console::Pressed(VK_CONTROL)) // gdy [Ctrl] zwolniony (dodatkowe widoki)
|
||||||
{
|
{
|
||||||
if (cKey == Global::Keys[k_MechLeft])
|
if (cKey == Global::Keys[k_MechLeft])
|
||||||
{
|
{
|
||||||
vMechMovement.x += fMechCroach;
|
vMechMovement -= right;
|
||||||
if (DynamicObject->Mechanik)
|
if (DynamicObject->Mechanik)
|
||||||
if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz
|
if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz
|
||||||
DynamicObject->Mechanik->RouteSwitch(
|
DynamicObject->Mechanik->RouteSwitch(
|
||||||
@@ -2420,7 +2410,7 @@ if
|
|||||||
}
|
}
|
||||||
else if (cKey == Global::Keys[k_MechRight])
|
else if (cKey == Global::Keys[k_MechRight])
|
||||||
{
|
{
|
||||||
vMechMovement.x -= fMechCroach;
|
vMechMovement += right;
|
||||||
if (DynamicObject->Mechanik)
|
if (DynamicObject->Mechanik)
|
||||||
if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz
|
if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz
|
||||||
DynamicObject->Mechanik->RouteSwitch(
|
DynamicObject->Mechanik->RouteSwitch(
|
||||||
@@ -2428,7 +2418,7 @@ if
|
|||||||
}
|
}
|
||||||
else if (cKey == Global::Keys[k_MechBackward])
|
else if (cKey == Global::Keys[k_MechBackward])
|
||||||
{
|
{
|
||||||
vMechMovement.z -= fMechCroach;
|
vMechMovement -= direction;
|
||||||
// if (DynamicObject->Mechanik)
|
// if (DynamicObject->Mechanik)
|
||||||
// if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz
|
// if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz
|
||||||
// DynamicObject->Mechanik->RouteSwitch(0); //na skrzyżowaniu stanie
|
// DynamicObject->Mechanik->RouteSwitch(0); //na skrzyżowaniu stanie
|
||||||
@@ -2436,16 +2426,16 @@ if
|
|||||||
}
|
}
|
||||||
else if (cKey == Global::Keys[k_MechForward])
|
else if (cKey == Global::Keys[k_MechForward])
|
||||||
{
|
{
|
||||||
vMechMovement.z += fMechCroach;
|
vMechMovement += direction;
|
||||||
if (DynamicObject->Mechanik)
|
if (DynamicObject->Mechanik)
|
||||||
if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz
|
if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz
|
||||||
DynamicObject->Mechanik->RouteSwitch(
|
DynamicObject->Mechanik->RouteSwitch(
|
||||||
3); // na skrzyżowaniu pojedzie prosto
|
3); // na skrzyżowaniu pojedzie prosto
|
||||||
}
|
}
|
||||||
else if (cKey == Global::Keys[k_MechUp])
|
else if (cKey == Global::Keys[k_MechUp])
|
||||||
pMechOffset.y += 0.2; // McZapkie-120302 - wstawanie
|
pMechOffset.y += 0.25; // McZapkie-120302 - wstawanie
|
||||||
else if (cKey == Global::Keys[k_MechDown])
|
else if (cKey == Global::Keys[k_MechDown])
|
||||||
pMechOffset.y -= 0.2; // McZapkie-120302 - siadanie
|
pMechOffset.y -= 0.25; // McZapkie-120302 - siadanie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3758,7 +3748,7 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
{
|
{
|
||||||
if (DynamicObject->Mechanik ?
|
if (DynamicObject->Mechanik ?
|
||||||
(DynamicObject->Mechanik->AIControllFlag ? false :
|
(DynamicObject->Mechanik->AIControllFlag ? false :
|
||||||
Global::iFeedbackMode == 4 ) :
|
(Global::iFeedbackMode == 4 || (Global::bMWDmasterEnable && Global::bMWDBreakEnable))) :
|
||||||
false) // nie blokujemy AI
|
false) // nie blokujemy AI
|
||||||
{ // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
|
{ // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
|
||||||
// Firleju: dlatego kasujemy i zastepujemy funkcją w Console
|
// Firleju: dlatego kasujemy i zastepujemy funkcją w Console
|
||||||
@@ -3782,7 +3772,7 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
if (ggLocalBrake.SubModel)
|
if (ggLocalBrake.SubModel)
|
||||||
{
|
{
|
||||||
if (DynamicObject->Mechanik ?
|
if (DynamicObject->Mechanik ?
|
||||||
(DynamicObject->Mechanik->AIControllFlag ? false : Global::iFeedbackMode == 4) :
|
(DynamicObject->Mechanik->AIControllFlag ? false : (Global::iFeedbackMode == 4 || Global::bMWDmasterEnable)) :
|
||||||
false) // nie blokujemy AI
|
false) // nie blokujemy AI
|
||||||
{ // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
|
{ // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
|
||||||
// Firleju: dlatego kasujemy i zastepujemy funkcją w Console
|
// Firleju: dlatego kasujemy i zastepujemy funkcją w Console
|
||||||
@@ -5994,6 +5984,10 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
|
|||||||
{
|
{
|
||||||
btLampkaHamienie.Load(Parser, DynamicObject->mdKabina);
|
btLampkaHamienie.Load(Parser, DynamicObject->mdKabina);
|
||||||
}
|
}
|
||||||
|
else if( Label == "i-dynamicbrake:" ) {
|
||||||
|
|
||||||
|
btLampkaED.Load( Parser, DynamicObject->mdKabina );
|
||||||
|
}
|
||||||
else if (Label == "i-braking-ezt:")
|
else if (Label == "i-braking-ezt:")
|
||||||
{
|
{
|
||||||
btLampkaHamowanie1zes.Load(Parser, DynamicObject->mdKabina);
|
btLampkaHamowanie1zes.Load(Parser, DynamicObject->mdKabina);
|
||||||
@@ -6334,6 +6328,10 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
|||||||
// hunter-091012: przyciemnienie swiatla w kabinie
|
// hunter-091012: przyciemnienie swiatla w kabinie
|
||||||
ggCabLightDimButton.Load(Parser, DynamicObject->mdKabina);
|
ggCabLightDimButton.Load(Parser, DynamicObject->mdKabina);
|
||||||
}
|
}
|
||||||
|
else if( Label == "battery_sw:" ) {
|
||||||
|
|
||||||
|
ggBatteryButton.Load( Parser, DynamicObject->mdKabina );
|
||||||
|
}
|
||||||
// ABu 090305: uniwersalne przyciski lub inne rzeczy
|
// ABu 090305: uniwersalne przyciski lub inne rzeczy
|
||||||
else if (Label == "universal1:")
|
else if (Label == "universal1:")
|
||||||
{
|
{
|
||||||
|
|||||||
67
World.cpp
67
World.cpp
@@ -345,8 +345,8 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("glLineWidth(1.0f);");
|
WriteLog("glLineWidth(1.0f);");
|
||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
// glLineWidth(2.0f);
|
// glLineWidth(2.0f);
|
||||||
WriteLog("glPointSize(2.0f);");
|
WriteLog("glPointSize(3.0f);");
|
||||||
glPointSize(2.0f);
|
glPointSize(3.0f);
|
||||||
#ifdef EU07_USE_OLD_LIGHTING_MODEL
|
#ifdef EU07_USE_OLD_LIGHTING_MODEL
|
||||||
// ----------- LIGHTING SETUP -----------
|
// ----------- LIGHTING SETUP -----------
|
||||||
// Light values and coordinates
|
// Light values and coordinates
|
||||||
@@ -492,21 +492,21 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
|
|
||||||
glBegin(GL_QUADS); // Drawing using triangles
|
glBegin(GL_QUADS); // Drawing using triangles
|
||||||
glTexCoord2f(0.0f, 0.0f);
|
glTexCoord2f(0.0f, 0.0f);
|
||||||
glVertex3f(-0.28f, -0.22f, 0.0f); // bottom left of the texture and quad
|
glVertex3f(-1.0f, -1.0f, 0.0f); // bottom left of the texture and quad
|
||||||
glTexCoord2f(1.0f, 0.0f);
|
glTexCoord2f(1.0f, 0.0f);
|
||||||
glVertex3f(0.28f, -0.22f, 0.0f); // bottom right of the texture and quad
|
glVertex3f(1.0f, -1.0f, 0.0f); // bottom right of the texture and quad
|
||||||
glTexCoord2f(1.0f, 1.0f);
|
glTexCoord2f(1.0f, 1.0f);
|
||||||
glVertex3f(0.28f, 0.22f, 0.0f); // top right of the texture and quad
|
glVertex3f(1.0f, 1.0f, 0.0f); // top right of the texture and quad
|
||||||
glTexCoord2f(0.0f, 1.0f);
|
glTexCoord2f(0.0f, 1.0f);
|
||||||
glVertex3f(-0.28f, 0.22f, 0.0f); // top left of the texture and quad
|
glVertex3f(-1.0f, 1.0f, 0.0f); // top left of the texture and quad
|
||||||
glEnd();
|
glEnd();
|
||||||
//~logo; Ra: to jest bez sensu zapis
|
//~logo; Ra: to jest bez sensu zapis
|
||||||
glColor3f(0.0f, 0.0f, 1.0f);
|
glColor3f(0.0f, 0.0f, 1.0f);
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.09f);
|
glRasterPos2f(-0.85f, -0.25f);
|
||||||
glPrint("Uruchamianie / Initializing...");
|
glPrint("Uruchamianie / Initializing...");
|
||||||
glRasterPos2f(-0.25f, -0.10f);
|
glRasterPos2f(-0.85f, -0.30f);
|
||||||
glPrint("Dzwiek / Sound...");
|
glPrint("Dzwiek / Sound...");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -518,7 +518,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("Sound Init OK");
|
WriteLog("Sound Init OK");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.11f);
|
glRasterPos2f(-0.25f, -0.30f);
|
||||||
glPrint("OK.");
|
glPrint("OK.");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -529,7 +529,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("Textures init");
|
WriteLog("Textures init");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.12f);
|
glRasterPos2f(-0.85f, -0.35f);
|
||||||
glPrint("Tekstury / Textures...");
|
glPrint("Tekstury / Textures...");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -539,7 +539,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("Textures init OK");
|
WriteLog("Textures init OK");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.13f);
|
glRasterPos2f(-0.25f, -0.35f);
|
||||||
glPrint("OK.");
|
glPrint("OK.");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -547,7 +547,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("Models init");
|
WriteLog("Models init");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.14f);
|
glRasterPos2f(-0.85f, -0.40f);
|
||||||
glPrint("Modele / Models...");
|
glPrint("Modele / Models...");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -557,7 +557,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("Models init OK");
|
WriteLog("Models init OK");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.15f);
|
glRasterPos2f(-0.25f, -0.40f);
|
||||||
glPrint("OK.");
|
glPrint("OK.");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -565,7 +565,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("Ground init");
|
WriteLog("Ground init");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.16f);
|
glRasterPos2f(-0.85f, -0.45f);
|
||||||
glPrint("Sceneria / Scenery (please wait)...");
|
glPrint("Sceneria / Scenery (please wait)...");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -594,7 +594,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("Ground init OK");
|
WriteLog("Ground init OK");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.17f);
|
glRasterPos2f(-0.25f, -0.45f);
|
||||||
glPrint("OK.");
|
glPrint("OK.");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -611,7 +611,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
char buff[255] = "Player train init: ";
|
char buff[255] = "Player train init: ";
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.18f);
|
glRasterPos2f(-0.85f, -0.50f);
|
||||||
glPrint("Przygotowanie kabiny do sterowania...");
|
glPrint("Przygotowanie kabiny do sterowania...");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -632,7 +632,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
WriteLog("Player train init OK");
|
WriteLog("Player train init OK");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.19f);
|
glRasterPos2f(-0.25f, -0.50f);
|
||||||
glPrint("OK.");
|
glPrint("OK.");
|
||||||
}
|
}
|
||||||
FollowView();
|
FollowView();
|
||||||
@@ -644,7 +644,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie
|
FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.20f);
|
glRasterPos2f(-0.85f, -0.50f);
|
||||||
glPrint("Blad inicjalizacji sterowanego pojazdu!");
|
glPrint("Blad inicjalizacji sterowanego pojazdu!");
|
||||||
}
|
}
|
||||||
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
|
||||||
@@ -660,7 +660,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
|||||||
Error("Player train not exist!");
|
Error("Player train not exist!");
|
||||||
if (Global::detonatoryOK)
|
if (Global::detonatoryOK)
|
||||||
{
|
{
|
||||||
glRasterPos2f(-0.25f, -0.20f);
|
glRasterPos2f(-0.85f, -0.55f);
|
||||||
glPrint("Wybrany pojazd nie istnieje w scenerii!");
|
glPrint("Wybrany pojazd nie istnieje w scenerii!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1008,7 +1008,7 @@ void TWorld::OnKeyUp(int cKey)
|
|||||||
|
|
||||||
void TWorld::OnMouseMove(double x, double y)
|
void TWorld::OnMouseMove(double x, double y)
|
||||||
{ // McZapkie:060503-definicja obracania myszy
|
{ // McZapkie:060503-definicja obracania myszy
|
||||||
Camera.OnCursorMove(x * Global::fMouseXScale, -y * Global::fMouseYScale);
|
Camera.OnCursorMove(x * Global::fMouseXScale / Global::ZoomFactor, -y * Global::fMouseYScale / Global::ZoomFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TWorld::InOutKey()
|
void TWorld::InOutKey()
|
||||||
@@ -1323,8 +1323,19 @@ TWorld::Update_Camera( double const Deltatime ) {
|
|||||||
if( FreeFlyModeFlag )
|
if( FreeFlyModeFlag )
|
||||||
Camera.RaLook(); // jednorazowe przestawienie kamery
|
Camera.RaLook(); // jednorazowe przestawienie kamery
|
||||||
}
|
}
|
||||||
else if( Console::Pressed( VK_RBUTTON ) ) //||Console::Pressed(VK_F4))
|
else if( Console::Pressed( VK_RBUTTON ) ) { //||Console::Pressed(VK_F4))
|
||||||
FollowView( false ); // bez wyciszania dźwięków
|
FollowView( false ); // bez wyciszania dźwięków
|
||||||
|
}
|
||||||
|
else if( true == Console::Pressed( VK_MBUTTON ) ) {
|
||||||
|
// middle mouse button controls zoom.
|
||||||
|
Global::ZoomFactor = std::min( 4.5f, Global::ZoomFactor + 15.0f * static_cast<float>(Deltatime) );
|
||||||
|
}
|
||||||
|
else if( false == Console::Pressed( VK_MBUTTON ) ) {
|
||||||
|
// reset zoom level if the button is no longer held down.
|
||||||
|
// NOTE: yes, this is terrible way to go about it. it'll do for now.
|
||||||
|
Global::ZoomFactor = std::max( 1.0f, Global::ZoomFactor - 15.0f * static_cast<float>( Deltatime ) );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
else if( Global::iTextMode == -1 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy
|
else if( Global::iTextMode == -1 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy
|
||||||
WriteLog( "Number of textures used: " + std::to_string( Global::iTextures ) );
|
WriteLog( "Number of textures used: " + std::to_string( Global::iTextures ) );
|
||||||
@@ -1552,6 +1563,12 @@ bool TWorld::Render()
|
|||||||
// glColor3b(255, 0, 255);
|
// glColor3b(255, 0, 255);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glDepthFunc( GL_LEQUAL );
|
glDepthFunc( GL_LEQUAL );
|
||||||
|
|
||||||
|
glMatrixMode( GL_PROJECTION ); // select the Projection Matrix
|
||||||
|
glLoadIdentity(); // reset the Projection Matrix
|
||||||
|
// calculate the aspect ratio of the window
|
||||||
|
gluPerspective( Global::FieldOfView / Global::ZoomFactor, (GLdouble)Global::ScreenWidth / (GLdouble)Global::ScreenHeight, 0.1f * Global::ZoomFactor, 2500.0f * Global::ZoomFactor );
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
|
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
Camera.SetMatrix(); // ustawienie macierzy kamery względem początku scenerii
|
Camera.SetMatrix(); // ustawienie macierzy kamery względem początku scenerii
|
||||||
@@ -1857,6 +1874,14 @@ TWorld::Render_Cab() {
|
|||||||
void
|
void
|
||||||
TWorld::Render_UI() {
|
TWorld::Render_UI() {
|
||||||
|
|
||||||
|
// set the UI mode projection. TODO: rework it all into somethinig more elegant... eventually
|
||||||
|
glMatrixMode( GL_PROJECTION ); // select the Projection Matrix
|
||||||
|
glLoadIdentity(); // reset the Projection Matrix
|
||||||
|
// calculate the aspect ratio of the window
|
||||||
|
gluPerspective( 45.0f, (GLdouble)Global::ScreenWidth / (GLdouble)Global::ScreenHeight, 0.2f, 2500.0f );
|
||||||
|
glMatrixMode( GL_MODELVIEW ); // Select The Modelview Matrix
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
if( DebugModeFlag && !Global::iTextMode ) {
|
if( DebugModeFlag && !Global::iTextMode ) {
|
||||||
OutText1 = " FPS: ";
|
OutText1 = " FPS: ";
|
||||||
OutText1 += to_string( Timer::GetFPS(), 2 );
|
OutText1 += to_string( Timer::GetFPS(), 2 );
|
||||||
|
|||||||
Reference in New Issue
Block a user