build 181016. freespot color override, vehicle start jolt sound, switch trackbed generation fixes

This commit is contained in:
tmj-fstate
2018-10-16 20:11:23 +02:00
parent 4474117878
commit 841e18f170
11 changed files with 155 additions and 57 deletions

View File

@@ -413,11 +413,9 @@ void TAnimContainer::EventAssign(basic_event *ev)
//------------------------------------------------------------------------------
TAnimModel::TAnimModel( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {
// TODO: wrap these in a tuple and move to underlying model
for( int index = 0; index < iMaxNumLights; ++index ) {
LightsOn[ index ] = LightsOff[ index ] = nullptr; // normalnie nie ma
lsLights[ index ] = ls_Off; // a jeśli są, to wyłączone
}
m_lightcolors.fill( glm::vec3{ -1.f } );
m_lightopacities.fill( 1.f );
}
TAnimModel::~TAnimModel()
@@ -498,20 +496,44 @@ bool TAnimModel::Load(cParser *parser, bool ter)
if (LightsOn[i] || LightsOff[i]) // Ra: zlikwidowałem wymóg istnienia obu
iNumLights = i + 1;
if ( parser->getToken<std::string>() == "lights" )
{
int i = 0;
std::string token = parser->getToken<std::string>();
while( ( token != "" )
&& ( token != "endmodel" ) ) {
std::string token;
do {
token = parser->getToken<std::string>();
LightSet( i, std::stof( token ) ); // stan światła jest liczbą z ułamkiem
++i;
if( token == "lights" ) {
auto i{ 0 };
while( ( false == ( token = parser->getToken<std::string>() ).empty() )
&& ( token != "lightcolors" )
&& ( token != "endmodel" ) ) {
if( i < iNumLights ) {
// stan światła jest liczbą z ułamkiem
LightSet( i, std::stof( token ) );
}
++i;
}
}
if( token == "lightcolors" ) {
auto i{ 0 };
while( ( false == ( token = parser->getToken<std::string>() ).empty() )
&& ( token != "lights" )
&& ( token != "endmodel" ) ) {
if( ( i < iNumLights )
&& ( token != "-1" ) ) { // -1 leaves the default color intact
auto const lightcolor { std::stoi( token, 0, 16 ) };
m_lightcolors[i] = {
( ( lightcolor >> 16 ) & 0xff ) / 255.f,
( ( lightcolor >> 8 ) & 0xff ) / 255.f,
( ( lightcolor ) & 0xff ) / 255.f };
}
++i;
}
}
} while( ( false == token.empty() )
&& ( token != "endmodel" ) );
token = "";
parser->getTokens(); *parser >> token;
}
}
return true;
}
@@ -683,6 +705,10 @@ void TAnimModel::RaPrepare()
if (LightsOff[i])
LightsOff[i]->iVisible = !state;
}
// potentially modify freespot colors
if( LightsOn[i] ) {
LightsOn[i]->SetDiffuseOverride( m_lightcolors[i], true);
}
}
TSubModel::iInstance = reinterpret_cast<std::uintptr_t>( this ); //żeby nie robić cudzych animacji
TSubModel::pasText = &asText; // przekazanie tekstu do wyświetlacza (!!!! do przemyślenia)