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

Merge branch 'milek-dev'

This commit is contained in:
milek7
2018-06-12 19:09:56 +02:00
12 changed files with 300 additions and 149 deletions

View File

@@ -148,6 +148,7 @@ set_target_properties( ${PROJECT_NAME}
DEBUG_POSTFIX "_d" DEBUG_POSTFIX "_d"
) )
cmake_policy(SET CMP0072 NEW)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES}) target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})

View File

@@ -1534,12 +1534,15 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
LogFile.open( std::string( "physicslog/" + VehicleName + ".dat" ), LogFile.open( std::string( "physicslog/" + VehicleName + ".dat" ),
std::ios::in | std::ios::out | std::ios::trunc ); std::ios::in | std::ios::out | std::ios::trunc );
#if LOGPRESS == 0 #if LOGPRESS == 0
LogFile << std::string( " Time [s] Velocity [m/s] Acceleration [m/ss] Coupler.Dist[m] " LogFile
"Coupler.Force[N] TractionForce [kN] FrictionForce [kN] " << "Time[s] Velocity[m/s] Acceleration[m/ss] "
"BrakeForce [kN] BrakePress [MPa] PipePress [MPa] " << "Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] "
"MotorCurrent [A] MCP SCP BCP LBP DmgFlag Command CVal1 CVal2" ) << "BrakePress[MPa] PipePress[MPa] MotorCurrent[A] "
.c_str() << "MCP SCP BCP LBP Direction Command CVal1 CVal2 "
<< "Security Wheelslip "
<< "EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg]"
<< "\r\n"; << "\r\n";
LogFile << std::fixed << std::setprecision( 4 );
#endif #endif
#if LOGPRESS == 1 #if LOGPRESS == 1
LogFile << string( "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP" ).c_str() << "\n"; LogFile << string( "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP" ).c_str() << "\n";
@@ -3538,20 +3541,40 @@ void TController::PhysicsLog()
if (LogFile.is_open()) if (LogFile.is_open())
{ {
#if LOGPRESS == 0 #if LOGPRESS == 0
LogFile << ElapsedTime << " " << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) /*
<< " "; << "Time[s] Velocity[m/s] Acceleration[m/ss] "
LogFile << mvControlling->AccS << " " << mvOccupied->Couplers[1].Dist << " " << "Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] "
<< mvOccupied->Couplers[1].CForce << " "; << "BrakePress[MPa] PipePress[MPa] MotorCurrent[A] "
LogFile << mvOccupied->Ft << " " << mvOccupied->Ff << " " << mvOccupied->Fb << " " << "MCP SCP BCP LBP DmgFlag Command CVal1 CVal2 "
<< mvOccupied->BrakePress << " "; << "EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg]"
LogFile << mvOccupied->PipePress << " " << mvControlling->Im << " " */
<< int(mvControlling->MainCtrlPos) << " "; LogFile
LogFile << int(mvControlling->ScndCtrlPos) << " " << int(mvOccupied->BrakeCtrlPos) << ElapsedTime << " "
<< " " << int(mvOccupied->LocalBrakePos) << " "; << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) << " "
LogFile << int(mvControlling->ActiveDir) << " " << mvOccupied->CommandIn.Command.c_str() << mvControlling->AccS << " "
<< " " << mvOccupied->CommandIn.Value1 << " "; << mvOccupied->Couplers[1].Dist << " "
LogFile << mvOccupied->CommandIn.Value2 << " " << int(mvControlling->SecuritySystem.Status) << mvOccupied->Couplers[1].CForce << " "
<< " " << int(mvControlling->SlippingWheels) << "\r\n"; << mvOccupied->Ft << " "
<< mvOccupied->Ff << " "
<< mvOccupied->Fb << " "
<< mvOccupied->BrakePress << " "
<< mvOccupied->PipePress << " "
<< mvControlling->Im << " "
<< int(mvControlling->MainCtrlPos) << " "
<< int(mvControlling->ScndCtrlPos) << " "
<< int(mvOccupied->BrakeCtrlPos) << " "
<< int(mvOccupied->LocalBrakePos) << " "
<< int(mvControlling->ActiveDir) << " "
<< ( mvOccupied->CommandIn.Command.empty() ? "none" : mvOccupied->CommandIn.Command.c_str() ) << " "
<< mvOccupied->CommandIn.Value1 << " "
<< mvOccupied->CommandIn.Value2 << " "
<< int(mvControlling->SecuritySystem.Status) << " "
<< int(mvControlling->SlippingWheels) << " "
<< mvControlling->dizel_heat.Ts << " "
<< mvControlling->dizel_heat.To << " "
<< mvControlling->dizel_heat.temperatura1 << " "
<< mvControlling->dizel_heat.temperatura2
<< "\r\n";
#endif #endif
#if LOGPRESS == 1 #if LOGPRESS == 1
LogFile << ElapsedTime << "\t" << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) LogFile << ElapsedTime << "\t" << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot)

View File

@@ -42,6 +42,16 @@ std::string const TDynamicObject::MED_labels[] = {
bool TDynamicObject::bDynamicRemove { false }; bool TDynamicObject::bDynamicRemove { false };
// helper, locates submodel with specified name in specified 3d model; returns: pointer to the submodel, or null
TSubModel *
GetSubmodelFromName( TModel3d * const Model, std::string const Name ) {
return (
Model ?
Model->GetFromName( Name ) :
nullptr );
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void TAnimPant::AKP_4E() void TAnimPant::AKP_4E()
{ // ustawienie wymiarów dla pantografu AKP-4E { // ustawienie wymiarów dla pantografu AKP-4E
@@ -3633,14 +3643,31 @@ bool TDynamicObject::Update(double dt, double dt1)
} }
// NBMX Obsluga drzwi, MC: zuniwersalnione // NBMX Obsluga drzwi, MC: zuniwersalnione
// TODO: fully generalized door assembly
if( ( dDoorMoveL < MoverParameters->DoorMaxShiftL ) if( ( dDoorMoveL < MoverParameters->DoorMaxShiftL )
&& ( true == MoverParameters->DoorLeftOpened ) ) { && ( true == MoverParameters->DoorLeftOpened ) ) {
dDoorMoveL += dt1 * MoverParameters->DoorOpenSpeed; // open left door
dDoorMoveL = std::min( dDoorMoveL, MoverParameters->DoorMaxShiftL ); if( ( MoverParameters->TrainType == dt_EZT )
|| ( MoverParameters->TrainType == dt_DMU ) ) {
// multi-unit vehicles typically open door only after unfolding the doorstep
if( ( MoverParameters->PlatformMaxShift == 0.0 ) // no wait if no doorstep
|| ( MoverParameters->PlatformOpenMethod == 2 ) // no wait for rotating doorstep
|| ( dDoorstepMoveL == 1.0 ) ) {
dDoorMoveL = std::min(
MoverParameters->DoorMaxShiftL,
dDoorMoveL + MoverParameters->DoorOpenSpeed * dt1 );
}
}
else {
dDoorMoveL = std::min(
MoverParameters->DoorMaxShiftL,
dDoorMoveL + MoverParameters->DoorOpenSpeed * dt1 );
}
DoorDelayL = 0.f; DoorDelayL = 0.f;
} }
if( ( dDoorMoveL > 0.0 ) if( ( dDoorMoveL > 0.0 )
&& ( false == MoverParameters->DoorLeftOpened ) ) { && ( false == MoverParameters->DoorLeftOpened ) ) {
// close left door
DoorDelayL += dt1; DoorDelayL += dt1;
if( DoorDelayL > MoverParameters->DoorCloseDelay ) { if( DoorDelayL > MoverParameters->DoorCloseDelay ) {
dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed; dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed;
@@ -3649,12 +3676,28 @@ bool TDynamicObject::Update(double dt, double dt1)
} }
if( ( dDoorMoveR < MoverParameters->DoorMaxShiftR ) if( ( dDoorMoveR < MoverParameters->DoorMaxShiftR )
&& ( true == MoverParameters->DoorRightOpened ) ) { && ( true == MoverParameters->DoorRightOpened ) ) {
dDoorMoveR += dt1 * MoverParameters->DoorOpenSpeed; // open right door
dDoorMoveR = std::min( dDoorMoveR, MoverParameters->DoorMaxShiftR ); if( ( MoverParameters->TrainType == dt_EZT )
|| ( MoverParameters->TrainType == dt_DMU ) ) {
// multi-unit vehicles typically open door only after unfolding the doorstep
if( ( MoverParameters->PlatformMaxShift == 0.0 ) // no wait if no doorstep
|| ( MoverParameters->PlatformOpenMethod == 2 ) // no wait for rotating doorstep
|| ( dDoorstepMoveR == 1.0 ) ) {
dDoorMoveR = std::min(
MoverParameters->DoorMaxShiftR,
dDoorMoveR + MoverParameters->DoorOpenSpeed * dt1 );
}
}
else {
dDoorMoveR = std::min(
MoverParameters->DoorMaxShiftR,
dDoorMoveR + MoverParameters->DoorOpenSpeed * dt1 );
}
DoorDelayR = 0.f; DoorDelayR = 0.f;
} }
if( ( dDoorMoveR > 0.0 ) if( ( dDoorMoveR > 0.0 )
&& ( false == MoverParameters->DoorRightOpened ) ) { && ( false == MoverParameters->DoorRightOpened ) ) {
// close right door
DoorDelayR += dt1; DoorDelayR += dt1;
if( DoorDelayR > MoverParameters->DoorCloseDelay ) { if( DoorDelayR > MoverParameters->DoorCloseDelay ) {
dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed; dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed;
@@ -3664,6 +3707,7 @@ bool TDynamicObject::Update(double dt, double dt1)
// doorsteps // doorsteps
if( ( dDoorstepMoveL < 1.0 ) if( ( dDoorstepMoveL < 1.0 )
&& ( true == MoverParameters->DoorLeftOpened ) ) { && ( true == MoverParameters->DoorLeftOpened ) ) {
// unfold left doorstep
dDoorstepMoveL = std::min( dDoorstepMoveL = std::min(
1.0, 1.0,
dDoorstepMoveL + MoverParameters->PlatformSpeed * dt1 ); dDoorstepMoveL + MoverParameters->PlatformSpeed * dt1 );
@@ -3671,12 +3715,25 @@ bool TDynamicObject::Update(double dt, double dt1)
if( ( dDoorstepMoveL > 0.0 ) if( ( dDoorstepMoveL > 0.0 )
&& ( false == MoverParameters->DoorLeftOpened ) && ( false == MoverParameters->DoorLeftOpened )
&& ( DoorDelayL > MoverParameters->DoorCloseDelay ) ) { && ( DoorDelayL > MoverParameters->DoorCloseDelay ) ) {
dDoorstepMoveL = std::max( // fold left doorstep
0.0, if( ( MoverParameters->TrainType == dt_EZT )
dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 ); || ( MoverParameters->TrainType == dt_DMU ) ) {
// multi-unit vehicles typically fold the doorstep only after closing the door
if( dDoorMoveL == 0.0 ) {
dDoorstepMoveL = std::max(
0.0,
dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 );
}
}
else {
dDoorstepMoveL = std::max(
0.0,
dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 );
}
} }
if( ( dDoorstepMoveR < 1.0 ) if( ( dDoorstepMoveR < 1.0 )
&& ( true == MoverParameters->DoorRightOpened ) ) { && ( true == MoverParameters->DoorRightOpened ) ) {
// unfold right doorstep
dDoorstepMoveR = std::min( dDoorstepMoveR = std::min(
1.0, 1.0,
dDoorstepMoveR + MoverParameters->PlatformSpeed * dt1 ); dDoorstepMoveR + MoverParameters->PlatformSpeed * dt1 );
@@ -3684,9 +3741,21 @@ bool TDynamicObject::Update(double dt, double dt1)
if( ( dDoorstepMoveR > 0.0 ) if( ( dDoorstepMoveR > 0.0 )
&& ( false == MoverParameters->DoorRightOpened ) && ( false == MoverParameters->DoorRightOpened )
&& ( DoorDelayR > MoverParameters->DoorCloseDelay ) ) { && ( DoorDelayR > MoverParameters->DoorCloseDelay ) ) {
dDoorstepMoveR = std::max( // fold right doorstep
0.0, if( ( MoverParameters->TrainType == dt_EZT )
dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 ); || ( MoverParameters->TrainType == dt_DMU ) ) {
// multi-unit vehicles typically fold the doorstep only after closing the door
if( dDoorMoveR == 0.0 ) {
dDoorstepMoveR = std::max(
0.0,
dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 );
}
}
else {
dDoorstepMoveR = std::max(
0.0,
dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 );
}
} }
// mirrors // mirrors
if( MoverParameters->Vel > 5.0 ) { if( MoverParameters->Vel > 5.0 ) {
@@ -4045,10 +4114,13 @@ void TDynamicObject::RenderSounds() {
} }
} }
// NBMX Obsluga drzwi, MC: zuniwersalnione // NBMX Obsluga drzwi, MC: zuniwersalnione
// TODO: fully generalized door assembly
if( true == MoverParameters->DoorLeftOpened ) { if( true == MoverParameters->DoorLeftOpened ) {
// open left door // open left door
// door sounds // door sounds
if( dDoorMoveL < MoverParameters->DoorMaxShiftL ) { // due to potential wait for the doorstep we play the sound only during actual animation
if( ( dDoorMoveL > 0.0 )
&& ( dDoorMoveL < MoverParameters->DoorMaxShiftL ) ) {
for( auto &door : m_doorsounds ) { for( auto &door : m_doorsounds ) {
if( door.rsDoorClose.offset().x > 0.f ) { if( door.rsDoorClose.offset().x > 0.f ) {
// determine left side doors from their offset // determine left side doors from their offset
@@ -4095,7 +4167,9 @@ void TDynamicObject::RenderSounds() {
if( true == MoverParameters->DoorRightOpened ) { if( true == MoverParameters->DoorRightOpened ) {
// open right door // open right door
// door sounds // door sounds
if( dDoorMoveR < MoverParameters->DoorMaxShiftR ) { // due to potential wait for the doorstep we play the sound only during actual animation
if( ( dDoorMoveR > 0.0 )
&& ( dDoorMoveR < MoverParameters->DoorMaxShiftR ) ) {
for( auto &door : m_doorsounds ) { for( auto &door : m_doorsounds ) {
if( door.rsDoorClose.offset().x < 0.f ) { if( door.rsDoorClose.offset().x < 0.f ) {
// determine right side doors from their offset // determine right side doors from their offset
@@ -4358,7 +4432,7 @@ void TDynamicObject::RenderSounds() {
// wczytywanie pliku z danymi multimedialnymi (dzwieki) // wczytywanie pliku z danymi multimedialnymi (dzwieki)
void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName, std::string ReplacableSkin ) { void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName, std::string ReplacableSkin ) {
double dSDist; replace_slashes( BaseDir );
Global.asCurrentDynamicPath = BaseDir; Global.asCurrentDynamicPath = BaseDir;
std::string asFileName = BaseDir + TypeName + ".mmd"; std::string asFileName = BaseDir + TypeName + ".mmd";
std::string asLoadName; std::string asLoadName;
@@ -4406,10 +4480,9 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
asModel = BaseDir + asModel; // McZapkie 2002-07-20: dynamics maja swoje modele w dynamics/basedir asModel = BaseDir + asModel; // McZapkie 2002-07-20: dynamics maja swoje modele w dynamics/basedir
Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/... Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/...
mdModel = TModelsManager::GetModel(asModel, true); mdModel = TModelsManager::GetModel(asModel, true);
assert( mdModel != nullptr ); // TODO: handle this more gracefully than all going to shit
if (ReplacableSkin != "none") if (ReplacableSkin != "none")
{ {
std::string nowheretexture = TextureTest(Global.asCurrentTexturePath + "nowhere"); // na razie prymitywnie std::string nowheretexture = TextureTest( Global.asCurrentTexturePath + "nowhere" ); // na razie prymitywnie
if( false == nowheretexture.empty() ) { if( false == nowheretexture.empty() ) {
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Material( nowheretexture ); m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Material( nowheretexture );
} }
@@ -4423,9 +4496,8 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
int skinindex = 0; int skinindex = 0;
std::string texturename; nameparser >> texturename; std::string texturename; nameparser >> texturename;
while( ( texturename != "" ) && ( skinindex < 4 ) ) { while( ( texturename != "" ) && ( skinindex < 4 ) ) {
erase_extension( texturename );
std::replace(texturename.begin(), texturename.end(), '\\', '/'); std::replace(texturename.begin(), texturename.end(), '\\', '/');
m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + texturename ); m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.Fetch_Material( texturename );
++skinindex; ++skinindex;
texturename = ""; nameparser >> texturename; texturename = ""; nameparser >> texturename;
} }
@@ -4436,7 +4508,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
erase_extension( ReplacableSkin ); erase_extension( ReplacableSkin );
int skinindex = 0; int skinindex = 0;
do { do {
material_handle material = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + ReplacableSkin + "," + std::to_string( skinindex + 1 ), true ); material_handle material = GfxRenderer.Fetch_Material( ReplacableSkin + "," + std::to_string( skinindex + 1 ), true );
if( material == null_handle ) { if( material == null_handle ) {
break; break;
} }
@@ -4446,12 +4518,12 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
m_materialdata.multi_textures = skinindex; m_materialdata.multi_textures = skinindex;
if( m_materialdata.multi_textures == 0 ) { if( m_materialdata.multi_textures == 0 ) {
// zestaw nie zadziałał, próbujemy normanie // zestaw nie zadziałał, próbujemy normanie
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + ReplacableSkin ); m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( ReplacableSkin );
} }
} }
} }
else { else {
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + ReplacableSkin ); m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( ReplacableSkin );
} }
if( GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) { if( GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) {
// tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
@@ -4579,7 +4651,13 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
// ABu: wnetrze lowpoly // ABu: wnetrze lowpoly
parser.getTokens(); parser.getTokens();
parser >> asModel; parser >> asModel;
std::replace(asModel.begin(), asModel.end(), '\\', '/');
replace_slashes( asModel );
if( asModel[ 0 ] == '/' ) {
// filename can potentially begin with a slash, and we don't need it
asModel.erase( 0, 1 );
}
asModel = BaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir asModel = BaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir
Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/... Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/...
mdLowPolyInt = TModelsManager::GetModel(asModel, true); mdLowPolyInt = TModelsManager::GetModel(asModel, true);
@@ -4589,7 +4667,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
// Ra 15-01: gałka nastawy hamulca // Ra 15-01: gałka nastawy hamulca
parser.getTokens(); parser.getTokens();
parser >> asAnimName; parser >> asAnimName;
smBrakeMode = mdModel->GetFromName(asAnimName); smBrakeMode = GetSubmodelFromName( mdModel, asAnimName );
// jeszcze wczytać kąty obrotu dla poszczególnych ustawień // jeszcze wczytać kąty obrotu dla poszczególnych ustawień
} }
@@ -4597,7 +4675,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
// Ra 15-01: gałka nastawy hamulca // Ra 15-01: gałka nastawy hamulca
parser.getTokens(); parser.getTokens();
parser >> asAnimName; parser >> asAnimName;
smLoadMode = mdModel->GetFromName(asAnimName); smLoadMode = GetSubmodelFromName( mdModel, asAnimName );
// jeszcze wczytać kąty obrotu dla poszczególnych ustawień // jeszcze wczytać kąty obrotu dla poszczególnych ustawień
} }
@@ -4609,7 +4687,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
for (i = 0; i < iAnimType[ANIM_WHEELS]; ++i) // liczba osi for (i = 0; i < iAnimType[ANIM_WHEELS]; ++i) // liczba osi
{ // McZapkie-050402: wyszukiwanie kol o nazwie str* { // McZapkie-050402: wyszukiwanie kol o nazwie str*
asAnimName = token + std::to_string(i + 1); asAnimName = token + std::to_string(i + 1);
pAnimations[i].smAnimated = mdModel->GetFromName(asAnimName); // ustalenie submodelu pAnimations[i].smAnimated = GetSubmodelFromName( mdModel, asAnimName );
if (pAnimations[i].smAnimated) if (pAnimations[i].smAnimated)
{ //++iAnimatedAxles; { //++iAnimatedAxles;
pAnimations[i].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu pAnimations[i].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
@@ -4672,7 +4750,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
for (int i = 0; i < iAnimType[ANIM_PANTS]; i++) for (int i = 0; i < iAnimType[ANIM_PANTS]; i++)
{ // Winger 160204: wyszukiwanie max 2 patykow o nazwie str* { // Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
asAnimName = token + std::to_string(i + 1); asAnimName = token + std::to_string(i + 1);
sm = mdModel->GetFromName(asAnimName); sm = GetSubmodelFromName( mdModel, asAnimName );
pants[i].smElement[0] = sm; // jak NULL, to nie będzie animowany pants[i].smElement[0] = sm; // jak NULL, to nie będzie animowany
if (sm) if (sm)
{ // w EP09 wywalało się tu z powodu NULL { // w EP09 wywalało się tu z powodu NULL
@@ -4681,27 +4759,22 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
// m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak) // m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak)
if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z T3D if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z T3D
m.InitialRotate(); // może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, tzn. przed wykonaniem Init() m.InitialRotate(); // może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, tzn. przed wykonaniem Init()
pants[i].fParamPants->vPos.z = pants[i].fParamPants->vPos.z = m[3][0]; // przesunięcie w bok (asymetria)
m[3][0]; // przesunięcie w bok (asymetria) pants[i].fParamPants->vPos.y = m[3][1]; // przesunięcie w górę odczytane z modelu
pants[i].fParamPants->vPos.y =
m[3][1]; // przesunięcie w górę odczytane z modelu
if ((sm = pants[i].smElement[0]->ChildGet()) != NULL) if ((sm = pants[i].smElement[0]->ChildGet()) != NULL)
{ // jeśli ma potomny, można policzyć długość (odległość potomnego od osi obrotu) { // jeśli ma potomny, można policzyć długość (odległość potomnego od osi obrotu)
m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik, nie trzeba kopiować m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik, nie trzeba kopiować
// może trzeba: pobrać macierz dolnego ramienia, wyzerować przesunięcie, przemnożyć przez macierz górnego // może trzeba: pobrać macierz dolnego ramienia, wyzerować przesunięcie, przemnożyć przez macierz górnego
pants[i].fParamPants->fHoriz = -fabs(m[3][1]); pants[i].fParamPants->fHoriz = -fabs(m[3][1]);
pants[i].fParamPants->fLenL1 = pants[i].fParamPants->fLenL1 = hypot(m[3][1], m[3][2]); // po osi OX nie potrzeba
hypot(m[3][1], m[3][2]); // po osi OX nie potrzeba pants[i].fParamPants->fAngleL0 = atan2(fabs(m[3][2]), fabs(m[3][1]));
pants[i].fParamPants->fAngleL0 =
atan2(fabs(m[3][2]), fabs(m[3][1]));
// if (pants[i].fParamPants->fAngleL0<M_PI_2) // if (pants[i].fParamPants->fAngleL0<M_PI_2)
// pants[i].fParamPants->fAngleL0+=M_PI; //gdyby w odwrotną stronę wyszło // pants[i].fParamPants->fAngleL0+=M_PI; //gdyby w odwrotną stronę wyszło
// if // if
// ((pants[i].fParamPants->fAngleL0<0.03)||(pants[i].fParamPants->fAngleL0>0.09)) // ((pants[i].fParamPants->fAngleL0<0.03)||(pants[i].fParamPants->fAngleL0>0.09))
// //normalnie ok. 0.05 // //normalnie ok. 0.05
// pants[i].fParamPants->fAngleL0=pants[i].fParamPants->fAngleL; // pants[i].fParamPants->fAngleL0=pants[i].fParamPants->fAngleL;
pants[i].fParamPants->fAngleL = pants[i].fParamPants->fAngleL0; // początkowy kąt dolnego pants[i].fParamPants->fAngleL = pants[i].fParamPants->fAngleL0; // początkowy kąt dolnego ramienia
// ramienia
if ((sm = sm->ChildGet()) != NULL) if ((sm = sm->ChildGet()) != NULL)
{ // jeśli dalej jest ślizg, można policzyć długość górnego ramienia { // jeśli dalej jest ślizg, można policzyć długość górnego ramienia
m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik, m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik,
@@ -4727,12 +4800,9 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
float det = Det(m); float det = Det(m);
if (std::fabs(det - 1.0) < 0.001) // dopuszczamy 1 promil błędu na skalowaniu ślizgu if (std::fabs(det - 1.0) < 0.001) // dopuszczamy 1 promil błędu na skalowaniu ślizgu
{ // skalowanie jest w normie, można pobrać wymiary z modelu { // skalowanie jest w normie, można pobrać wymiary z modelu
pants[i].fParamPants->fHeight = pants[i].fParamPants->fHeight = sm->MaxY(m); // przeliczenie maksimum wysokości wierzchołków względem macierzy
sm->MaxY(m); // przeliczenie maksimum wysokości wierzchołków względem macierzy pants[i].fParamPants->fHeight -= m[3][1]; // odjęcie wysokości pivota ślizgu
pants[i].fParamPants->fHeight -= pants[i].fParamPants->vPos.x = m[3][2]; // przy okazji odczytać z modelu pozycję w długości
m[3][1]; // odjęcie wysokości pivota ślizgu
pants[i].fParamPants->vPos.x =
m[3][2]; // przy okazji odczytać z modelu pozycję w długości
// ErrorLog("Model OK: "+asModel+", // ErrorLog("Model OK: "+asModel+",
// height="+pants[i].fParamPants->fHeight); // height="+pants[i].fParamPants->fHeight);
// ErrorLog("Model OK: "+asModel+", // ErrorLog("Model OK: "+asModel+",
@@ -4740,8 +4810,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
} }
else else
{ // gdy ktoś przesadził ze skalowaniem { // gdy ktoś przesadził ze skalowaniem
pants[i].fParamPants->fHeight = pants[i].fParamPants->fHeight = 0.0; // niech będzie odczyt z pantfactors:
0.0; // niech będzie odczyt z pantfactors:
ErrorLog( ErrorLog(
"Bad model: " + asModel + ", scale of " + (sm->pName) + " is " + std::to_string(100.0 * det) + "%", "Bad model: " + asModel + ", scale of " + (sm->pName) + " is " + std::to_string(100.0 * det) + "%",
logtype::model ); logtype::model );
@@ -4749,8 +4818,11 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
} }
} }
} }
else else {
ErrorLog("Bad model: " + asFileName + " - missed submodel " + asAnimName, logtype::model); // brak ramienia // brak ramienia
pants[ i ].fParamPants->fHeight = 0.0; // niech będzie odczyt z pantfactors:
ErrorLog( "Bad model: " + asFileName + " - missed submodel " + asAnimName, logtype::model );
}
} }
} }
@@ -4763,7 +4835,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str* // Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
asAnimName = token + std::to_string( i + 1 ); asAnimName = token + std::to_string( i + 1 );
sm = mdModel->GetFromName( asAnimName ); sm = GetSubmodelFromName( mdModel, asAnimName );
pants[ i ].smElement[ 1 ] = sm; // jak NULL, to nie będzie animowany pants[ i ].smElement[ 1 ] = sm; // jak NULL, to nie będzie animowany
if( sm ) { // w EP09 wywalało się tu z powodu NULL if( sm ) { // w EP09 wywalało się tu z powodu NULL
sm->WillBeAnimated(); sm->WillBeAnimated();
@@ -4792,43 +4864,49 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
else if( token == "animpantrg1prefix:" ) { else if( token == "animpantrg1prefix:" ) {
// prefiks ramion górnych 1 // prefiks ramion górnych 1
parser.getTokens(); parser >> token; parser.getTokens(); parser >> token;
if( pants ) { if( pants ) {
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str* // Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
asAnimName = token + std::to_string( i + 1 ); asAnimName = token + std::to_string( i + 1 );
pants[ i ].smElement[ 2 ] = mdModel->GetFromName( asAnimName ); pants[ i ].smElement[ 2 ] = GetSubmodelFromName( mdModel, asAnimName );
pants[ i ].smElement[ 2 ]->WillBeAnimated(); if( pants[ i ].smElement[ 2 ] ) {
} pants[ i ].smElement[ 2 ]->WillBeAnimated();
}
} }
}
} }
else if( token == "animpantrg2prefix:" ) { else if( token == "animpantrg2prefix:" ) {
// prefiks ramion górnych 2 // prefiks ramion górnych 2
parser.getTokens(); parser >> token; parser.getTokens(); parser >> token;
if( pants ) { if( pants ) {
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str* // Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
asAnimName = token + std::to_string( i + 1 ); asAnimName = token + std::to_string( i + 1 );
pants[ i ].smElement[ 3 ] = mdModel->GetFromName( asAnimName ); pants[ i ].smElement[ 3 ] = GetSubmodelFromName( mdModel, asAnimName );
pants[ i ].smElement[ 3 ]->WillBeAnimated(); if( pants[ i ].smElement[ 3 ] ) {
} pants[ i ].smElement[ 3 ]->WillBeAnimated();
}
} }
}
} }
else if( token == "animpantslprefix:" ) { else if( token == "animpantslprefix:" ) {
// prefiks ślizgaczy // prefiks ślizgaczy
parser.getTokens(); parser >> token; parser.getTokens(); parser >> token;
if( pants ) { if( pants ) {
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str* // Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
asAnimName = token + std::to_string( i + 1 ); asAnimName = token + std::to_string( i + 1 );
pants[ i ].smElement[ 4 ] = mdModel->GetFromName( asAnimName ); pants[ i ].smElement[ 4 ] = GetSubmodelFromName( mdModel, asAnimName );
pants[ i ].smElement[ 4 ]->WillBeAnimated(); if( pants[ i ].smElement[ 4 ] ) {
pants[ i ].yUpdate = std::bind( &TDynamicObject::UpdatePant, this, std::placeholders::_1 ); pants[ i ].smElement[ 4 ]->WillBeAnimated();
pants[ i ].fMaxDist = 300 * 300; // nie podnosić w większej odległości pants[ i ].yUpdate = std::bind( &TDynamicObject::UpdatePant, this, std::placeholders::_1 );
pants[ i ].iNumber = i; pants[ i ].fMaxDist = 300 * 300; // nie podnosić w większej odległości
} pants[ i ].iNumber = i;
}
} }
}
} }
else if( token == "pantfactors:" ) { else if( token == "pantfactors:" ) {
@@ -4853,34 +4931,38 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
if( pants ) { if( pants ) {
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; ++i ) { for( int i = 0; i < iAnimType[ ANIM_PANTS ]; ++i ) {
// przepisanie współczynników do pantografów (na razie nie będzie lepiej) // przepisanie współczynników do pantografów (na razie nie będzie lepiej)
pants[ i ].fParamPants->fAngleL = pants[ i ].fParamPants->fAngleL0; // początkowy kąt dolnego ramienia auto &pantograph { *(pants[ i ].fParamPants) };
pants[ i ].fParamPants->fAngleU = pants[ i ].fParamPants->fAngleU0; // początkowy kąt
pantograph.fAngleL = pantograph.fAngleL0; // początkowy kąt dolnego ramienia
pantograph.fAngleU = pantograph.fAngleU0; // początkowy kąt
// pants[i].fParamPants->PantWys=1.22*sin(pants[i].fParamPants->fAngleL)+1.755*sin(pants[i].fParamPants->fAngleU); // pants[i].fParamPants->PantWys=1.22*sin(pants[i].fParamPants->fAngleL)+1.755*sin(pants[i].fParamPants->fAngleU);
// //wysokość początkowa // //wysokość początkowa
// pants[i].fParamPants->PantWys=1.176289*sin(pants[i].fParamPants->fAngleL)+1.724482197*sin(pants[i].fParamPants->fAngleU); // pants[i].fParamPants->PantWys=1.176289*sin(pants[i].fParamPants->fAngleL)+1.724482197*sin(pants[i].fParamPants->fAngleU);
// //wysokość początkowa // //wysokość początkowa
if( pants[ i ].fParamPants->fHeight == 0.0 ) // gdy jest nieprawdopodobna wartość (np. nie znaleziony ślizg) if( pantograph.fHeight == 0.0 ) // gdy jest nieprawdopodobna wartość (np. nie znaleziony ślizg)
{ // gdy pomiary modelu nie udały się, odczyt podanych parametrów z MMD { // gdy pomiary modelu nie udały się, odczyt podanych parametrów z MMD
pants[ i ].fParamPants->vPos.x = pantograph.vPos.x =
( i & 1 ) ? ( i & 1 ) ?
pant2x : pant2x :
pant1x; pant1x;
pants[ i ].fParamPants->fHeight = pantograph.fHeight =
( i & 1 ) ? ( i & 1 ) ?
pant2h : pant2h :
pant1h; // wysokość ślizgu jest zapisana w MMD pant1h; // wysokość ślizgu jest zapisana w MMD
} }
pants[ i ].fParamPants->PantWys = pantograph.PantWys =
pants[ i ].fParamPants->fLenL1 * sin( pants[ i ].fParamPants->fAngleL ) + pantograph.fLenL1 * sin( pantograph.fAngleL ) +
pants[ i ].fParamPants->fLenU1 * sin( pants[ i ].fParamPants->fAngleU ) + pantograph.fLenU1 * sin( pantograph.fAngleU ) +
pants[ i ].fParamPants->fHeight; // wysokość początkowa pantograph.fHeight; // wysokość początkowa
// pants[i].fParamPants->vPos.y=panty-panth-pants[i].fParamPants->PantWys; // pants[i].fParamPants->vPos.y=panty-panth-pants[i].fParamPants->PantWys; //np. 4.429-0.097=4.332=~4.335
// //np. 4.429-0.097=4.332=~4.335 if( pantograph.vPos.y == 0.0 ) {
// pants[i].fParamPants->vPos.z=0; //niezerowe dla pantografów // crude fallback, place the pantograph(s) atop of the vehicle-sized box
// asymetrycznych pantograph.vPos.y = MoverParameters->Dim.H - pantograph.fHeight - pantograph.PantWys;
pants[ i ].fParamPants->PantTraction = pants[ i ].fParamPants->PantWys; }
// pants[i].fParamPants->vPos.z=0; //niezerowe dla pantografów asymetrycznych
pantograph.PantTraction = pantograph.PantWys;
// połowa szerokości ślizgu; jest w "Power: CSW=" // połowa szerokości ślizgu; jest w "Power: CSW="
pants[ i ].fParamPants->fWidth = 0.5 * MoverParameters->EnginePowerSource.CollectorParameters.CSW; pantograph.fWidth = 0.5 * MoverParameters->EnginePowerSource.CollectorParameters.CSW;
// create sound emitters for the pantograph // create sound emitters for the pantograph
m_pantographsounds.emplace_back(); m_pantographsounds.emplace_back();
@@ -4956,11 +5038,13 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
// prefiks wahaczy // prefiks wahaczy
parser.getTokens(); parser >> token; parser.getTokens(); parser >> token;
asAnimName = ""; asAnimName = "";
for (int i = 1; i <= 4; i++) for( int i = 1; i <= 4; ++i ) {
{ // McZapkie-050402: wyszukiwanie max 4 wahaczy o nazwie str* // McZapkie-050402: wyszukiwanie max 4 wahaczy o nazwie str*
asAnimName = token + std::to_string(i); asAnimName = token + std::to_string( i );
smWahacze[i - 1] = mdModel->GetFromName(asAnimName); smWahacze[ i - 1 ] = GetSubmodelFromName( mdModel, asAnimName );
smWahacze[i - 1]->WillBeAnimated(); if( smWahacze[ i - 1 ] ) {
smWahacze[ i - 1 ]->WillBeAnimated();
}
} }
parser.getTokens(); parser >> token; parser.getTokens(); parser >> token;
if( token == "pendulumamplitude:" ) { if( token == "pendulumamplitude:" ) {
@@ -4979,7 +5063,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str* { // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
// ustalenie submodelu // ustalenie submodelu
asAnimName = token + std::to_string(i + 1); asAnimName = token + std::to_string(i + 1);
pAnimations[i + j].smAnimated = mdModel->GetFromName(asAnimName); pAnimations[ i + j ].smAnimated = GetSubmodelFromName( mdModel, asAnimName );
if (pAnimations[i + j].smAnimated) if (pAnimations[i + j].smAnimated)
{ //++iAnimatedDoors; { //++iAnimatedDoors;
pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
@@ -5021,7 +5105,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str* { // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
// ustalenie submodelu // ustalenie submodelu
asAnimName = token + std::to_string(i + 1); asAnimName = token + std::to_string(i + 1);
pAnimations[i + j].smAnimated = mdModel->GetFromName(asAnimName); pAnimations[i + j].smAnimated = GetSubmodelFromName( mdModel, asAnimName );
if (pAnimations[i + j].smAnimated) if (pAnimations[i + j].smAnimated)
{ //++iAnimatedDoors; { //++iAnimatedDoors;
pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
@@ -5057,7 +5141,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str* { // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
// ustalenie submodelu // ustalenie submodelu
asAnimName = token + std::to_string( i + 1 ); asAnimName = token + std::to_string( i + 1 );
pAnimations[ i + j ].smAnimated = mdModel->GetFromName( asAnimName ); pAnimations[ i + j ].smAnimated = GetSubmodelFromName( mdModel, asAnimName );
if( pAnimations[ i + j ].smAnimated ) { if( pAnimations[ i + j ].smAnimated ) {
pAnimations[ i + j ].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu pAnimations[ i + j ].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
// od razu zapinamy potrzebny typ animacji // od razu zapinamy potrzebny typ animacji
@@ -5092,6 +5176,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
parser.getTokens(); parser >> token; parser.getTokens(); parser >> token;
if( token == "wheel_clatter:" ){ if( token == "wheel_clatter:" ){
// polozenia osi w/m srodka pojazdu // polozenia osi w/m srodka pojazdu
double dSDist;
parser.getTokens( 1, false ); parser.getTokens( 1, false );
parser >> dSDist; parser >> dSDist;
while( ( ( token = parser.getToken<std::string>() ) != "" ) while( ( ( token = parser.getToken<std::string>() ) != "" )

View File

@@ -947,7 +947,7 @@ public:
int DoorOpenMethod = 2; /*sposob otwarcia - 1: przesuwne, 2: obrotowe, 3: trójelementowe*/ int DoorOpenMethod = 2; /*sposob otwarcia - 1: przesuwne, 2: obrotowe, 3: trójelementowe*/
float DoorCloseDelay { 0.f }; // delay (in seconds) before the door begin closing, once conditions to close are met float DoorCloseDelay { 0.f }; // delay (in seconds) before the door begin closing, once conditions to close are met
double PlatformSpeed = 0.5; /*szybkosc stopnia*/ double PlatformSpeed = 0.5; /*szybkosc stopnia*/
double PlatformMaxShift { 45.0 }; /*wysuniecie stopnia*/ double PlatformMaxShift { 0.0 }; /*wysuniecie stopnia*/
int PlatformOpenMethod { 2 }; /*sposob animacji stopnia*/ int PlatformOpenMethod { 2 }; /*sposob animacji stopnia*/
double MirrorMaxShift { 90.0 }; double MirrorMaxShift { 90.0 };
bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/ bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/

View File

@@ -4680,10 +4680,11 @@ double TMoverParameters::TractionForce(double dt)
case DieselEngine: case DieselEngine:
{ {
EnginePower = dmoment * enrot; EnginePower = ( 2 * dizel_Mstand + dmoment ) * enrot * ( 2.0 * M_PI / 1000.0 );
if (MainCtrlPos > 1) if( MainCtrlPos > 1 ) {
dmoment -= // dodatkowe opory z powodu sprezarki}
dizel_Mstand * (0.2 * enrot / dizel_nmax); // dodatkowe opory z powodu sprezarki} dmoment -= dizel_Mstand * ( 0.2 * enrot / dizel_nmax );
}
Mm = dmoment; //bylo * dizel_engage Mm = dmoment; //bylo * dizel_engage
Mw = Mm * dtrans; // dmoment i dtrans policzone przy okazji enginerotation Mw = Mm * dtrans; // dmoment i dtrans policzone przy okazji enginerotation
Fw = Mw * 2.0 / WheelDiameter / NPoweredAxles; Fw = Mw * 2.0 / WheelDiameter / NPoweredAxles;

View File

@@ -331,12 +331,14 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
m_material = -4; m_material = -4;
iFlags |= (Opacity < 1.0) ? 8 : 0x10; // zmienna tekstura 4 iFlags |= (Opacity < 1.0) ? 8 : 0x10; // zmienna tekstura 4
} }
else else {
{ // jeśli tylko nazwa pliku, to dawać bieżącą ścieżkę do tekstur
Name_Material(material); Name_Material(material);
/*
if( material.find_first_of( "/" ) == material.npos ) { if( material.find_first_of( "/" ) == material.npos ) {
// jeśli tylko nazwa pliku, to dawać bieżącą ścieżkę do tekstur
material.insert( 0, Global.asCurrentTexturePath ); material.insert( 0, Global.asCurrentTexturePath );
} }
*/
m_material = GfxRenderer.Fetch_Material( material ); m_material = GfxRenderer.Fetch_Material( material );
// renderowanie w cyklu przezroczystych tylko jeśli: // renderowanie w cyklu przezroczystych tylko jeśli:
// 1. Opacity=0 (przejściowo <1, czy tam <100) oraz // 1. Opacity=0 (przejściowo <1, czy tam <100) oraz
@@ -1672,9 +1674,11 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
auto const materialindex = static_cast<std::size_t>( iTexture ); auto const materialindex = static_cast<std::size_t>( iTexture );
if( materialindex < t->size() ) { if( materialindex < t->size() ) {
m_materialname = t->at( materialindex ); m_materialname = t->at( materialindex );
/*
if( m_materialname.find_last_of( "/" ) == std::string::npos ) { if( m_materialname.find_last_of( "/" ) == std::string::npos ) {
m_materialname = Global.asCurrentTexturePath + m_materialname; m_materialname = Global.asCurrentTexturePath + m_materialname;
} }
*/
m_material = GfxRenderer.Fetch_Material( m_materialname ); m_material = GfxRenderer.Fetch_Material( m_materialname );
if( ( iFlags & 0x30 ) == 0 ) { if( ( iFlags & 0x30 ) == 0 ) {
// texture-alpha based fallback if for some reason we don't have opacity flag set yet // texture-alpha based fallback if for some reason we don't have opacity flag set yet

View File

@@ -818,6 +818,11 @@ texture_manager::create( std::string Filename, bool const Loadnow ) {
erase_extension( Filename ); erase_extension( Filename );
if( Filename[ 0 ] == '/' ) {
// filename can potentially begin with a slash, and we don't need it
Filename.erase( 0, 1 );
}
std::vector<std::string> extensions{ { ".dds" }, { ".tga" }, { ".png" }, { ".bmp" }, { ".ext" } }; std::vector<std::string> extensions{ { ".dds" }, { ".tga" }, { ".png" }, { ".bmp" }, { ".ext" } };
// try to locate requested texture in the databank // try to locate requested texture in the databank

View File

@@ -336,9 +336,7 @@ std::vector<std::string> const TTrain::fPress_labels = {
}; };
TTrain::TTrain() { TTrain::TTrain() {
/*
Universal4Active = false;
*/
ShowNextCurrent = false; ShowNextCurrent = false;
// McZapkie-240302 - przyda sie do tachometru // McZapkie-240302 - przyda sie do tachometru
fTachoVelocity = 0; fTachoVelocity = 0;
@@ -433,10 +431,10 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
PyObject *TTrain::GetTrainState() { PyObject *TTrain::GetTrainState() {
auto const &mover = DynamicObject->MoverParameters; auto const *mover = DynamicObject->MoverParameters;
auto *dict = PyDict_New(); auto *dict = PyDict_New();
if( ( dict == nullptr ) if( ( dict == nullptr )
|| ( mover == nullptr ) ) { || ( mover == nullptr ) ) {
return nullptr; return nullptr;
} }
@@ -759,7 +757,8 @@ void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data con
if( Command.action != GLFW_RELEASE ) { if( Command.action != GLFW_RELEASE ) {
// on press or hold // on press or hold
if( Train->mvControlled->ShuntMode ) { if( ( Train->mvControlled->EngineType == DieselElectric )
&& ( true == Train->mvControlled->ShuntMode ) ) {
Train->mvControlled->AnPos = clamp( Train->mvControlled->AnPos = clamp(
Train->mvControlled->AnPos + 0.025, Train->mvControlled->AnPos + 0.025,
0.0, 1.0 ); 0.0, 1.0 );
@@ -774,7 +773,13 @@ void TTrain::OnCommand_secondcontrollerincreasefast( TTrain *Train, command_data
if( Command.action != GLFW_RELEASE ) { if( Command.action != GLFW_RELEASE ) {
// on press or hold // on press or hold
Train->mvControlled->IncScndCtrl( 2 ); if( ( Train->mvControlled->EngineType == DieselElectric )
&& ( true == Train->mvControlled->ShuntMode ) ) {
Train->mvControlled->AnPos = 1.0;
}
else {
Train->mvControlled->IncScndCtrl( 2 );
}
} }
} }
@@ -820,12 +825,15 @@ void TTrain::OnCommand_secondcontrollerdecrease( TTrain *Train, command_data con
if( Command.action != GLFW_RELEASE ) { if( Command.action != GLFW_RELEASE ) {
// on press or hold // on press or hold
if( Train->mvControlled->ShuntMode ) { if( ( Train->mvControlled->EngineType == DieselElectric )
&& ( true == Train->mvControlled->ShuntMode ) ) {
Train->mvControlled->AnPos = clamp( Train->mvControlled->AnPos = clamp(
Train->mvControlled->AnPos - 0.025, Train->mvControlled->AnPos - 0.025,
0.0, 1.0 ); 0.0, 1.0 );
} }
Train->mvControlled->DecScndCtrl( 1 ); else {
Train->mvControlled->DecScndCtrl( 1 );
}
} }
} }
@@ -833,7 +841,13 @@ void TTrain::OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data
if( Command.action != GLFW_RELEASE ) { if( Command.action != GLFW_RELEASE ) {
// on press or hold // on press or hold
Train->mvControlled->DecScndCtrl( 2 ); if( ( Train->mvControlled->EngineType == DieselElectric )
&& ( true == Train->mvControlled->ShuntMode ) ) {
Train->mvControlled->AnPos = 0.0;
}
else {
Train->mvControlled->DecScndCtrl( 2 );
}
} }
} }
@@ -5978,6 +5992,11 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
// bieżąca sciezka do tekstur to dynamic/... // bieżąca sciezka do tekstur to dynamic/...
Global.asCurrentTexturePath = DynamicObject->asBaseDir; Global.asCurrentTexturePath = DynamicObject->asBaseDir;
// szukaj kabinę jako oddzielny model // szukaj kabinę jako oddzielny model
// name can contain leading slash, erase it to avoid creation of double slashes when the name is combined with current directory
replace_slashes( token );
if( token[ 0 ] == '/' ) {
token.erase( 0, 1 );
}
TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true); TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true);
// z powrotem defaultowa sciezka do tekstur // z powrotem defaultowa sciezka do tekstur
Global.asCurrentTexturePath = szTexturePath; Global.asCurrentTexturePath = szTexturePath;

10
Train.h
View File

@@ -312,11 +312,11 @@ class TTrain
static void OnCommand_generictoggle( TTrain *Train, command_data const &Command ); static void OnCommand_generictoggle( TTrain *Train, command_data const &Command );
// members // members
TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5] TDynamicObject *DynamicObject { nullptr }; // przestawia zmiana pojazdu [F5]
TMoverParameters *mvControlled; // człon, w którym sterujemy silnikiem TMoverParameters *mvControlled { nullptr }; // człon, w którym sterujemy silnikiem
TMoverParameters *mvOccupied; // człon, w którym sterujemy hamulcem TMoverParameters *mvOccupied { nullptr }; // człon, w którym sterujemy hamulcem
TMoverParameters *mvSecond; // drugi człon (ET40, ET41, ET42, ukrotnienia) TMoverParameters *mvSecond { nullptr }; // drugi człon (ET40, ET41, ET42, ukrotnienia)
TMoverParameters *mvThird; // trzeci człon (SN61) TMoverParameters *mvThird { nullptr }; // trzeci człon (SN61)
// helper variable, to prevent immediate switch between closing and opening line breaker circuit // helper variable, to prevent immediate switch between closing and opening line breaker circuit
int m_linebreakerstate { 0 }; // 0: open, 1: closed, 2: freshly closed (and yes this is awful way to go about it) int m_linebreakerstate { 0 }; // 0: open, 1: closed, 2: freshly closed (and yes this is awful way to go about it)
static const commandhandler_map m_commandhandlers; static const commandhandler_map m_commandhandlers;

View File

@@ -115,6 +115,11 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
erase_extension( filename ); erase_extension( filename );
if( filename[ 0 ] == '/' ) {
// filename can potentially begin with a slash, and we don't need it
filename.erase( 0, 1 );
}
filename += ".mat"; filename += ".mat";
// try to locate requested material in the databank // try to locate requested material in the databank
@@ -124,7 +129,6 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
} }
// if this fails, try to look for it on disk // if this fails, try to look for it on disk
opengl_material material; opengl_material material;
material.name = filename;
auto const disklookup = find_on_disk( filename ); auto const disklookup = find_on_disk( filename );
if( disklookup != "" ) { if( disklookup != "" ) {
cParser materialparser( disklookup, cParser::buffer_FILE ); cParser materialparser( disklookup, cParser::buffer_FILE );
@@ -132,6 +136,7 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
// deserialization failed but the .mat file does exist, so we give up at this point // deserialization failed but the .mat file does exist, so we give up at this point
return null_handle; return null_handle;
} }
material.name = disklookup;
} }
else { else {
// if there's no .mat file, this could be legacy method of referring just to diffuse texture directly, make a material out of it in such case // if there's no .mat file, this could be legacy method of referring just to diffuse texture directly, make a material out of it in such case
@@ -140,6 +145,10 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
// if there's also no texture, give up // if there's also no texture, give up
return null_handle; return null_handle;
} }
// use texture path and name to tell the newly created materials apart
filename = GfxRenderer.Texture( material.texture1 ).name;
erase_extension( filename );
material.name = filename + ".mat";
material.has_alpha = GfxRenderer.Texture( material.texture1 ).has_alpha; material.has_alpha = GfxRenderer.Texture( material.texture1 ).has_alpha;
} }
@@ -149,21 +158,23 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
return handle; return handle;
}; };
// checks whether specified texture is in the texture bank. returns texture id, or npos. // checks whether specified material is in the material bank. returns handle to the material, or a null handle
material_handle material_handle
material_manager::find_in_databank( std::string const &Materialname ) const { material_manager::find_in_databank( std::string const &Materialname ) const {
auto lookup = m_materialmappings.find( Materialname ); std::vector<std::string> filenames {
if( lookup != m_materialmappings.end() ) { Global.asCurrentTexturePath + Materialname,
return lookup->second; Materialname,
} szTexturePath + Materialname };
// jeszcze próba z dodatkową ścieżką
lookup = m_materialmappings.find( szTexturePath + Materialname );
return ( for( auto const &filename : filenames ) {
lookup != m_materialmappings.end() ? auto const lookup { m_materialmappings.find( filename ) };
lookup->second : if( lookup != m_materialmappings.end() ) {
null_handle ); return lookup->second;
}
}
return null_handle;
} }
// checks whether specified file exists. // checks whether specified file exists.
@@ -172,6 +183,7 @@ std::string
material_manager::find_on_disk( std::string const &Materialname ) const { material_manager::find_on_disk( std::string const &Materialname ) const {
return( return(
FileExists( Global.asCurrentTexturePath + Materialname ) ? Global.asCurrentTexturePath + Materialname :
FileExists( Materialname ) ? Materialname : FileExists( Materialname ) ? Materialname :
FileExists( szTexturePath + Materialname ) ? szTexturePath + Materialname : FileExists( szTexturePath + Materialname ) ? szTexturePath + Materialname :
"" ); "" );

View File

@@ -747,7 +747,8 @@ ui_layer::update() {
+ " dist: " + to_string( vehicle->MoverParameters->DistCounter, 2 ) + " km" + " dist: " + to_string( vehicle->MoverParameters->DistCounter, 2 ) + " km"
+ "; pos: [" + to_string( vehicle->GetPosition().x, 2 ) + ", " + to_string( vehicle->GetPosition().y, 2 ) + ", " + to_string( vehicle->GetPosition().z, 2 ) + "]" + "; pos: [" + to_string( vehicle->GetPosition().x, 2 ) + ", " + to_string( vehicle->GetPosition().y, 2 ) + ", " + to_string( vehicle->GetPosition().z, 2 ) + "]"
+ ", PM=" + to_string( vehicle->MoverParameters->WheelFlat, 1 ) + ", PM=" + to_string( vehicle->MoverParameters->WheelFlat, 1 )
+ " mm; enrot=" + to_string( vehicle->MoverParameters->enrot * 60, 0 ) + " mm; enpwr=" + to_string( vehicle->MoverParameters->EnginePower, 1 )
+ "; enrot=" + to_string( vehicle->MoverParameters->enrot * 60, 0 )
+ " tmrot=" + to_string( std::abs( vehicle->MoverParameters->nrot ) * vehicle->MoverParameters->Transmision.Ratio * 60, 0 ) + " tmrot=" + to_string( std::abs( vehicle->MoverParameters->nrot ) * vehicle->MoverParameters->Transmision.Ratio * 60, 0 )
+ "; ventrot=" + to_string( vehicle->MoverParameters->RventRot * 60, 1 ) + "; ventrot=" + to_string( vehicle->MoverParameters->RventRot * 60, 1 )
+ "; fanrot=" + to_string( vehicle->MoverParameters->dizel_heat.rpmw, 1 ) + ", " + to_string( vehicle->MoverParameters->dizel_heat.rpmw2, 1 ); + "; fanrot=" + to_string( vehicle->MoverParameters->dizel_heat.rpmw, 1 ) + ", " + to_string( vehicle->MoverParameters->dizel_heat.rpmw2, 1 );
@@ -756,7 +757,7 @@ ui_layer::update() {
"HamZ=" + to_string( vehicle->MoverParameters->fBrakeCtrlPos, 2 ) "HamZ=" + to_string( vehicle->MoverParameters->fBrakeCtrlPos, 2 )
+ "; HamP=" + std::to_string( vehicle->MoverParameters->LocalBrakePos ) + "/" + to_string( vehicle->MoverParameters->LocalBrakePosA, 2 ) + "; HamP=" + std::to_string( vehicle->MoverParameters->LocalBrakePos ) + "/" + to_string( vehicle->MoverParameters->LocalBrakePosA, 2 )
+ "; NasJ=" + std::to_string( vehicle->MoverParameters->MainCtrlPos ) + "(" + std::to_string( vehicle->MoverParameters->MainCtrlActualPos ) + ")" + "; NasJ=" + std::to_string( vehicle->MoverParameters->MainCtrlPos ) + "(" + std::to_string( vehicle->MoverParameters->MainCtrlActualPos ) + ")"
+ ( vehicle->MoverParameters->ShuntMode ? + ( ( vehicle->MoverParameters->ShuntMode && vehicle->MoverParameters->EngineType == DieselElectric ) ?
"; NasB=" + to_string( vehicle->MoverParameters->AnPos, 2 ) : "; NasB=" + to_string( vehicle->MoverParameters->AnPos, 2 ) :
"; NasB=" + std::to_string( vehicle->MoverParameters->ScndCtrlPos ) + "(" + std::to_string( vehicle->MoverParameters->ScndCtrlActualPos ) + ")" ) "; NasB=" + std::to_string( vehicle->MoverParameters->ScndCtrlPos ) + "(" + std::to_string( vehicle->MoverParameters->ScndCtrlActualPos ) + ")" )
+ "; I=" + + "; I=" +
@@ -965,7 +966,7 @@ ui_layer::render() {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT ); glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT ); // blendfunc included since 3rd party gui doesn't play nice
glDisable( GL_LIGHTING ); glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST ); glDisable( GL_DEPTH_TEST );
glDisable( GL_ALPHA_TEST ); glDisable( GL_ALPHA_TEST );
@@ -988,7 +989,7 @@ ui_layer::render() {
render_panels(); render_panels();
render_tooltip(); render_tooltip();
glPopAttrib(); glPopAttrib();
} }
void void

View File

@@ -1 +1 @@
#define VERSION_INFO "M7 19.05.2018, based on tmj 45e7513" #define VERSION_INFO "M7 12.06.2018, based on tmj aa520aa3"