mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 22:09:19 +02:00
build 180122. radio channel cab controls, sky brightness calculation fix, motor ventilator spin rate tweaks
This commit is contained in:
@@ -105,7 +105,7 @@ TButton::model_offset() const {
|
||||
|
||||
return (
|
||||
submodel != nullptr ?
|
||||
submodel->offset( 1.f ) :
|
||||
submodel->offset( 2.5f ) :
|
||||
glm::vec3() );
|
||||
}
|
||||
|
||||
|
||||
@@ -2975,7 +2975,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
// crude bump simulation, drop down on even axles, move back up on the odd ones
|
||||
MoverParameters->AccVert +=
|
||||
interpolate(
|
||||
0.25, 0.50,
|
||||
0.01, 0.05,
|
||||
clamp(
|
||||
GetVelocity() / ( 1 + MoverParameters->Vmax ),
|
||||
0.0, 1.0 ) )
|
||||
|
||||
@@ -84,7 +84,7 @@ extern int ConversionError;
|
||||
const double Steel2Steel_friction = 0.15; //tarcie statyczne
|
||||
const double g = 9.81; //przyspieszenie ziemskie
|
||||
const double SandSpeed = 0.1; //ile kg/s}
|
||||
const double RVentSpeed = 0.4; //rozpedzanie sie wentylatora obr/s^2}
|
||||
const double RVentSpeed = 3.5; //rozpedzanie sie wentylatora obr/s^2}
|
||||
const double RVentMinI = 50.0; //przy jakim pradzie sie wylaczaja}
|
||||
const double Pirazy2 = 6.2831853071794f;
|
||||
#define PI 3.1415926535897f
|
||||
@@ -945,17 +945,21 @@ public:
|
||||
bool InsideConsist = false;
|
||||
/*-zmienne dla lokomotywy elektrycznej*/
|
||||
TTractionParam RunningTraction;/*parametry sieci trakcyjnej najblizej lokomotywy*/
|
||||
double enrot = 0.0;
|
||||
double Im = 0.0;
|
||||
double Itot = 0.0;
|
||||
double enrot = 0.0; // ilosc obrotow silnika
|
||||
double Im = 0.0; // prad silnika
|
||||
/*
|
||||
// currently not used
|
||||
double IHeating = 0.0;
|
||||
double ITraction = 0.0;
|
||||
*/
|
||||
double Itot = 0.0; // prad calkowity
|
||||
double TotalCurrent = 0.0;
|
||||
// momenty
|
||||
double Mm = 0.0;
|
||||
double Mw = 0.0;
|
||||
// sily napedne
|
||||
double Fw = 0.0;
|
||||
double Ft = 0.0;
|
||||
/*ilosc obrotow, prad silnika i calkowity, momenty, sily napedne*/
|
||||
//Ra: Im jest ujemny, jeśli lok jedzie w stronę sprzęgu 1
|
||||
//a ujemne powinien być przy odwróconej polaryzacji sieci...
|
||||
//w wielu miejscach jest używane abs(Im)
|
||||
|
||||
@@ -4252,7 +4252,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
RventRot += ( RVentnmax - RventRot ) * RVentSpeed * dt;
|
||||
}
|
||||
else {
|
||||
RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt );
|
||||
RventRot = std::max( 0.0, RventRot - RVentSpeed * dt );
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -4267,7 +4267,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
RventRot += ( RVentnmax * Im / ImaxLo - RventRot ) * RVentSpeed * dt;
|
||||
}
|
||||
else {
|
||||
RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt );
|
||||
RventRot = std::max( 0.0, RventRot - RVentSpeed * dt );
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -4278,7 +4278,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
} // rventtype
|
||||
} // mains
|
||||
else {
|
||||
RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt );
|
||||
RventRot = std::max( 0.0, RventRot - RVentSpeed * dt );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1166,7 +1166,7 @@ TSubModel::offset( float const Geometrytestoffsetthreshold ) const {
|
||||
|
||||
auto offset { glm::vec3 { glm::make_mat4( parentmatrix.readArray() ) * glm::vec4 { 0, 0, 0, 1 } } };
|
||||
|
||||
if( glm::length2( offset ) < Geometrytestoffsetthreshold ) {
|
||||
if( glm::length( offset ) < Geometrytestoffsetthreshold ) {
|
||||
// offset of zero generally means the submodel has optimized identity matrix
|
||||
// for such cases we resort to an estimate from submodel geometry
|
||||
// TODO: do proper bounding area calculation for submodel when loading mesh and grab the centre point from it here
|
||||
|
||||
37
Train.cpp
37
Train.cpp
@@ -464,6 +464,7 @@ PyObject *TTrain::GetTrainState() {
|
||||
PyDict_SetItemString( dict, "shp", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ) );
|
||||
PyDict_SetItemString( dict, "pantpress", PyGetFloat( mvControlled->PantPress ) );
|
||||
PyDict_SetItemString( dict, "universal3", PyGetBool( InstrumentLightActive ) );
|
||||
PyDict_SetItemString( dict, "radio_channel", PyGetInt( iRadioChannel ) );
|
||||
// movement data
|
||||
PyDict_SetItemString( dict, "velocity", PyGetFloat( mover->Vel ) );
|
||||
PyDict_SetItemString( dict, "tractionforce", PyGetFloat( mover->Ft ) );
|
||||
@@ -3079,6 +3080,13 @@ void TTrain::OnCommand_radiochannelincrease( TTrain *Train, command_data const &
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
Train->iRadioChannel = clamp( Train->iRadioChannel + 1, 1, 10 );
|
||||
// visual feedback
|
||||
Train->ggRadioChannelSelector.UpdateValue( Train->iRadioChannel - 1 );
|
||||
Train->ggRadioChannelNext.UpdateValue( 1.0 );
|
||||
}
|
||||
else if( Command.action == GLFW_RELEASE ) {
|
||||
// visual feedback
|
||||
Train->ggRadioChannelNext.UpdateValue( 0.0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3086,6 +3094,13 @@ void TTrain::OnCommand_radiochanneldecrease( TTrain *Train, command_data const &
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
Train->iRadioChannel = clamp( Train->iRadioChannel - 1, 1, 10 );
|
||||
// visual feedback
|
||||
Train->ggRadioChannelSelector.UpdateValue( Train->iRadioChannel - 1 );
|
||||
Train->ggRadioChannelPrevious.UpdateValue( 1.0 );
|
||||
}
|
||||
else if( Command.action == GLFW_RELEASE ) {
|
||||
// visual feedback
|
||||
Train->ggRadioChannelPrevious.UpdateValue( 0.0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3283,9 +3298,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
}
|
||||
|
||||
if (DynamicObject->mdKabina)
|
||||
{ // Ra: TODO: odczyty klawiatury/pulpitu nie
|
||||
// powinny być uzależnione od istnienia modelu
|
||||
// kabiny
|
||||
{ // Ra: TODO: odczyty klawiatury/pulpitu nie powinny być uzależnione od istnienia modelu kabiny
|
||||
tor = DynamicObject->GetTrack(); // McZapkie-180203
|
||||
// McZapkie: predkosc wyswietlana na tachometrze brana jest z obrotow kol
|
||||
float maxtacho = 3;
|
||||
@@ -3307,9 +3320,10 @@ bool TTrain::Update( double const Deltatime )
|
||||
if (fTachoCount < maxtacho)
|
||||
fTachoCount += Deltatime * 3; // szybciej zacznij stukac
|
||||
}
|
||||
else if (fTachoCount > 0)
|
||||
fTachoCount -= Deltatime * 0.66; // schodz powoli - niektore haslery to ze 4
|
||||
// sekundy potrafia stukac
|
||||
else if( fTachoCount > 0 ) {
|
||||
// schodz powoli - niektore haslery to ze 4 sekundy potrafia stukac
|
||||
fTachoCount -= Deltatime * 0.66;
|
||||
}
|
||||
|
||||
// Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są ewentualnie na PoKeys
|
||||
if ((mvControlled->EngineType != DieselElectric)
|
||||
@@ -4170,6 +4184,9 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggConverterFuseButton.Update();
|
||||
ggStLinOffButton.Update();
|
||||
ggRadioButton.Update();
|
||||
ggRadioChannelSelector.Update();
|
||||
ggRadioChannelPrevious.Update();
|
||||
ggRadioChannelNext.Update();
|
||||
ggDepartureSignalButton.Update();
|
||||
|
||||
ggPantFrontButton.Update();
|
||||
@@ -5162,6 +5179,10 @@ void TTrain::clear_cab_controls()
|
||||
ggFuseButton.Clear();
|
||||
ggConverterFuseButton.Clear();
|
||||
ggStLinOffButton.Clear();
|
||||
ggRadioButton.Clear();
|
||||
ggRadioChannelSelector.Clear();
|
||||
ggRadioChannelPrevious.Clear();
|
||||
ggRadioChannelNext.Clear();
|
||||
ggDoorLeftButton.Clear();
|
||||
ggDoorRightButton.Clear();
|
||||
ggDepartureSignalButton.Clear();
|
||||
@@ -5299,6 +5320,7 @@ void TTrain::set_cab_controls() {
|
||||
if( true == mvOccupied->Radio ) {
|
||||
ggRadioButton.PutValue( 1.0 );
|
||||
}
|
||||
ggRadioChannelSelector.PutValue( iRadioChannel - 1 );
|
||||
// pantographs
|
||||
if( mvOccupied->PantSwitchType != "impulse" ) {
|
||||
ggPantFrontButton.PutValue(
|
||||
@@ -5630,6 +5652,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "converteroff_sw:", ggConverterOffButton },
|
||||
{ "main_sw:", ggMainButton },
|
||||
{ "radio_sw:", ggRadioButton },
|
||||
{ "radiochannel_sw:", ggRadioChannelSelector },
|
||||
{ "radiochannelprev_sw:", ggRadioChannelPrevious },
|
||||
{ "radiochannelnext_sw:", ggRadioChannelNext },
|
||||
{ "pantfront_sw:", ggPantFrontButton },
|
||||
{ "pantrear_sw:", ggPantRearButton },
|
||||
{ "pantfrontoff_sw:", ggPantFrontButtonOff },
|
||||
|
||||
7
Train.h
7
Train.h
@@ -89,7 +89,6 @@ class TTrain
|
||||
void UpdateMechPosition(double dt);
|
||||
vector3 GetWorldMechPosition();
|
||||
bool Update( double const Deltatime );
|
||||
void update_sounds( double const Deltatime );
|
||||
void MechStop();
|
||||
void SetLights();
|
||||
// McZapkie-310302: ladowanie parametrow z pliku
|
||||
@@ -116,7 +115,8 @@ class TTrain
|
||||
TDynamicObject *find_nearest_consist_vehicle() const;
|
||||
// moves train brake lever to specified position, potentially emits switch sound if conditions are met
|
||||
void set_train_brake( double const Position );
|
||||
|
||||
// update function subroutines
|
||||
void update_sounds( double const Deltatime );
|
||||
|
||||
// command handlers
|
||||
// NOTE: we're currently using universal handlers and static handler map but it may be beneficial to have these implemented on individual class instance basis
|
||||
@@ -271,6 +271,9 @@ public: // reszta może by?publiczna
|
||||
TGauge ggConverterFuseButton; // hunter-261211: przycisk odblokowania nadmiarowego przetwornic i ogrzewania
|
||||
TGauge ggStLinOffButton;
|
||||
TGauge ggRadioButton;
|
||||
TGauge ggRadioChannelSelector;
|
||||
TGauge ggRadioChannelPrevious;
|
||||
TGauge ggRadioChannelNext;
|
||||
TGauge ggUpperLightButton;
|
||||
TGauge ggLeftLightButton;
|
||||
TGauge ggRightLightButton;
|
||||
|
||||
16
World.cpp
16
World.cpp
@@ -1558,13 +1558,11 @@ TWorld::Update_UI() {
|
||||
"vel: " + to_string( vehicle->GetVelocity(), 2 ) + "/" + to_string( vehicle->MoverParameters->nrot* M_PI * vehicle->MoverParameters->WheelDiameter * 3.6, 2 )
|
||||
+ " km/h;" + ( vehicle->MoverParameters->SlippingWheels ? " (!)" : " " )
|
||||
+ " 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 ) + "), PM="
|
||||
+ to_string( vehicle->MoverParameters->WheelFlat, 1 ) + " mm; enrot="
|
||||
+ to_string( vehicle->MoverParameters->enrot * 60, 0 ) + " tmrot="
|
||||
+ to_string( std::abs( vehicle->MoverParameters->nrot ) * vehicle->MoverParameters->Transmision.Ratio * 60, 0 );
|
||||
+ "; 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 )
|
||||
+ " mm; enrot=" + to_string( vehicle->MoverParameters->enrot * 60, 0 )
|
||||
+ " tmrot=" + to_string( std::abs( vehicle->MoverParameters->nrot ) * vehicle->MoverParameters->Transmision.Ratio * 60, 0 )
|
||||
+ "; ventrot=" + to_string( vehicle->MoverParameters->RventRot, 1 );
|
||||
|
||||
uitextline2 =
|
||||
"HamZ=" + to_string( vehicle->MoverParameters->fBrakeCtrlPos, 2 )
|
||||
@@ -2188,14 +2186,14 @@ world_environment::update() {
|
||||
auto const skydomecolour = m_skydome.GetAverageColor();
|
||||
auto const skydomehsv = RGBtoHSV( skydomecolour );
|
||||
// sun strength is reduced by overcast level
|
||||
keylightintensity *= ( 1.0f - Global::Overcast * 0.65f );
|
||||
keylightintensity *= ( 1.0f - std::min( 1.f, Global::Overcast ) * 0.65f );
|
||||
|
||||
// intensity combines intensity of the sun and the light reflected by the sky dome
|
||||
// it'd be more technically correct to have just the intensity of the sun here,
|
||||
// but whether it'd _look_ better is something to be tested
|
||||
auto const intensity = std::min( 1.15f * ( 0.05f + keylightintensity + skydomehsv.z ), 1.25f );
|
||||
// the impact of sun component is reduced proportionally to overcast level, as overcast increases role of ambient light
|
||||
auto const diffuselevel = interpolate( keylightintensity, intensity * ( 1.0f - twilightfactor ), 1.0f - Global::Overcast * 0.75f );
|
||||
auto const diffuselevel = interpolate( keylightintensity, intensity * ( 1.0f - twilightfactor ), 1.0f - std::min( 1.f, Global::Overcast ) * 0.75f );
|
||||
// ...update light colours and intensity.
|
||||
keylightcolor = keylightcolor * diffuselevel;
|
||||
Global::DayLight.diffuse = glm::vec4( keylightcolor, Global::DayLight.diffuse.a );
|
||||
|
||||
@@ -342,6 +342,15 @@ mouse_input::default_bindings() {
|
||||
{ "radio_sw:", {
|
||||
user_command::radiotoggle,
|
||||
user_command::none } },
|
||||
{ "radiochannel_sw:", {
|
||||
user_command::radiochannelincrease,
|
||||
user_command::radiochanneldecrease } },
|
||||
{ "radiochannelprev_sw:", {
|
||||
user_command::radiochanneldecrease,
|
||||
user_command::none } },
|
||||
{ "radiochannelnext_sw:", {
|
||||
user_command::radiochannelincrease,
|
||||
user_command::none } },
|
||||
{ "pantfront_sw:", {
|
||||
user_command::pantographtogglefront,
|
||||
user_command::none } },
|
||||
|
||||
@@ -34,10 +34,6 @@ private:
|
||||
|
||||
user_command left;
|
||||
user_command right;
|
||||
|
||||
mouse_commands( user_command const Left, user_command const Right ):
|
||||
left(Left), right(Right)
|
||||
{}
|
||||
};
|
||||
|
||||
typedef std::unordered_map<std::string, mouse_commands> controlcommands_map;
|
||||
|
||||
14
renderer.cpp
14
renderer.cpp
@@ -1453,7 +1453,7 @@ opengl_renderer::Render( world_environment *Environment ) {
|
||||
GL_LIGHT_MODEL_AMBIENT,
|
||||
glm::value_ptr(
|
||||
interpolate( Environment->m_skydome.GetAverageColor(), suncolor, duskfactor * 0.25f )
|
||||
* ( 1.0f - Global::Overcast * 0.5f ) // overcast darkens the clouds
|
||||
* interpolate( 1.f, 0.35f, Global::Overcast / 2.f ) // overcast darkens the clouds
|
||||
* 2.5f // arbitrary adjustment factor
|
||||
) );
|
||||
// render
|
||||
@@ -3135,11 +3135,17 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
|
||||
static_cast<float>( TSubModel::fSquareDist / Submodel->fSquareMaxDist ) ); // pozycja punktu świecącego względem kamery
|
||||
Submodel->fCosViewAngle = glm::dot( glm::normalize( modelview * glm::vec4( 0.f, 0.f, -1.f, 1.f ) - lightcenter ), glm::normalize( -lightcenter ) );
|
||||
|
||||
float glarelevel = 0.6f; // luminosity at night is at level of ~0.1, so the overall resulting transparency is ~0.5 at full 'brightness'
|
||||
float glarelevel = 0.6f; // luminosity at night is at level of ~0.1, so the overall resulting transparency in clear conditions is ~0.5 at full 'brightness'
|
||||
if( Submodel->fCosViewAngle > Submodel->fCosFalloffAngle ) {
|
||||
|
||||
// only bother if the viewer is inside the visibility cone
|
||||
if( Global::Overcast > 1.0 ) {
|
||||
// increase the glare in rainy/foggy conditions
|
||||
glarelevel += std::max( 0.f, 0.5f * ( Global::Overcast - 1.f ) );
|
||||
}
|
||||
// scale it down based on view angle
|
||||
glarelevel *= ( Submodel->fCosViewAngle - Submodel->fCosFalloffAngle ) / ( 1.0f - Submodel->fCosFalloffAngle );
|
||||
glarelevel = std::max( 0.0f, glarelevel - static_cast<float>(Global::fLuminance) );
|
||||
// reduce the glare in bright daylight
|
||||
glarelevel = clamp( glarelevel - static_cast<float>(Global::fLuminance), 0.f, 1.f );
|
||||
|
||||
if( glarelevel > 0.0f ) {
|
||||
// setup
|
||||
|
||||
@@ -164,7 +164,7 @@ state_manager::deserialize_atmo( cParser &Input, scene::scratch_data &Scratchpad
|
||||
std::string token { Input.getToken<std::string>() };
|
||||
if( token != "endatmo" ) {
|
||||
// optional overcast parameter
|
||||
Global::Overcast = clamp( std::stof( token ), 0.f, 1.f );
|
||||
Global::Overcast = clamp( std::stof( token ), 0.f, 2.f );
|
||||
}
|
||||
while( ( false == token.empty() )
|
||||
&& ( token != "endatmo" ) ) {
|
||||
|
||||
@@ -275,8 +275,8 @@ void CSkyDome::RebuildColors() {
|
||||
float const y = PerezFunctionO2( perezy, icostheta, gamma, cosgamma2, zenithy );
|
||||
|
||||
// luminance(Y) for clear & overcast sky
|
||||
float const yclear = PerezFunctionO2( perezluminance, icostheta, gamma, cosgamma2, zenithluminance );
|
||||
float const yover = zenithluminance * ( 1.0f + 2.0f * vertex.y ) / 3.0f;
|
||||
float const yclear = std::max( 0.01f, PerezFunctionO2( perezluminance, icostheta, gamma, cosgamma2, zenithluminance ) );
|
||||
float const yover = std::max( 0.01f, zenithluminance * ( 1.0f + 2.0f * vertex.y ) / 3.0f );
|
||||
|
||||
float const Y = interpolate( yclear, yover, m_overcast );
|
||||
float const X = (x / y) * Y;
|
||||
|
||||
@@ -63,6 +63,9 @@ static std::unordered_map<std::string, std::string> m_cabcontrols = {
|
||||
{ "converteroff_sw:", "converter" },
|
||||
{ "main_sw:", "line breaker" },
|
||||
{ "radio_sw:", "radio" },
|
||||
{ "radiochannel_sw:", "radio channel" },
|
||||
{ "radiochannelprev_sw:", "radio channel" },
|
||||
{ "radiochannelnext_sw:", "radio channel" },
|
||||
{ "pantfront_sw:", "pantograph A" },
|
||||
{ "pantrear_sw:", "pantograph B" },
|
||||
{ "pantfrontoff_sw:", "pantograph A" },
|
||||
|
||||
Reference in New Issue
Block a user