mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 12:49:18 +02:00
build 180308. location definition for bogies, serial port output fixes
This commit is contained in:
79
DynObj.cpp
79
DynObj.cpp
@@ -3940,7 +3940,7 @@ void TDynamicObject::RenderSounds() {
|
|||||||
}
|
}
|
||||||
// szum w czasie jazdy
|
// szum w czasie jazdy
|
||||||
if( ( GetVelocity() > 0.5 )
|
if( ( GetVelocity() > 0.5 )
|
||||||
&& ( false == rsOuterNoise.empty() )
|
&& ( false == m_bogiesounds.empty() )
|
||||||
&& ( // compound test whether the vehicle belongs to user-driven consist (as these don't emit outer noise in cab view)
|
&& ( // compound test whether the vehicle belongs to user-driven consist (as these don't emit outer noise in cab view)
|
||||||
FreeFlyModeFlag ? true : // in external view all vehicles emit outer noise
|
FreeFlyModeFlag ? true : // in external view all vehicles emit outer noise
|
||||||
// Global.pWorld->train() == nullptr ? true : // (can skip this check, with no player train the external view is a given)
|
// Global.pWorld->train() == nullptr ? true : // (can skip this check, with no player train the external view is a given)
|
||||||
@@ -3949,19 +3949,20 @@ void TDynamicObject::RenderSounds() {
|
|||||||
Global.CabWindowOpen ? true : // sticking head out we get to hear outer noise
|
Global.CabWindowOpen ? true : // sticking head out we get to hear outer noise
|
||||||
false ) ) {
|
false ) ) {
|
||||||
|
|
||||||
// frequency calculation
|
auto const &bogiesound { m_bogiesounds.front() };
|
||||||
auto const normalizer{ (
|
// frequency calculation
|
||||||
true == rsOuterNoise.is_combined() ?
|
auto const normalizer { (
|
||||||
|
true == bogiesound.is_combined() ?
|
||||||
MoverParameters->Vmax * 0.01f :
|
MoverParameters->Vmax * 0.01f :
|
||||||
1.f ) };
|
1.f ) };
|
||||||
frequency =
|
frequency =
|
||||||
rsOuterNoise.m_frequencyoffset
|
bogiesound.m_frequencyoffset
|
||||||
+ rsOuterNoise.m_frequencyfactor * MoverParameters->Vel * normalizer;
|
+ bogiesound.m_frequencyfactor * MoverParameters->Vel * normalizer;
|
||||||
|
|
||||||
// volume calculation
|
// volume calculation
|
||||||
volume =
|
volume =
|
||||||
rsOuterNoise.m_amplitudeoffset +
|
bogiesound.m_amplitudeoffset +
|
||||||
rsOuterNoise.m_amplitudefactor * MoverParameters->Vel;
|
bogiesound.m_amplitudefactor * MoverParameters->Vel;
|
||||||
if( brakeforceratio > 0.0 ) {
|
if( brakeforceratio > 0.0 ) {
|
||||||
// hamulce wzmagaja halas
|
// hamulce wzmagaja halas
|
||||||
volume *= 1 + 0.125 * brakeforceratio;
|
volume *= 1 + 0.125 * brakeforceratio;
|
||||||
@@ -3978,18 +3979,26 @@ void TDynamicObject::RenderSounds() {
|
|||||||
0.0, 1.0 ) );
|
0.0, 1.0 ) );
|
||||||
|
|
||||||
if( volume > 0.05 ) {
|
if( volume > 0.05 ) {
|
||||||
rsOuterNoise
|
// apply calculated parameters to all motor instances
|
||||||
.pitch( frequency ) // arbitrary limits to prevent the pitch going out of whack
|
for( auto &bogiesound : m_bogiesounds ) {
|
||||||
.gain( volume )
|
bogiesound
|
||||||
.play( sound_flags::exclusive | sound_flags::looping );
|
.pitch( frequency ) // arbitrary limits to prevent the pitch going out of whack
|
||||||
|
.gain( volume )
|
||||||
|
.play( sound_flags::exclusive | sound_flags::looping );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rsOuterNoise.stop();
|
// stop all noise instances
|
||||||
|
for( auto &bogiesound : m_bogiesounds ) {
|
||||||
|
bogiesound.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// don't play the optional ending sound if the listener switches views
|
// don't play the optional ending sound if the listener switches views
|
||||||
rsOuterNoise.stop( false == FreeFlyModeFlag );
|
for( auto &bogiesound : m_bogiesounds ) {
|
||||||
|
bogiesound.stop( false == FreeFlyModeFlag );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// flat spot sound
|
// flat spot sound
|
||||||
if( MoverParameters->CategoryFlag == 1 ) {
|
if( MoverParameters->CategoryFlag == 1 ) {
|
||||||
@@ -4844,9 +4853,8 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
m_powertrainsounds.motors.emplace_back( motortemplate );
|
m_powertrainsounds.motors.emplace_back( motortemplate );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//
|
// apply configuration to all defined motors
|
||||||
for( auto &motor : m_powertrainsounds.motors ) {
|
for( auto &motor : m_powertrainsounds.motors ) {
|
||||||
// apply configuration to all defined motors
|
|
||||||
// combine potential x- and y-axis offsets of the sound template with z-axis offsets of individual motors
|
// combine potential x- and y-axis offsets of the sound template with z-axis offsets of individual motors
|
||||||
auto motoroffset { motortemplate.offset() };
|
auto motoroffset { motortemplate.offset() };
|
||||||
motoroffset.z = motor.offset().z;
|
motoroffset.z = motor.offset().z;
|
||||||
@@ -5034,11 +5042,27 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
|
|
||||||
else if( token == "outernoise:" ) {
|
else if( token == "outernoise:" ) {
|
||||||
// szum podczas jazdy:
|
// szum podczas jazdy:
|
||||||
rsOuterNoise.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, MoverParameters->Vmax );
|
sound_source noisetemplate { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||||
rsOuterNoise.owner( this );
|
noisetemplate.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, MoverParameters->Vmax );
|
||||||
|
noisetemplate.owner( this );
|
||||||
|
|
||||||
rsOuterNoise.m_amplitudefactor /= ( 1 + MoverParameters->Vmax );
|
noisetemplate.m_amplitudefactor /= ( 1 + MoverParameters->Vmax );
|
||||||
rsOuterNoise.m_frequencyfactor /= ( 1 + MoverParameters->Vmax );
|
noisetemplate.m_frequencyfactor /= ( 1 + MoverParameters->Vmax );
|
||||||
|
|
||||||
|
if( true == m_bogiesounds.empty() ) {
|
||||||
|
// fallback for cases without specified noise locations, convert sound template to a single sound source
|
||||||
|
m_bogiesounds.emplace_back( noisetemplate );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// apply configuration to all defined bogies
|
||||||
|
for( auto &bogie : m_bogiesounds ) {
|
||||||
|
// combine potential x- and y-axis offsets of the sound template with z-axis offsets of individual motors
|
||||||
|
auto bogieoffset { noisetemplate.offset() };
|
||||||
|
bogieoffset.z = bogie.offset().z;
|
||||||
|
bogie = noisetemplate;
|
||||||
|
bogie.offset( bogieoffset );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( token == "wheelflat:" ) {
|
else if( token == "wheelflat:" ) {
|
||||||
@@ -5102,6 +5126,21 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if( token == "bogies:" ) {
|
||||||
|
// a list of offsets along vehicle's z-axis; followed with "end"
|
||||||
|
while( ( ( token = parser.getToken<std::string>() ) != "" )
|
||||||
|
&& ( token != "end" ) ) {
|
||||||
|
// vehicle faces +Z in 'its' space, for bogie locations negative value means ahead of centre
|
||||||
|
auto const offset { std::atof( token.c_str() ) * -1.f };
|
||||||
|
// NOTE: we skip setting owner of the sounds, it'll be done during individual sound deserialization
|
||||||
|
sound_source bogienoise { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||||
|
// add entry to the list
|
||||||
|
auto const location { glm::vec3 { 0.f, 0.f, offset } };
|
||||||
|
bogienoise.offset( location );
|
||||||
|
m_bogiesounds.emplace_back( bogienoise );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} while( ( token != "" )
|
} while( ( token != "" )
|
||||||
&& ( token != "endlocations" ) );
|
&& ( token != "endlocations" ) );
|
||||||
|
|
||||||
|
|||||||
2
DynObj.h
2
DynObj.h
@@ -394,7 +394,7 @@ private:
|
|||||||
sound_source sDepartureSignal { sound_placement::general };
|
sound_source sDepartureSignal { sound_placement::general };
|
||||||
sound_source sHorn1 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
sound_source sHorn1 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||||
sound_source sHorn2 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
sound_source sHorn2 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||||
sound_source rsOuterNoise { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
std::vector<sound_source> m_bogiesounds; // TBD, TODO: wrapper for all bogie-related sounds (noise, brakes, squeal etc)
|
||||||
sound_source m_wheelflat { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
sound_source m_wheelflat { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE };
|
||||||
sound_source rscurve { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; // youBy
|
sound_source rscurve { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; // youBy
|
||||||
sound_source rsDerailment { sound_placement::external, 250.f }; // McZapkie-051202
|
sound_source rsDerailment { sound_placement::external, 250.f }; // McZapkie-051202
|
||||||
|
|||||||
@@ -5755,8 +5755,8 @@ void TTrain::clear_cab_controls()
|
|||||||
btLampkaOgrzewanieSkladu.Clear(11);
|
btLampkaOgrzewanieSkladu.Clear(11);
|
||||||
btHaslerBrakes.Clear(12); // ciśnienie w cylindrach do odbijania na haslerze
|
btHaslerBrakes.Clear(12); // ciśnienie w cylindrach do odbijania na haslerze
|
||||||
btHaslerCurrent.Clear(13); // prąd na silnikach do odbijania na haslerze
|
btHaslerCurrent.Clear(13); // prąd na silnikach do odbijania na haslerze
|
||||||
// Jeśli ustawiamy nową wartość dla PoKeys wolna jest 15
|
|
||||||
// Numer 14 jest używany dla buczka SHP w update_sounds()
|
// Numer 14 jest używany dla buczka SHP w update_sounds()
|
||||||
|
// Jeśli ustawiamy nową wartość dla PoKeys wolna jest 15
|
||||||
|
|
||||||
// other cab controls
|
// other cab controls
|
||||||
// TODO: arrange in more readable manner, and eventually refactor
|
// TODO: arrange in more readable manner, and eventually refactor
|
||||||
|
|||||||
35
uart.cpp
35
uart.cpp
@@ -239,9 +239,9 @@ void uart_input::poll()
|
|||||||
uint16_t pipe_press = (uint16_t)std::min(conf.pipeuart, trainstate.pipe_pressure * 0.1f / conf.pipemax * conf.pipeuart);
|
uint16_t pipe_press = (uint16_t)std::min(conf.pipeuart, trainstate.pipe_pressure * 0.1f / conf.pipemax * conf.pipeuart);
|
||||||
uint16_t brake_press = (uint16_t)std::min(conf.brakeuart, trainstate.brake_pressure * 0.1f / conf.brakemax * conf.brakeuart);
|
uint16_t brake_press = (uint16_t)std::min(conf.brakeuart, trainstate.brake_pressure * 0.1f / conf.brakemax * conf.brakeuart);
|
||||||
uint16_t hv_voltage = (uint16_t)std::min(conf.hvuart, trainstate.hv_voltage / conf.hvmax * conf.hvuart);
|
uint16_t hv_voltage = (uint16_t)std::min(conf.hvuart, trainstate.hv_voltage / conf.hvmax * conf.hvuart);
|
||||||
uint16_t current1 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[0]) / conf.currentmax * conf.currentuart;
|
uint16_t current1 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[0] / conf.currentmax * conf.currentuart);
|
||||||
uint16_t current2 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[1]) / conf.currentmax * conf.currentuart;
|
uint16_t current2 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[1] / conf.currentmax * conf.currentuart);
|
||||||
uint16_t current3 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[2]) / conf.currentmax * conf.currentuart;
|
uint16_t current3 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[2] / conf.currentmax * conf.currentuart);
|
||||||
|
|
||||||
std::array<uint8_t, 31> buffer {
|
std::array<uint8_t, 31> buffer {
|
||||||
//byte 0
|
//byte 0
|
||||||
@@ -269,15 +269,26 @@ void uart_input::poll()
|
|||||||
| trainstate.line_breaker << 5
|
| trainstate.line_breaker << 5
|
||||||
| trainstate.compressor_overload << 6),
|
| trainstate.compressor_overload << 6),
|
||||||
//byte 6
|
//byte 6
|
||||||
(uint8_t)( trainstate.alerter_sound << 7),
|
(uint8_t)(
|
||||||
SPLIT_INT16(brake_press), //byte 7-8
|
trainstate.recorder_braking << 3
|
||||||
SPLIT_INT16(pipe_press), //byte 9-10
|
| trainstate.recorder_power << 4
|
||||||
SPLIT_INT16(tank_press), //byte 11-12
|
| trainstate.alerter_sound << 7),
|
||||||
SPLIT_INT16(hv_voltage), //byte 13-14
|
//byte 7-8
|
||||||
SPLIT_INT16(current1), //byte 15-16
|
SPLIT_INT16(brake_press),
|
||||||
SPLIT_INT16(current2), //byte 17-18
|
//byte 9-10
|
||||||
SPLIT_INT16(current3), //byte 19-20
|
SPLIT_INT16(pipe_press),
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 //byte 21-30
|
//byte 11-12
|
||||||
|
SPLIT_INT16(tank_press),
|
||||||
|
//byte 13-14
|
||||||
|
SPLIT_INT16(hv_voltage),
|
||||||
|
//byte 15-16
|
||||||
|
SPLIT_INT16(current1),
|
||||||
|
//byte 17-18
|
||||||
|
SPLIT_INT16(current2),
|
||||||
|
//byte 19-20
|
||||||
|
SPLIT_INT16(current3),
|
||||||
|
//byte 21-30
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (conf.debug)
|
if (conf.debug)
|
||||||
|
|||||||
Reference in New Issue
Block a user