16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 20:59:19 +02:00

more complete parsing of .fiz data files

This commit is contained in:
tmj-fstate
2017-01-22 00:08:53 +01:00
parent 8f2f3b9889
commit 538d130617
7 changed files with 1045 additions and 682 deletions

View File

@@ -2525,14 +2525,21 @@ bool TDynamicObject::Update(double dt, double dt1)
{ // wyliczenie promienia z obrotów { // wyliczenie promienia z obrotów
// osi - modyfikację zgłosił youBy // osi - modyfikację zgłosił youBy
ts.R = Axle0.vAngles.z - Axle1.vAngles.z; // różnica może dawać stałą ±M_2PI ts.R = Axle0.vAngles.z - Axle1.vAngles.z; // różnica może dawać stałą ±M_2PI
if (ts.R > M_PI) if( ( ts.R > 15000.0 ) || ( ts.R < -15000.0 ) ) {
ts.R -= M_2PI else if (ts.R < -M_PI) ts.R += M_2PI; // normalizacja // szkoda czasu na zbyt duże promienie, 4km to promień nie wymagający przechyłki
ts.R = 0.0;
}
else {
// normalizacja
if( ts.R > M_PI ) { ts.R -= M_2PI; }
else if( ts.R < -M_PI ) { ts.R += M_2PI; }
if( ts.R != 0.0 ) {
// sin(0) results in division by zero
// ts.R=fabs(0.5*MoverParameters->BDist/sin(ts.R*0.5)); // ts.R=fabs(0.5*MoverParameters->BDist/sin(ts.R*0.5));
ts.R = -0.5 * MoverParameters->BDist / sin( ts.R * 0.5 ); ts.R = -0.5 * MoverParameters->BDist / sin( ts.R * 0.5 );
if ((ts.R > 15000.0) || (ts.R < -15000.0)) }
ts.R = 0.0; // szkoda czasu na zbyt duże promienie, 4km to promień nie }
// wymagający
// przechyłki
} }
else else
ts.R = 0.0; ts.R = 0.0;
@@ -3769,7 +3776,7 @@ void TDynamicObject::RenderSounds()
vol = rsSilnik.AM * MoverParameters->dizel_fill + rsSilnik.AA; vol = rsSilnik.AM * MoverParameters->dizel_fill + rsSilnik.AA;
else else
vol = vol =
rsSilnik.AM * fabs(MoverParameters->enrot / MoverParameters->nmax) + rsSilnik.AM * fabs(MoverParameters->enrot / MoverParameters->dizel_nmax) +
rsSilnik.AA * 0.9; rsSilnik.AA * 0.9;
} }
else else
@@ -4224,16 +4231,6 @@ void TDynamicObject::RenderAlpha()
void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
std::string ReplacableSkin) std::string ReplacableSkin)
{ {
// temporary hack to enable door animation in EZT
// TODO: add relevant entries to suitable definition file (.mmd ?)
// ensure the parameters are loaded before the main body mesh
// so the code binds proper method of door animation
if( MoverParameters->TrainType & dt_EZT ) {
MoverParameters->DoorOpenCtrl = 1;
MoverParameters->DoorCloseCtrl = 1;
MoverParameters->DoorOpenMethod = 1;
}
double dSDist; double dSDist;
// asBaseDir=BaseDir; // asBaseDir=BaseDir;
Global::asCurrentDynamicPath = BaseDir; Global::asCurrentDynamicPath = BaseDir;

View File

@@ -59,8 +59,8 @@ LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
int InitGL(GLvoid) // All Setup For OpenGL Goes Here int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{ {
_clear87(); // _clear87();
_control87(MCW_EM, MCW_EM); // _control87(MCW_EM, MCW_EM);
glewInit(); glewInit();
// hunter-271211: przeniesione // hunter-271211: przeniesione
// AllocConsole(); // AllocConsole();
@@ -572,8 +572,14 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
LPSTR lpCmdLine, // command line parameters LPSTR lpCmdLine, // command line parameters
int nCmdShow) // window show state int nCmdShow) // window show state
{ {
#ifdef _MSC_VER #ifdef _MSC_VER & _DEBUG
// memory leaks
_CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF ); _CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF );
// floating point operation errors
auto state = _clearfp();
state = _control87( 0, 0 );
// this will turn on FPE for #IND and zerodiv
state = _control87( state & ~( _EM_ZERODIVIDE | _EM_INVALID ), _MCW_EM );
#endif #endif
MSG msg; // windows message structure MSG msg; // windows message structure

View File

@@ -77,7 +77,7 @@ TGroundNode::TGroundNode()
asName = ""; asName = "";
// Color= TMaterialColor(1); // Color= TMaterialColor(1);
// fAngle=0; //obrót dla modelu // fAngle=0; //obrót dla modelu
// fLineThickness=1.0; //mm dla linii fLineThickness=1.0; //mm dla linii
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
Ambient[i] = Global::whiteLight[i] * 255; Ambient[i] = Global::whiteLight[i] * 255;
@@ -1307,6 +1307,9 @@ void TGround::MoveGroundNode(vector3 pPosition)
*/ */
} }
TGroundVertex TempVerts[ 10000 ]; // tu wczytywane s¹ trójk¹ty
BYTE TempConnectionType[ 200 ]; // Ra: sprzêgi w sk³adzie; ujemne, gdy odwrotnie
TGround::TGround() TGround::TGround()
{ {
// RootNode=NULL; // RootNode=NULL;
@@ -1324,6 +1327,8 @@ TGround::TGround()
nRootOfType[i] = NULL; // zerowanie tablic wyszukiwania nRootOfType[i] = NULL; // zerowanie tablic wyszukiwania
bDynamicRemove = false; // na razie nic do usuniêcia bDynamicRemove = false; // na razie nic do usuniêcia
sTracks = new TNames(); // nazwy torów - na razie tak sTracks = new TNames(); // nazwy torów - na razie tak
::SecureZeroMemory( TempVerts, sizeof( TempVerts ) );
::SecureZeroMemory( TempConnectionType, sizeof( TempConnectionType ) );
} }
TGround::~TGround() TGround::~TGround()
@@ -1414,9 +1419,6 @@ int iTrainSetWehicleNumber = 0;
TGroundNode *nTrainSetNode = NULL; // poprzedni pojazd do ³¹czenia TGroundNode *nTrainSetNode = NULL; // poprzedni pojazd do ³¹czenia
TGroundNode *nTrainSetDriver = NULL; // pojazd, któremu zostanie wys³any rozk³ad TGroundNode *nTrainSetDriver = NULL; // pojazd, któremu zostanie wys³any rozk³ad
TGroundVertex TempVerts[10000]; // tu wczytywane s¹ trójk¹ty
BYTE TempConnectionType[200]; // Ra: sprzêgi w sk³adzie; ujemne, gdy odwrotnie
void TGround::RaTriangleDivider(TGroundNode *node) void TGround::RaTriangleDivider(TGroundNode *node)
{ // tworzy dodatkowe trójk¹ty i zmiejsza podany { // tworzy dodatkowe trójk¹ty i zmiejsza podany
// to jest wywo³ywane przy wczytywaniu trójk¹tów // to jest wywo³ywane przy wczytywaniu trójk¹tów

View File

@@ -496,10 +496,10 @@ struct TScheme
typedef TScheme TSchemeTable[ResArraySize + 1]; /*tablica rezystorow rozr.*/ typedef TScheme TSchemeTable[ResArraySize + 1]; /*tablica rezystorow rozr.*/
struct TDEScheme struct TDEScheme
{ {
double RPM; /*obroty diesla*/ double RPM = 0.0; /*obroty diesla*/
double GenPower; /*moc maksymalna*/ double GenPower = 0.0; /*moc maksymalna*/
double Umax; /*napiecie maksymalne*/ double Umax = 0.0; /*napiecie maksymalne*/
double Imax; /*prad maksymalny*/ double Imax = 0.0; /*prad maksymalny*/
}; };
typedef TDEScheme TDESchemeTable[33]; /*tablica rezystorow rozr.*/ typedef TDEScheme TDESchemeTable[33]; /*tablica rezystorow rozr.*/
struct TShuntScheme struct TShuntScheme
@@ -569,23 +569,28 @@ struct TTransmision
enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic }; enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic };
//class TMoverParameters; // wyforwardowanie klasy coby typ byl widoczny w ponizszej strukturze
class TMoverParameters; // wyforwardowanie klasy coby typ byl widoczny w ponizszej strukturze
struct TCoupling { struct TCoupling {
/*parametry*/ /*parametry*/
double SpringKB; double SpringKC; double beta; /*stala sprezystosci zderzaka/sprzegu, %tlumiennosci */ double SpringKB = 1.0; /*stala sprezystosci zderzaka/sprzegu, %tlumiennosci */
double DmaxB; double FmaxB; double DmaxC; double FmaxC; /*tolerancja scisku/rozciagania, sila rozerwania*/ double SpringKC = 1.0;
TCouplerType CouplerType; /*typ sprzegu*/ double beta = 0.0;
double DmaxB = 0.1; /*tolerancja scisku/rozciagania, sila rozerwania*/
double FmaxB = 1000.0;
double DmaxC = 0.1;
double FmaxC = 1000.0;
TCouplerType CouplerType = NoCoupler; /*typ sprzegu*/
/*zmienne*/ /*zmienne*/
int CouplingFlag; /*0 - wirtualnie, 1 - sprzegi, 2 - pneumatycznie, 4 - sterowanie, 8 - kabel mocy*/ int CouplingFlag = 0; /*0 - wirtualnie, 1 - sprzegi, 2 - pneumatycznie, 4 - sterowanie, 8 - kabel mocy*/
int AllowedFlag; //Ra: znaczenie jak wyżej, maska dostępnych int AllowedFlag = 3; //Ra: znaczenie jak wyżej, maska dostępnych // domyślnie hak i hamulec, inne trzeba włączyć jawnie w FIZ
bool Render; /*ABu: czy rysowac jak zaczepiony sprzeg*/ bool Render = false; /*ABu: czy rysowac jak zaczepiony sprzeg*/
double CoupleDist; /*ABu: optymalizacja - liczenie odleglosci raz na klatkę, bez iteracji*/ double CoupleDist = 0.0; /*ABu: optymalizacja - liczenie odleglosci raz na klatkę, bez iteracji*/
TMoverParameters* Connected; /*co jest podlaczone*/ class TMoverParameters *Connected = nullptr; /*co jest podlaczone*/
int ConnectedNr; //Ra: od której strony podłączony do (Connected): 0=przód, 1=tył int ConnectedNr = 0; //Ra: od której strony podłączony do (Connected): 0=przód, 1=tył
double CForce; /*sila z jaka dzialal*/ double CForce = 0.0; /*sila z jaka dzialal*/
double Dist; /*strzalka ugiecia zderzaków*/ double Dist = 0.0; /*strzalka ugiecia zderzaków*/
bool CheckCollision; /*czy sprawdzac sile czy pedy*/ bool CheckCollision = false; /*czy sprawdzac sile czy pedy*/
}; };
class TMoverParameters class TMoverParameters
@@ -1111,9 +1116,17 @@ public:
/*funkcje ladujace pliki opisujace pojazd*/ /*funkcje ladujace pliki opisujace pojazd*/
bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath); bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath);
bool readMPT(int ln, std::string line); //Q 20160717 bool LoadFIZ_Doors( std::string const &line );
bool readRLIST(int ln, std::string line); //Q 20160718 bool readMPT0( std::string const &line );
bool readBPT(int ln, std::string line); //Q 20160721 bool readMPT( std::string const &line ); //Q 20160717
bool readMPTElectricSeries( std::string const &line );
bool readMPTDieselElectric( std::string const &line );
bool readMPTDieselEngine( std::string const &line );
bool readRList(int const ln, std::string const &line); //Q 20160718
bool readBPT(/*int const ln,*/ std::string const &line); //Q 20160721
bool readDList( std::string const &line );
bool readFFList( std::string const &line );
bool readWWList( std::string const &line );
void BrakeValveDecode( std::string s ); //Q 20160719 void BrakeValveDecode( std::string s ); //Q 20160719
void BrakeSubsystemDecode(); //Q 20160719 void BrakeSubsystemDecode(); //Q 20160719
void PowerParamDecode(std::string lines, std::string prefix, TPowerParameters &PowerParamDecode); //Q 20160719 void PowerParamDecode(std::string lines, std::string prefix, TPowerParameters &PowerParamDecode); //Q 20160719
@@ -1127,23 +1140,32 @@ public:
extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2); extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);
template <typename _Type> template <typename _Type>
bool getkeyval( _Type &Variable, std::string const &Key, std::string const &Input ) { bool getkeyval( _Type &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) {
std::string value;
auto lookup = Input.find( Key + "=" ); auto lookup = Input.find( Key + "=" );
if( lookup == std::string::npos ) { if( lookup != std::string::npos ) {
return false; } value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
std::string value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
lookup = value.find( ' ' ); lookup = value.find( ' ' );
if( lookup != std::string::npos ) { if( lookup != std::string::npos ) {
// trim everything past the value // trim everything past the value
value.erase( lookup ); value.erase( lookup );
} }
if( true == value.empty() ) {
return false;
} }
if( false == value.empty() ) {
// set the specified variable to retrieved value // set the specified variable to retrieved value
std::stringstream converter; std::stringstream converter;
converter << value; converter << value;
converter >> Variable; converter >> Variable;
return true; // all done return true; // located the variable
}
else {
// set the variable to provided default value
if( false == Default.empty() ) {
std::stringstream converter;
converter << Default;
converter >> Variable;
}
return false; // supplied the default
}
} }

File diff suppressed because it is too large Load Diff

View File

@@ -193,7 +193,8 @@ double TBrakeCyl::P()
static double const cD = 1; static double const cD = 1;
static double const pD = VD - cD; static double const pD = VD - cD;
double VtoC = Vol / Cap; // stosunek cisnienia do objetosci double VtoC = ( Cap > 0.0 ) ? Vol / Cap : 0.0; // stosunek cisnienia do objetosci.
// Added div/0 trap for vehicles with incomplete definitions (cars etc)
// P:=VtoC; // P:=VtoC;
if (VtoC < VS) if (VtoC < VS)
return VtoC * pS / VS; // objetosc szkodliwa return VtoC * pS / VS; // objetosc szkodliwa

View File

@@ -79,6 +79,10 @@ bool cParser::getTokens(int Count, bool ToLower, const char *Break)
for (i = 0; i < Count; ++i) for (i = 0; i < Count; ++i)
{ {
std::string string = readToken(ToLower, Break); std::string string = readToken(ToLower, Break);
if( true == string.empty() ) {
// no more tokens
break;
}
// collect parameters // collect parameters
if (i == 0) if (i == 0)
this->str(string); this->str(string);