mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 09:59:18 +02:00
added headlights dimming switch, removed obsolete sub-model from dynamic object class
This commit is contained in:
14
DynObj.cpp
14
DynObj.cpp
@@ -557,8 +557,6 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
||||
mdLoad->GetSMRoot()->SetTranslate(modelShake + vFloor);
|
||||
if (mdLowPolyInt)
|
||||
mdLowPolyInt->GetSMRoot()->SetTranslate(modelShake);
|
||||
if (mdPrzedsionek)
|
||||
mdPrzedsionek->GetSMRoot()->SetTranslate(modelShake);
|
||||
// ABu: koniec rzucania
|
||||
// ABu011104: liczenie obrotow wozkow
|
||||
ABuBogies();
|
||||
@@ -1707,7 +1705,6 @@ TDynamicObject::TDynamicObject()
|
||||
smLoadMode = NULL;
|
||||
mdLoad = NULL;
|
||||
mdLowPolyInt = NULL;
|
||||
mdPrzedsionek = NULL;
|
||||
//smMechanik0 = smMechanik1 = NULL;
|
||||
smBuforLewy[0] = smBuforLewy[1] = NULL;
|
||||
smBuforPrawy[0] = smBuforPrawy[1] = NULL;
|
||||
@@ -4503,15 +4500,6 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
// w cyklu
|
||||
// nieprzezroczystych
|
||||
}
|
||||
/*
|
||||
// Winger 040304 - ladowanie przedsionkow dla EZT
|
||||
if (MoverParameters->TrainType == dt_EZT)
|
||||
{
|
||||
asModel = "przedsionki.t3d";
|
||||
asModel = BaseDir + asModel;
|
||||
mdPrzedsionek = TModelsManager::GetModel(asModel, true);
|
||||
}
|
||||
*/
|
||||
if (!MoverParameters->LoadAccepted.empty())
|
||||
// if (MoverParameters->LoadAccepted!=AnsiString("")); // &&
|
||||
// MoverParameters->LoadType!=AnsiString("passengers"))
|
||||
@@ -5424,8 +5412,6 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
// binarnego
|
||||
if (mdLoad)
|
||||
mdLoad->Init();
|
||||
if (mdPrzedsionek)
|
||||
mdPrzedsionek->Init();
|
||||
if (mdLowPolyInt)
|
||||
mdLowPolyInt->Init();
|
||||
// sHorn2.CopyIfEmpty(sHorn1); ///żeby jednak trąbił też drugim
|
||||
|
||||
2
DynObj.h
2
DynObj.h
@@ -180,7 +180,6 @@ private:
|
||||
public: // modele składowe pojazdu
|
||||
TModel3d *mdModel; // model pudła
|
||||
TModel3d *mdLoad; // model zmiennego ładunku
|
||||
TModel3d *mdPrzedsionek; // model przedsionków dla EZT - może użyć mdLoad zamiast?
|
||||
TModel3d *mdKabina; // model kabiny dla użytkownika; McZapkie-030303: to z train.h
|
||||
TModel3d *mdLowPolyInt; // ABu 010305: wnetrze lowpoly
|
||||
float3 InteriorLight{ 0.9f * 255.0f / 255.0f, 0.9f * 216.0f / 255.0f, 0.9f * 176.0f / 255.0f }; // tungsten light. TODO: allow definition of light type?
|
||||
@@ -346,6 +345,7 @@ public: // modele składowe pojazdu
|
||||
|
||||
public:
|
||||
int *iLights; // wskaźnik na bity zapalonych świateł (własne albo innego członu)
|
||||
bool DimHeadlights{ false }; // status of the headlight dimming toggle. NOTE: single toggle for all lights is a simplification. TODO: separate per-light switches
|
||||
double fTrackBlock; // odległość do przeszkody do dalszego ruchu (wykrywanie kolizji z innym
|
||||
// pojazdem)
|
||||
TDynamicObject * PrevAny();
|
||||
|
||||
@@ -1043,9 +1043,12 @@ void Global::InitKeys()
|
||||
Keys[k_PantRearDown] = 'O';
|
||||
// Winger 020304 - ogrzewanie
|
||||
Keys[k_Heating] = 'H';
|
||||
// headlights
|
||||
Keys[k_LeftSign] = 'Y';
|
||||
Keys[k_UpperSign] = 'U';
|
||||
Keys[k_RightSign] = 'I';
|
||||
Keys[k_DimHeadlights] = 'L';
|
||||
// tail lights
|
||||
Keys[k_EndSign] = 'T';
|
||||
|
||||
Keys[k_SmallCompressor] = 'V';
|
||||
|
||||
@@ -110,7 +110,8 @@ const int k_Active = 71;
|
||||
// Winger 020304
|
||||
const int k_Battery = 72;
|
||||
const int k_WalkMode = 73;
|
||||
const int MaxKeys = 74;
|
||||
int const k_DimHeadlights = 74;
|
||||
const int MaxKeys = 75;
|
||||
|
||||
// klasy dla wskaźników globalnych
|
||||
class TGround;
|
||||
|
||||
76
Train.cpp
76
Train.cpp
@@ -508,7 +508,7 @@ void TTrain::OnKeyDown(int cKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cKey == Global::Keys[k_StLinOff])
|
||||
else if ((cKey == Global::Keys[k_StLinOff]) && (!Global::shiftState) && (!Global::ctrlState)) // shift&ctrl are used for light dimming
|
||||
{
|
||||
if (mvControlled->TrainType == dt_EZT)
|
||||
{
|
||||
@@ -2339,7 +2339,7 @@ if
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cKey == Global::Keys[k_StLinOff]) // Winger 110904: wylacznik st.
|
||||
else if ((cKey == Global::Keys[k_StLinOff]) && (!Global::shiftState) && (!Global::ctrlState)) // Winger 110904: wylacznik st.
|
||||
// liniowych
|
||||
{
|
||||
if ((mvControlled->TrainType != dt_EZT) && (mvControlled->TrainType != dt_EP05) &&
|
||||
@@ -2468,6 +2468,29 @@ if
|
||||
++iRadioChannel; // 0=wyłączony
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: break the mess above into individual command-based routines.
|
||||
// TODO: test for modifiers inside the routines, instead of grouping by the modifier
|
||||
// TODO: do away with the modifier tests, each command should be separate and issued by input processor(s) up the chain
|
||||
if( cKey == Global::Keys[ k_DimHeadlights ] ) {
|
||||
// headlight strength toggle
|
||||
if( !Global::ctrlState ) {
|
||||
// switch uses either ctrl, or ctrl+shift, so we can bail early here
|
||||
return;
|
||||
}
|
||||
if( DynamicObject->DimHeadlights && (!Global::shiftState)) {
|
||||
DynamicObject->DimHeadlights = false;
|
||||
// switch sound
|
||||
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||
dsbSwitch->Play( 0, 0, 0 );
|
||||
}
|
||||
else if( (!DynamicObject->DimHeadlights) && (Global::shiftState)) {
|
||||
DynamicObject->DimHeadlights = true;
|
||||
// switch sound
|
||||
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||
dsbSwitch->Play( 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnKeyUp(int cKey)
|
||||
@@ -2477,7 +2500,7 @@ void TTrain::OnKeyUp(int cKey)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cKey == Global::Keys[k_StLinOff]) // Winger 110904: wylacznik st. liniowych
|
||||
if ((cKey == Global::Keys[k_StLinOff]) && (!Global::shiftState) && (!Global::ctrlState)) // Winger 110904: wylacznik st. liniowych
|
||||
{ // zwolnienie klawisza daje powrót przycisku do zwykłego stanu
|
||||
if ((mvControlled->TrainType != dt_EZT) && (mvControlled->TrainType != dt_EP05) &&
|
||||
(mvControlled->TrainType != dt_ET40))
|
||||
@@ -3877,41 +3900,6 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggLeftEndLightButton.PutValue(0);
|
||||
}
|
||||
|
||||
//---------
|
||||
// hunter-101211: poprawka na zle obracajace sie przelaczniki
|
||||
/*
|
||||
if (((DynamicObject->iLights[0]&1)==1)
|
||||
||((DynamicObject->iLights[1]&1)==1))
|
||||
ggLeftLightButton.PutValue(1);
|
||||
if (((DynamicObject->iLights[0]&16)==16)
|
||||
||((DynamicObject->iLights[1]&16)==16))
|
||||
ggRightLightButton.PutValue(1);
|
||||
if (((DynamicObject->iLights[0]&4)==4)
|
||||
||((DynamicObject->iLights[1]&4)==4))
|
||||
ggUpperLightButton.PutValue(1);
|
||||
|
||||
if (((DynamicObject->iLights[0]&2)==2)
|
||||
||((DynamicObject->iLights[1]&2)==2))
|
||||
if (ggLeftEndLightButton.SubModel)
|
||||
{
|
||||
ggLeftEndLightButton.PutValue(1);
|
||||
ggLeftLightButton.PutValue(0);
|
||||
}
|
||||
else
|
||||
ggLeftLightButton.PutValue(-1);
|
||||
|
||||
if (((DynamicObject->iLights[0]&32)==32)
|
||||
||((DynamicObject->iLights[1]&32)==32))
|
||||
if (ggRightEndLightButton.SubModel)
|
||||
{
|
||||
ggRightEndLightButton.PutValue(1);
|
||||
ggRightLightButton.PutValue(0);
|
||||
}
|
||||
else
|
||||
ggRightLightButton.PutValue(-1);
|
||||
*/
|
||||
|
||||
//--------------
|
||||
// hunter-230112
|
||||
|
||||
// REFLEKTOR LEWY
|
||||
@@ -4049,6 +4037,11 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggLightsButton.PutValue(mvOccupied->LightsPos - 1);
|
||||
ggLightsButton.Update();
|
||||
}
|
||||
if( ggDimHeadlightsButton.SubModel ) {
|
||||
|
||||
ggDimHeadlightsButton.PutValue( DynamicObject->DimHeadlights ? 1.0 : 0.0 );
|
||||
ggDimHeadlightsButton.Update();
|
||||
}
|
||||
|
||||
//---------
|
||||
// Winger 010304 - pantografy
|
||||
@@ -5855,6 +5848,7 @@ void TTrain::clear_cab_controls()
|
||||
ggLeftLightButton.Clear();
|
||||
ggRightLightButton.Clear();
|
||||
ggUpperLightButton.Clear();
|
||||
ggDimHeadlightsButton.Clear();
|
||||
ggLeftEndLightButton.Clear();
|
||||
ggRightEndLightButton.Clear();
|
||||
ggLightsButton.Clear();
|
||||
@@ -6259,7 +6253,11 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
// swiatlo
|
||||
ggRightLightButton.Load(Parser, DynamicObject->mdKabina);
|
||||
}
|
||||
else if (Label == "leftend_sw:")
|
||||
else if( Label == "dimheadlights_sw:" ) {
|
||||
// swiatlo
|
||||
ggDimHeadlightsButton.Load( Parser, DynamicObject->mdKabina );
|
||||
}
|
||||
else if( Label == "leftend_sw:" )
|
||||
{
|
||||
// swiatlo
|
||||
ggLeftEndLightButton.Load(Parser, DynamicObject->mdKabina);
|
||||
|
||||
1
Train.h
1
Train.h
@@ -177,6 +177,7 @@ class TTrain
|
||||
TGauge ggLeftEndLightButton;
|
||||
TGauge ggRightEndLightButton;
|
||||
TGauge ggLightsButton; // przelacznik reflektorow (wszystkich)
|
||||
TGauge ggDimHeadlightsButton; // headlights dimming switch
|
||||
|
||||
// hunter-230112: przelacznik swiatel tylnich
|
||||
TGauge ggRearUpperLightButton;
|
||||
|
||||
@@ -68,7 +68,7 @@ light_array::update() {
|
||||
if( light.count > 0 ) {
|
||||
// TODO: intensity can be affected further by dim switch or other factors
|
||||
light.intensity = std::max( 0.0f, std::log( (float)light.count + 1.0f ) );
|
||||
// light.intensity = std::max( 0.0f, std::log( (float)light.count + 3.0f ) );
|
||||
light.intensity *= ( light.owner->DimHeadlights ? 0.6f : 1.0f );
|
||||
}
|
||||
else {
|
||||
light.intensity = 0.0f;
|
||||
|
||||
@@ -140,8 +140,6 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) {
|
||||
|
||||
if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku
|
||||
Render( Dynamic->mdLoad, Dynamic, squaredistance );
|
||||
if( Dynamic->mdPrzedsionek )
|
||||
Render( Dynamic->mdPrzedsionek, Dynamic, squaredistance );
|
||||
|
||||
::glPopMatrix();
|
||||
|
||||
@@ -246,8 +244,6 @@ opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) {
|
||||
|
||||
if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku
|
||||
Render_Alpha( Dynamic->mdLoad, Dynamic, squaredistance );
|
||||
if( Dynamic->mdPrzedsionek )
|
||||
Render_Alpha( Dynamic->mdPrzedsionek, Dynamic, squaredistance );
|
||||
|
||||
::glPopMatrix();
|
||||
|
||||
@@ -343,7 +339,7 @@ opengl_renderer::Update_Lights( light_array const &Lights ) {
|
||||
renderlight->ambient[ 1 ] = std::max( 0.0, scenelight.color.y * scenelight.intensity - luminance );
|
||||
renderlight->ambient[ 2 ] = std::max( 0.0, scenelight.color.z * scenelight.intensity - luminance );
|
||||
|
||||
::glLightf( renderlight->id, GL_LINEAR_ATTENUATION, (0.25f * scenelight.count) / std::pow( scenelight.count, 2 ) );
|
||||
::glLightf( renderlight->id, GL_LINEAR_ATTENUATION, (0.25f * scenelight.count) / std::pow( scenelight.count, 2 ) * (scenelight.owner->DimHeadlights ? 1.25f : 1.0f) );
|
||||
::glEnable( renderlight->id );
|
||||
|
||||
renderlight->apply_intensity();
|
||||
|
||||
Reference in New Issue
Block a user