mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 07:39:19 +02:00
tmj merge
This commit is contained in:
155
DynObj.cpp
155
DynObj.cpp
@@ -1751,10 +1751,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
// McZapkie: TypeName musi byc nazwą CHK/MMD pojazdu
|
||||
if (!MoverParameters->LoadFIZ(asBaseDir))
|
||||
{ // jak wczytanie CHK się nie uda, to błąd
|
||||
if (ConversionError == -8)
|
||||
ErrorLog("Missed file: " + BaseDir + "\\" + Type_Name + ".fiz");
|
||||
Error("Cannot load dynamic object " + asName + " from:\r\n" + BaseDir + "\\" + Type_Name +
|
||||
".fiz\r\nError " + to_string(ConversionError));
|
||||
if (ConversionError == 666)
|
||||
ErrorLog( "Bad vehicle: failed do locate definition file \"" + BaseDir + "\\" + Type_Name + ".fiz" + "\"" );
|
||||
else {
|
||||
ErrorLog( "Bad vehicle: failed to load definition from file \"" + BaseDir + "\\" + Type_Name + ".fiz\" (error " + to_string( ConversionError ) + ")" );
|
||||
}
|
||||
return 0.0; // zerowa długość to brak pojazdu
|
||||
}
|
||||
bool driveractive = (fVel != 0.0); // jeśli prędkość niezerowa, to aktywujemy ruch
|
||||
@@ -2966,27 +2967,26 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
}
|
||||
}
|
||||
|
||||
auto axleindex { 0 };
|
||||
for( auto &axle : m_axlesounds ) {
|
||||
axle.distance -= dDOMoveLen * Sign( dDOMoveLen );
|
||||
if( axle.distance < 0 ) {
|
||||
axle.distance += dRailLength;
|
||||
/*
|
||||
// McZapkie-040302
|
||||
if( i == iAxles - 1 ) {
|
||||
rsStukot[ 0 ].stop();
|
||||
MoverParameters->AccV += 0.5 * GetVelocity() / ( 1 + MoverParameters->Vmax );
|
||||
}
|
||||
else {
|
||||
rsStukot[ i + 1 ].stop();
|
||||
}
|
||||
if( i == 1 ) {
|
||||
MoverParameters->AccV -= 0.5 * GetVelocity() / ( 1 + MoverParameters->Vmax );
|
||||
}
|
||||
*/
|
||||
if( MoverParameters->Vel > 2.5 ) {
|
||||
axle.clatter.gain( volume ).play();
|
||||
// crude bump simulation, drop down on even axles, move back up on the odd ones
|
||||
MoverParameters->AccVert +=
|
||||
interpolate(
|
||||
0.25, 0.50,
|
||||
clamp(
|
||||
GetVelocity() / ( 1 + MoverParameters->Vmax ),
|
||||
0.0, 1.0 ) )
|
||||
* ( ( axleindex % 2 ) != 0 ?
|
||||
1 :
|
||||
-1 );
|
||||
}
|
||||
}
|
||||
++axleindex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3495,7 +3495,7 @@ void TDynamicObject::RenderSounds() {
|
||||
if( MoverParameters->ConverterFlag ) {
|
||||
frequency = (
|
||||
MoverParameters->EngineType == ElectricSeriesMotor ?
|
||||
MoverParameters->Voltage / ( MoverParameters->NominalVoltage * MoverParameters->RList[ MoverParameters->RlistSize ].Mn ) :
|
||||
( MoverParameters->RunningTraction.TractionVoltage / MoverParameters->NominalVoltage ) * MoverParameters->RList[ MoverParameters->RlistSize ].Mn :
|
||||
1.0 );
|
||||
frequency = sConverter.m_frequencyoffset + sConverter.m_frequencyfactor * frequency;
|
||||
sConverter
|
||||
@@ -3610,21 +3610,22 @@ void TDynamicObject::RenderSounds() {
|
||||
}
|
||||
|
||||
// McZapkie-280302 - pisk mocno zacisnietych hamulcow
|
||||
if( //( false == MoverParameters->SlippingWheels ) &&
|
||||
( MoverParameters->UnitBrakeForce > rsPisk.m_amplitudefactor )
|
||||
&& ( MoverParameters->Vel > 2.5 ) ) {
|
||||
if( MoverParameters->Vel > 2.5 ) {
|
||||
|
||||
rsPisk
|
||||
.gain( MoverParameters->UnitBrakeForce / ( rsPisk.m_amplitudefactor + 1 ) + rsPisk.m_amplitudeoffset )
|
||||
.play( sound_flags::exclusive | sound_flags::looping );
|
||||
volume = rsPisk.m_amplitudeoffset + interpolate( -1.0, 1.0, brakeforceratio ) * rsPisk.m_amplitudefactor;
|
||||
if( volume > 0.075 ) {
|
||||
rsPisk
|
||||
.gain( volume )
|
||||
.play( sound_flags::exclusive | sound_flags::looping );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// don't stop the sound too abruptly
|
||||
volume = std::max( 0.0, rsPisk.gain() - ( rsPisk.gain() * 2.5 * dt ) );
|
||||
rsPisk.gain( volume );
|
||||
if( volume < 0.05 ) {
|
||||
rsPisk.stop();
|
||||
}
|
||||
}
|
||||
if( volume < 0.05 ) {
|
||||
rsPisk.stop();
|
||||
}
|
||||
|
||||
// other sounds
|
||||
@@ -3771,24 +3772,6 @@ void TDynamicObject::RenderSounds() {
|
||||
|
||||
// McZapkie! - to wazne - SoundFlag wystawiane jest przez moje moduly
|
||||
// gdy zachodza pewne wydarzenia komentowane dzwiekiem.
|
||||
if( TestFlag( MoverParameters->SoundFlag, sound::relay ) ) {
|
||||
// przekaznik - gdy bezpiecznik, automatyczny rozruch itp
|
||||
if( true == TestFlag( MoverParameters->SoundFlag, sound::parallel ) ) {
|
||||
if( TestFlag( MoverParameters->SoundFlag, sound::loud ) )
|
||||
m_powertrainsounds.dsbWejscie_na_bezoporow.play();
|
||||
else
|
||||
m_powertrainsounds.motor_parallel.play();
|
||||
}
|
||||
else {
|
||||
m_powertrainsounds.motor_relay
|
||||
.gain(
|
||||
true == TestFlag( MoverParameters->SoundFlag, sound::loud ) ?
|
||||
1.0f :
|
||||
0.8f )
|
||||
.play();
|
||||
}
|
||||
}
|
||||
|
||||
if( TestFlag( MoverParameters->SoundFlag, sound::pneumatic ) ) {
|
||||
// pneumatic relay
|
||||
dsbPneumaticRelay
|
||||
@@ -3798,7 +3781,6 @@ void TDynamicObject::RenderSounds() {
|
||||
0.8f )
|
||||
.play();
|
||||
}
|
||||
|
||||
// couplers
|
||||
int couplerindex { 0 };
|
||||
for( auto &couplersounds : m_couplersounds ) {
|
||||
@@ -4581,6 +4563,12 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
m_powertrainsounds.engine.m_amplitudefactor /= amplitudedivisor;
|
||||
}
|
||||
|
||||
else if( token == "dieselinc:" ) {
|
||||
// dzwiek przy wlazeniu na obroty woodwarda
|
||||
m_powertrainsounds.engine_revving.deserialize( parser, sound_type::single, sound_parameters::range );
|
||||
m_powertrainsounds.engine_revving.owner( this );
|
||||
}
|
||||
|
||||
else if( ( token == "tractionmotor:" )
|
||||
&& ( MoverParameters->Power > 0 ) ) {
|
||||
// plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest.
|
||||
@@ -4620,6 +4608,11 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
rsPisk.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude );
|
||||
rsPisk.owner( this );
|
||||
|
||||
if( rsPisk.m_amplitudefactor > 10.f ) {
|
||||
// HACK: convert old style activation point threshold to the new, regular amplitude adjustment system
|
||||
rsPisk.m_amplitudefactor = 1.f;
|
||||
rsPisk.m_amplitudeoffset = 0.f;
|
||||
}
|
||||
rsPisk.m_amplitudeoffset *= ( 105.f - Random( 10.f ) ) / 100.f;
|
||||
}
|
||||
|
||||
@@ -4643,12 +4636,6 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
rsDerailment.owner( this );
|
||||
}
|
||||
|
||||
else if( token == "dieselinc:" ) {
|
||||
// dzwiek przy wlazeniu na obroty woodwarda
|
||||
m_powertrainsounds.engine_revving.deserialize( parser, sound_type::single, sound_parameters::range );
|
||||
m_powertrainsounds.engine_revving.owner( this );
|
||||
}
|
||||
|
||||
else if( token == "curve:" ) {
|
||||
rscurve.deserialize( parser, sound_type::single, sound_parameters::range );
|
||||
rscurve.owner( this );
|
||||
@@ -4805,10 +4792,10 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
m_powertrainsounds.motor_relay.deserialize( parser, sound_type::single );
|
||||
m_powertrainsounds.motor_relay.owner( this );
|
||||
}
|
||||
else if( token == "pneumaticrelay:" ) {
|
||||
// wylaczniki pneumatyczne:
|
||||
dsbPneumaticRelay.deserialize( parser, sound_type::single );
|
||||
dsbPneumaticRelay.owner( this );
|
||||
else if( token == "shuntfield:" ) {
|
||||
// styczniki itp:
|
||||
m_powertrainsounds.motor_shuntfield.deserialize( parser, sound_type::single );
|
||||
m_powertrainsounds.motor_shuntfield.owner( this );
|
||||
}
|
||||
else if( token == "wejscie_na_bezoporow:" ) {
|
||||
// hunter-111211: wydzielenie wejscia na bezoporowa i na drugi uklad do pliku
|
||||
@@ -4819,6 +4806,11 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
m_powertrainsounds.motor_parallel.deserialize( parser, sound_type::single );
|
||||
m_powertrainsounds.motor_parallel.owner( this );
|
||||
}
|
||||
else if( token == "pneumaticrelay:" ) {
|
||||
// wylaczniki pneumatyczne:
|
||||
dsbPneumaticRelay.deserialize( parser, sound_type::single );
|
||||
dsbPneumaticRelay.owner( this );
|
||||
}
|
||||
// braking sounds
|
||||
else if( token == "brakesound:" ) {
|
||||
// hamowanie zwykle:
|
||||
@@ -5580,8 +5572,14 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
|
||||
}
|
||||
engine_revs_last = Vehicle.enrot * 60;
|
||||
|
||||
if( false == engine_revving.is_combined() ) {
|
||||
// if the sound comes with multiple samples we reuse rpm-based calculation from the engine
|
||||
frequency = engine_revving.m_frequencyoffset + engine_revving.m_frequencyfactor * 1.0;
|
||||
}
|
||||
|
||||
if( enginerevvolume > 0.02 ) {
|
||||
engine_revving
|
||||
.pitch( frequency )
|
||||
.gain( enginerevvolume )
|
||||
.play( sound_flags::exclusive | sound_flags::looping );
|
||||
}
|
||||
@@ -5757,6 +5755,50 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
|
||||
motor.stop();
|
||||
}
|
||||
|
||||
auto const soundflags { Vehicle.SoundFlag };
|
||||
if( TestFlag( soundflags, sound::relay ) ) {
|
||||
// przekaznik - gdy bezpiecznik, automatyczny rozruch itp
|
||||
if( true == TestFlag( soundflags, sound::shuntfield ) ) {
|
||||
// shunt field
|
||||
motor_shuntfield
|
||||
.pitch(
|
||||
true == motor_shuntfield.is_combined() ?
|
||||
Vehicle.ScndCtrlActualPos * 0.01f :
|
||||
motor_shuntfield.m_frequencyoffset + 1.f * motor_shuntfield.m_frequencyfactor )
|
||||
.gain(
|
||||
motor_shuntfield.m_amplitudeoffset + (
|
||||
true == TestFlag( soundflags, sound::loud ) ?
|
||||
1.0f :
|
||||
0.8f )
|
||||
* motor_shuntfield.m_amplitudefactor )
|
||||
.play();
|
||||
}
|
||||
else if( true == TestFlag( soundflags, sound::parallel ) ) {
|
||||
// parallel mode
|
||||
if( TestFlag( soundflags, sound::loud ) ) {
|
||||
dsbWejscie_na_bezoporow.play();
|
||||
}
|
||||
else {
|
||||
motor_parallel.play();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// series mode
|
||||
motor_relay
|
||||
.pitch(
|
||||
true == motor_relay.is_combined() ?
|
||||
Vehicle.MainCtrlActualPos * 0.01f :
|
||||
motor_relay.m_frequencyoffset + 1.f * motor_relay.m_frequencyfactor )
|
||||
.gain(
|
||||
motor_relay.m_amplitudeoffset + (
|
||||
true == TestFlag( soundflags, sound::loud ) ?
|
||||
1.0f :
|
||||
0.8f )
|
||||
* motor_relay.m_amplitudefactor )
|
||||
.play();
|
||||
}
|
||||
}
|
||||
|
||||
if( ( Vehicle.EngineType == ElectricSeriesMotor )
|
||||
|| ( Vehicle.EngineType == ElectricInductionMotor ) ) {
|
||||
|
||||
@@ -5778,7 +5820,6 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( Vehicle.TrainType == dt_ET40 ) {
|
||||
if( Vehicle.Vel > 0.1 ) {
|
||||
transmission
|
||||
|
||||
Reference in New Issue
Block a user