mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 17:29:18 +02:00
vehicle mesh load fail crash fix, material and texture loading tweaks, minor bug fixes
This commit is contained in:
176
DynObj.cpp
176
DynObj.cpp
@@ -40,6 +40,16 @@ std::string const TDynamicObject::MED_labels[] = {
|
|||||||
|
|
||||||
bool TDynamicObject::bDynamicRemove { false };
|
bool TDynamicObject::bDynamicRemove { false };
|
||||||
|
|
||||||
|
// helper, locates submodel with specified name in specified 3d model; returns: pointer to the submodel, or null
|
||||||
|
TSubModel *
|
||||||
|
GetSubmodelFromName( TModel3d * const Model, std::string const Name ) {
|
||||||
|
|
||||||
|
return (
|
||||||
|
Model ?
|
||||||
|
Model->GetFromName( Name ) :
|
||||||
|
nullptr );
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void TAnimPant::AKP_4E()
|
void TAnimPant::AKP_4E()
|
||||||
{ // ustawienie wymiarów dla pantografu AKP-4E
|
{ // ustawienie wymiarów dla pantografu AKP-4E
|
||||||
@@ -4421,7 +4431,7 @@ void TDynamicObject::RenderSounds() {
|
|||||||
// wczytywanie pliku z danymi multimedialnymi (dzwieki)
|
// wczytywanie pliku z danymi multimedialnymi (dzwieki)
|
||||||
void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName, std::string ReplacableSkin ) {
|
void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName, std::string ReplacableSkin ) {
|
||||||
|
|
||||||
double dSDist;
|
replace_slashes( BaseDir );
|
||||||
Global.asCurrentDynamicPath = BaseDir;
|
Global.asCurrentDynamicPath = BaseDir;
|
||||||
std::string asFileName = BaseDir + TypeName + ".mmd";
|
std::string asFileName = BaseDir + TypeName + ".mmd";
|
||||||
std::string asLoadName;
|
std::string asLoadName;
|
||||||
@@ -4469,10 +4479,9 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
asModel = BaseDir + asModel; // McZapkie 2002-07-20: dynamics maja swoje modele w dynamics/basedir
|
asModel = BaseDir + asModel; // McZapkie 2002-07-20: dynamics maja swoje modele w dynamics/basedir
|
||||||
Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/...
|
Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/...
|
||||||
mdModel = TModelsManager::GetModel(asModel, true);
|
mdModel = TModelsManager::GetModel(asModel, true);
|
||||||
assert( mdModel != nullptr ); // TODO: handle this more gracefully than all going to shit
|
|
||||||
if (ReplacableSkin != "none")
|
if (ReplacableSkin != "none")
|
||||||
{
|
{
|
||||||
std::string nowheretexture = TextureTest(Global.asCurrentTexturePath + "nowhere"); // na razie prymitywnie
|
std::string nowheretexture = TextureTest( Global.asCurrentTexturePath + "nowhere" ); // na razie prymitywnie
|
||||||
if( false == nowheretexture.empty() ) {
|
if( false == nowheretexture.empty() ) {
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Material( nowheretexture );
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Material( nowheretexture );
|
||||||
}
|
}
|
||||||
@@ -4486,8 +4495,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
int skinindex = 0;
|
int skinindex = 0;
|
||||||
std::string texturename; nameparser >> texturename;
|
std::string texturename; nameparser >> texturename;
|
||||||
while( ( texturename != "" ) && ( skinindex < 4 ) ) {
|
while( ( texturename != "" ) && ( skinindex < 4 ) ) {
|
||||||
erase_extension( texturename );
|
m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.Fetch_Material( texturename );
|
||||||
m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + texturename );
|
|
||||||
++skinindex;
|
++skinindex;
|
||||||
texturename = ""; nameparser >> texturename;
|
texturename = ""; nameparser >> texturename;
|
||||||
}
|
}
|
||||||
@@ -4498,7 +4506,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
erase_extension( ReplacableSkin );
|
erase_extension( ReplacableSkin );
|
||||||
int skinindex = 0;
|
int skinindex = 0;
|
||||||
do {
|
do {
|
||||||
material_handle material = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + ReplacableSkin + "," + std::to_string( skinindex + 1 ), true );
|
material_handle material = GfxRenderer.Fetch_Material( ReplacableSkin + "," + std::to_string( skinindex + 1 ), true );
|
||||||
if( material == null_handle ) {
|
if( material == null_handle ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4508,12 +4516,12 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
m_materialdata.multi_textures = skinindex;
|
m_materialdata.multi_textures = skinindex;
|
||||||
if( m_materialdata.multi_textures == 0 ) {
|
if( m_materialdata.multi_textures == 0 ) {
|
||||||
// zestaw nie zadziałał, próbujemy normanie
|
// zestaw nie zadziałał, próbujemy normanie
|
||||||
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + ReplacableSkin );
|
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( ReplacableSkin );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + ReplacableSkin );
|
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( ReplacableSkin );
|
||||||
}
|
}
|
||||||
if( GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) {
|
if( GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) {
|
||||||
// tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
// tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
@@ -4641,6 +4649,11 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
// ABu: wnetrze lowpoly
|
// ABu: wnetrze lowpoly
|
||||||
parser.getTokens();
|
parser.getTokens();
|
||||||
parser >> asModel;
|
parser >> asModel;
|
||||||
|
replace_slashes( asModel );
|
||||||
|
if( asModel[ 0 ] == '/' ) {
|
||||||
|
// filename can potentially begin with a slash, and we don't need it
|
||||||
|
asModel.erase( 0, 1 );
|
||||||
|
}
|
||||||
asModel = BaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir
|
asModel = BaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir
|
||||||
Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/...
|
Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/...
|
||||||
mdLowPolyInt = TModelsManager::GetModel(asModel, true);
|
mdLowPolyInt = TModelsManager::GetModel(asModel, true);
|
||||||
@@ -4650,7 +4663,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
// Ra 15-01: gałka nastawy hamulca
|
// Ra 15-01: gałka nastawy hamulca
|
||||||
parser.getTokens();
|
parser.getTokens();
|
||||||
parser >> asAnimName;
|
parser >> asAnimName;
|
||||||
smBrakeMode = mdModel->GetFromName(asAnimName);
|
smBrakeMode = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
// jeszcze wczytać kąty obrotu dla poszczególnych ustawień
|
// jeszcze wczytać kąty obrotu dla poszczególnych ustawień
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4658,7 +4671,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
// Ra 15-01: gałka nastawy hamulca
|
// Ra 15-01: gałka nastawy hamulca
|
||||||
parser.getTokens();
|
parser.getTokens();
|
||||||
parser >> asAnimName;
|
parser >> asAnimName;
|
||||||
smLoadMode = mdModel->GetFromName(asAnimName);
|
smLoadMode = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
// jeszcze wczytać kąty obrotu dla poszczególnych ustawień
|
// jeszcze wczytać kąty obrotu dla poszczególnych ustawień
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4670,7 +4683,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
for (i = 0; i < iAnimType[ANIM_WHEELS]; ++i) // liczba osi
|
for (i = 0; i < iAnimType[ANIM_WHEELS]; ++i) // liczba osi
|
||||||
{ // McZapkie-050402: wyszukiwanie kol o nazwie str*
|
{ // McZapkie-050402: wyszukiwanie kol o nazwie str*
|
||||||
asAnimName = token + std::to_string(i + 1);
|
asAnimName = token + std::to_string(i + 1);
|
||||||
pAnimations[i].smAnimated = mdModel->GetFromName(asAnimName); // ustalenie submodelu
|
pAnimations[i].smAnimated = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
if (pAnimations[i].smAnimated)
|
if (pAnimations[i].smAnimated)
|
||||||
{ //++iAnimatedAxles;
|
{ //++iAnimatedAxles;
|
||||||
pAnimations[i].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
|
pAnimations[i].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
|
||||||
@@ -4733,7 +4746,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
for (int i = 0; i < iAnimType[ANIM_PANTS]; i++)
|
for (int i = 0; i < iAnimType[ANIM_PANTS]; i++)
|
||||||
{ // Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
{ // Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
||||||
asAnimName = token + std::to_string(i + 1);
|
asAnimName = token + std::to_string(i + 1);
|
||||||
sm = mdModel->GetFromName(asAnimName);
|
sm = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
pants[i].smElement[0] = sm; // jak NULL, to nie będzie animowany
|
pants[i].smElement[0] = sm; // jak NULL, to nie będzie animowany
|
||||||
if (sm)
|
if (sm)
|
||||||
{ // w EP09 wywalało się tu z powodu NULL
|
{ // w EP09 wywalało się tu z powodu NULL
|
||||||
@@ -4742,27 +4755,22 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
// m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak)
|
// m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak)
|
||||||
if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z T3D
|
if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z T3D
|
||||||
m.InitialRotate(); // może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, tzn. przed wykonaniem Init()
|
m.InitialRotate(); // może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, tzn. przed wykonaniem Init()
|
||||||
pants[i].fParamPants->vPos.z =
|
pants[i].fParamPants->vPos.z = m[3][0]; // przesunięcie w bok (asymetria)
|
||||||
m[3][0]; // przesunięcie w bok (asymetria)
|
pants[i].fParamPants->vPos.y = m[3][1]; // przesunięcie w górę odczytane z modelu
|
||||||
pants[i].fParamPants->vPos.y =
|
|
||||||
m[3][1]; // przesunięcie w górę odczytane z modelu
|
|
||||||
if ((sm = pants[i].smElement[0]->ChildGet()) != NULL)
|
if ((sm = pants[i].smElement[0]->ChildGet()) != NULL)
|
||||||
{ // jeśli ma potomny, można policzyć długość (odległość potomnego od osi obrotu)
|
{ // jeśli ma potomny, można policzyć długość (odległość potomnego od osi obrotu)
|
||||||
m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik, nie trzeba kopiować
|
m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik, nie trzeba kopiować
|
||||||
// może trzeba: pobrać macierz dolnego ramienia, wyzerować przesunięcie, przemnożyć przez macierz górnego
|
// może trzeba: pobrać macierz dolnego ramienia, wyzerować przesunięcie, przemnożyć przez macierz górnego
|
||||||
pants[i].fParamPants->fHoriz = -fabs(m[3][1]);
|
pants[i].fParamPants->fHoriz = -fabs(m[3][1]);
|
||||||
pants[i].fParamPants->fLenL1 =
|
pants[i].fParamPants->fLenL1 = hypot(m[3][1], m[3][2]); // po osi OX nie potrzeba
|
||||||
hypot(m[3][1], m[3][2]); // po osi OX nie potrzeba
|
pants[i].fParamPants->fAngleL0 = atan2(fabs(m[3][2]), fabs(m[3][1]));
|
||||||
pants[i].fParamPants->fAngleL0 =
|
|
||||||
atan2(fabs(m[3][2]), fabs(m[3][1]));
|
|
||||||
// if (pants[i].fParamPants->fAngleL0<M_PI_2)
|
// if (pants[i].fParamPants->fAngleL0<M_PI_2)
|
||||||
// pants[i].fParamPants->fAngleL0+=M_PI; //gdyby w odwrotną stronę wyszło
|
// pants[i].fParamPants->fAngleL0+=M_PI; //gdyby w odwrotną stronę wyszło
|
||||||
// if
|
// if
|
||||||
// ((pants[i].fParamPants->fAngleL0<0.03)||(pants[i].fParamPants->fAngleL0>0.09))
|
// ((pants[i].fParamPants->fAngleL0<0.03)||(pants[i].fParamPants->fAngleL0>0.09))
|
||||||
// //normalnie ok. 0.05
|
// //normalnie ok. 0.05
|
||||||
// pants[i].fParamPants->fAngleL0=pants[i].fParamPants->fAngleL;
|
// pants[i].fParamPants->fAngleL0=pants[i].fParamPants->fAngleL;
|
||||||
pants[i].fParamPants->fAngleL = pants[i].fParamPants->fAngleL0; // początkowy kąt dolnego
|
pants[i].fParamPants->fAngleL = pants[i].fParamPants->fAngleL0; // początkowy kąt dolnego ramienia
|
||||||
// ramienia
|
|
||||||
if ((sm = sm->ChildGet()) != NULL)
|
if ((sm = sm->ChildGet()) != NULL)
|
||||||
{ // jeśli dalej jest ślizg, można policzyć długość górnego ramienia
|
{ // jeśli dalej jest ślizg, można policzyć długość górnego ramienia
|
||||||
m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik,
|
m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik,
|
||||||
@@ -4788,12 +4796,9 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
float det = Det(m);
|
float det = Det(m);
|
||||||
if (std::fabs(det - 1.0) < 0.001) // dopuszczamy 1 promil błędu na skalowaniu ślizgu
|
if (std::fabs(det - 1.0) < 0.001) // dopuszczamy 1 promil błędu na skalowaniu ślizgu
|
||||||
{ // skalowanie jest w normie, można pobrać wymiary z modelu
|
{ // skalowanie jest w normie, można pobrać wymiary z modelu
|
||||||
pants[i].fParamPants->fHeight =
|
pants[i].fParamPants->fHeight = sm->MaxY(m); // przeliczenie maksimum wysokości wierzchołków względem macierzy
|
||||||
sm->MaxY(m); // przeliczenie maksimum wysokości wierzchołków względem macierzy
|
pants[i].fParamPants->fHeight -= m[3][1]; // odjęcie wysokości pivota ślizgu
|
||||||
pants[i].fParamPants->fHeight -=
|
pants[i].fParamPants->vPos.x = m[3][2]; // przy okazji odczytać z modelu pozycję w długości
|
||||||
m[3][1]; // odjęcie wysokości pivota ślizgu
|
|
||||||
pants[i].fParamPants->vPos.x =
|
|
||||||
m[3][2]; // przy okazji odczytać z modelu pozycję w długości
|
|
||||||
// ErrorLog("Model OK: "+asModel+",
|
// ErrorLog("Model OK: "+asModel+",
|
||||||
// height="+pants[i].fParamPants->fHeight);
|
// height="+pants[i].fParamPants->fHeight);
|
||||||
// ErrorLog("Model OK: "+asModel+",
|
// ErrorLog("Model OK: "+asModel+",
|
||||||
@@ -4801,8 +4806,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // gdy ktoś przesadził ze skalowaniem
|
{ // gdy ktoś przesadził ze skalowaniem
|
||||||
pants[i].fParamPants->fHeight =
|
pants[i].fParamPants->fHeight = 0.0; // niech będzie odczyt z pantfactors:
|
||||||
0.0; // niech będzie odczyt z pantfactors:
|
|
||||||
ErrorLog(
|
ErrorLog(
|
||||||
"Bad model: " + asModel + ", scale of " + (sm->pName) + " is " + std::to_string(100.0 * det) + "%",
|
"Bad model: " + asModel + ", scale of " + (sm->pName) + " is " + std::to_string(100.0 * det) + "%",
|
||||||
logtype::model );
|
logtype::model );
|
||||||
@@ -4810,8 +4814,11 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
ErrorLog("Bad model: " + asFileName + " - missed submodel " + asAnimName, logtype::model); // brak ramienia
|
// brak ramienia
|
||||||
|
pants[ i ].fParamPants->fHeight = 0.0; // niech będzie odczyt z pantfactors:
|
||||||
|
ErrorLog( "Bad model: " + asFileName + " - missed submodel " + asAnimName, logtype::model );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4824,7 +4831,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
|
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
|
||||||
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
||||||
asAnimName = token + std::to_string( i + 1 );
|
asAnimName = token + std::to_string( i + 1 );
|
||||||
sm = mdModel->GetFromName( asAnimName );
|
sm = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
pants[ i ].smElement[ 1 ] = sm; // jak NULL, to nie będzie animowany
|
pants[ i ].smElement[ 1 ] = sm; // jak NULL, to nie będzie animowany
|
||||||
if( sm ) { // w EP09 wywalało się tu z powodu NULL
|
if( sm ) { // w EP09 wywalało się tu z powodu NULL
|
||||||
sm->WillBeAnimated();
|
sm->WillBeAnimated();
|
||||||
@@ -4853,43 +4860,49 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
else if( token == "animpantrg1prefix:" ) {
|
else if( token == "animpantrg1prefix:" ) {
|
||||||
// prefiks ramion górnych 1
|
// prefiks ramion górnych 1
|
||||||
parser.getTokens(); parser >> token;
|
parser.getTokens(); parser >> token;
|
||||||
if( pants ) {
|
if( pants ) {
|
||||||
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
|
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
|
||||||
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
||||||
asAnimName = token + std::to_string( i + 1 );
|
asAnimName = token + std::to_string( i + 1 );
|
||||||
pants[ i ].smElement[ 2 ] = mdModel->GetFromName( asAnimName );
|
pants[ i ].smElement[ 2 ] = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
pants[ i ].smElement[ 2 ]->WillBeAnimated();
|
if( pants[ i ].smElement[ 2 ] ) {
|
||||||
}
|
pants[ i ].smElement[ 2 ]->WillBeAnimated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( token == "animpantrg2prefix:" ) {
|
else if( token == "animpantrg2prefix:" ) {
|
||||||
// prefiks ramion górnych 2
|
// prefiks ramion górnych 2
|
||||||
parser.getTokens(); parser >> token;
|
parser.getTokens(); parser >> token;
|
||||||
if( pants ) {
|
if( pants ) {
|
||||||
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
|
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
|
||||||
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
||||||
asAnimName = token + std::to_string( i + 1 );
|
asAnimName = token + std::to_string( i + 1 );
|
||||||
pants[ i ].smElement[ 3 ] = mdModel->GetFromName( asAnimName );
|
pants[ i ].smElement[ 3 ] = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
pants[ i ].smElement[ 3 ]->WillBeAnimated();
|
if( pants[ i ].smElement[ 3 ] ) {
|
||||||
}
|
pants[ i ].smElement[ 3 ]->WillBeAnimated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( token == "animpantslprefix:" ) {
|
else if( token == "animpantslprefix:" ) {
|
||||||
// prefiks ślizgaczy
|
// prefiks ślizgaczy
|
||||||
parser.getTokens(); parser >> token;
|
parser.getTokens(); parser >> token;
|
||||||
if( pants ) {
|
if( pants ) {
|
||||||
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
|
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) {
|
||||||
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
// Winger 160204: wyszukiwanie max 2 patykow o nazwie str*
|
||||||
asAnimName = token + std::to_string( i + 1 );
|
asAnimName = token + std::to_string( i + 1 );
|
||||||
pants[ i ].smElement[ 4 ] = mdModel->GetFromName( asAnimName );
|
pants[ i ].smElement[ 4 ] = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
pants[ i ].smElement[ 4 ]->WillBeAnimated();
|
if( pants[ i ].smElement[ 4 ] ) {
|
||||||
pants[ i ].yUpdate = std::bind( &TDynamicObject::UpdatePant, this, std::placeholders::_1 );
|
pants[ i ].smElement[ 4 ]->WillBeAnimated();
|
||||||
pants[ i ].fMaxDist = 300 * 300; // nie podnosić w większej odległości
|
pants[ i ].yUpdate = std::bind( &TDynamicObject::UpdatePant, this, std::placeholders::_1 );
|
||||||
pants[ i ].iNumber = i;
|
pants[ i ].fMaxDist = 300 * 300; // nie podnosić w większej odległości
|
||||||
}
|
pants[ i ].iNumber = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( token == "pantfactors:" ) {
|
else if( token == "pantfactors:" ) {
|
||||||
@@ -4914,34 +4927,38 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
if( pants ) {
|
if( pants ) {
|
||||||
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; ++i ) {
|
for( int i = 0; i < iAnimType[ ANIM_PANTS ]; ++i ) {
|
||||||
// przepisanie współczynników do pantografów (na razie nie będzie lepiej)
|
// przepisanie współczynników do pantografów (na razie nie będzie lepiej)
|
||||||
pants[ i ].fParamPants->fAngleL = pants[ i ].fParamPants->fAngleL0; // początkowy kąt dolnego ramienia
|
auto &pantograph { *(pants[ i ].fParamPants) };
|
||||||
pants[ i ].fParamPants->fAngleU = pants[ i ].fParamPants->fAngleU0; // początkowy kąt
|
|
||||||
|
pantograph.fAngleL = pantograph.fAngleL0; // początkowy kąt dolnego ramienia
|
||||||
|
pantograph.fAngleU = pantograph.fAngleU0; // początkowy kąt
|
||||||
// pants[i].fParamPants->PantWys=1.22*sin(pants[i].fParamPants->fAngleL)+1.755*sin(pants[i].fParamPants->fAngleU);
|
// pants[i].fParamPants->PantWys=1.22*sin(pants[i].fParamPants->fAngleL)+1.755*sin(pants[i].fParamPants->fAngleU);
|
||||||
// //wysokość początkowa
|
// //wysokość początkowa
|
||||||
// pants[i].fParamPants->PantWys=1.176289*sin(pants[i].fParamPants->fAngleL)+1.724482197*sin(pants[i].fParamPants->fAngleU);
|
// pants[i].fParamPants->PantWys=1.176289*sin(pants[i].fParamPants->fAngleL)+1.724482197*sin(pants[i].fParamPants->fAngleU);
|
||||||
// //wysokość początkowa
|
// //wysokość początkowa
|
||||||
if( pants[ i ].fParamPants->fHeight == 0.0 ) // gdy jest nieprawdopodobna wartość (np. nie znaleziony ślizg)
|
if( pantograph.fHeight == 0.0 ) // gdy jest nieprawdopodobna wartość (np. nie znaleziony ślizg)
|
||||||
{ // gdy pomiary modelu nie udały się, odczyt podanych parametrów z MMD
|
{ // gdy pomiary modelu nie udały się, odczyt podanych parametrów z MMD
|
||||||
pants[ i ].fParamPants->vPos.x =
|
pantograph.vPos.x =
|
||||||
( i & 1 ) ?
|
( i & 1 ) ?
|
||||||
pant2x :
|
pant2x :
|
||||||
pant1x;
|
pant1x;
|
||||||
pants[ i ].fParamPants->fHeight =
|
pantograph.fHeight =
|
||||||
( i & 1 ) ?
|
( i & 1 ) ?
|
||||||
pant2h :
|
pant2h :
|
||||||
pant1h; // wysokość ślizgu jest zapisana w MMD
|
pant1h; // wysokość ślizgu jest zapisana w MMD
|
||||||
}
|
}
|
||||||
pants[ i ].fParamPants->PantWys =
|
pantograph.PantWys =
|
||||||
pants[ i ].fParamPants->fLenL1 * sin( pants[ i ].fParamPants->fAngleL ) +
|
pantograph.fLenL1 * sin( pantograph.fAngleL ) +
|
||||||
pants[ i ].fParamPants->fLenU1 * sin( pants[ i ].fParamPants->fAngleU ) +
|
pantograph.fLenU1 * sin( pantograph.fAngleU ) +
|
||||||
pants[ i ].fParamPants->fHeight; // wysokość początkowa
|
pantograph.fHeight; // wysokość początkowa
|
||||||
// pants[i].fParamPants->vPos.y=panty-panth-pants[i].fParamPants->PantWys;
|
// pants[i].fParamPants->vPos.y=panty-panth-pants[i].fParamPants->PantWys; //np. 4.429-0.097=4.332=~4.335
|
||||||
// //np. 4.429-0.097=4.332=~4.335
|
if( pantograph.vPos.y == 0.0 ) {
|
||||||
// pants[i].fParamPants->vPos.z=0; //niezerowe dla pantografów
|
// crude fallback, place the pantograph(s) atop of the vehicle-sized box
|
||||||
// asymetrycznych
|
pantograph.vPos.y = MoverParameters->Dim.H - pantograph.fHeight - pantograph.PantWys;
|
||||||
pants[ i ].fParamPants->PantTraction = pants[ i ].fParamPants->PantWys;
|
}
|
||||||
|
// pants[i].fParamPants->vPos.z=0; //niezerowe dla pantografów asymetrycznych
|
||||||
|
pantograph.PantTraction = pantograph.PantWys;
|
||||||
// połowa szerokości ślizgu; jest w "Power: CSW="
|
// połowa szerokości ślizgu; jest w "Power: CSW="
|
||||||
pants[ i ].fParamPants->fWidth = 0.5 * MoverParameters->EnginePowerSource.CollectorParameters.CSW;
|
pantograph.fWidth = 0.5 * MoverParameters->EnginePowerSource.CollectorParameters.CSW;
|
||||||
|
|
||||||
// create sound emitters for the pantograph
|
// create sound emitters for the pantograph
|
||||||
m_pantographsounds.emplace_back();
|
m_pantographsounds.emplace_back();
|
||||||
@@ -5017,11 +5034,13 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
// prefiks wahaczy
|
// prefiks wahaczy
|
||||||
parser.getTokens(); parser >> token;
|
parser.getTokens(); parser >> token;
|
||||||
asAnimName = "";
|
asAnimName = "";
|
||||||
for (int i = 1; i <= 4; i++)
|
for( int i = 1; i <= 4; ++i ) {
|
||||||
{ // McZapkie-050402: wyszukiwanie max 4 wahaczy o nazwie str*
|
// McZapkie-050402: wyszukiwanie max 4 wahaczy o nazwie str*
|
||||||
asAnimName = token + std::to_string(i);
|
asAnimName = token + std::to_string( i );
|
||||||
smWahacze[i - 1] = mdModel->GetFromName(asAnimName);
|
smWahacze[ i - 1 ] = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
smWahacze[i - 1]->WillBeAnimated();
|
if( smWahacze[ i - 1 ] ) {
|
||||||
|
smWahacze[ i - 1 ]->WillBeAnimated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
parser.getTokens(); parser >> token;
|
parser.getTokens(); parser >> token;
|
||||||
if( token == "pendulumamplitude:" ) {
|
if( token == "pendulumamplitude:" ) {
|
||||||
@@ -5040,7 +5059,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
|
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
|
||||||
// ustalenie submodelu
|
// ustalenie submodelu
|
||||||
asAnimName = token + std::to_string(i + 1);
|
asAnimName = token + std::to_string(i + 1);
|
||||||
pAnimations[i + j].smAnimated = mdModel->GetFromName(asAnimName);
|
pAnimations[ i + j ].smAnimated = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
if (pAnimations[i + j].smAnimated)
|
if (pAnimations[i + j].smAnimated)
|
||||||
{ //++iAnimatedDoors;
|
{ //++iAnimatedDoors;
|
||||||
pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
|
pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
|
||||||
@@ -5082,7 +5101,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
|
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
|
||||||
// ustalenie submodelu
|
// ustalenie submodelu
|
||||||
asAnimName = token + std::to_string(i + 1);
|
asAnimName = token + std::to_string(i + 1);
|
||||||
pAnimations[i + j].smAnimated = mdModel->GetFromName(asAnimName);
|
pAnimations[i + j].smAnimated = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
if (pAnimations[i + j].smAnimated)
|
if (pAnimations[i + j].smAnimated)
|
||||||
{ //++iAnimatedDoors;
|
{ //++iAnimatedDoors;
|
||||||
pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
|
pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
|
||||||
@@ -5118,7 +5137,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
|
{ // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str*
|
||||||
// ustalenie submodelu
|
// ustalenie submodelu
|
||||||
asAnimName = token + std::to_string( i + 1 );
|
asAnimName = token + std::to_string( i + 1 );
|
||||||
pAnimations[ i + j ].smAnimated = mdModel->GetFromName( asAnimName );
|
pAnimations[ i + j ].smAnimated = GetSubmodelFromName( mdModel, asAnimName );
|
||||||
if( pAnimations[ i + j ].smAnimated ) {
|
if( pAnimations[ i + j ].smAnimated ) {
|
||||||
pAnimations[ i + j ].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
|
pAnimations[ i + j ].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu
|
||||||
// od razu zapinamy potrzebny typ animacji
|
// od razu zapinamy potrzebny typ animacji
|
||||||
@@ -5153,6 +5172,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
|||||||
parser.getTokens(); parser >> token;
|
parser.getTokens(); parser >> token;
|
||||||
if( token == "wheel_clatter:" ){
|
if( token == "wheel_clatter:" ){
|
||||||
// polozenia osi w/m srodka pojazdu
|
// polozenia osi w/m srodka pojazdu
|
||||||
|
double dSDist;
|
||||||
parser.getTokens( 1, false );
|
parser.getTokens( 1, false );
|
||||||
parser >> dSDist;
|
parser >> dSDist;
|
||||||
while( ( ( token = parser.getToken<std::string>() ) != "" )
|
while( ( ( token = parser.getToken<std::string>() ) != "" )
|
||||||
|
|||||||
@@ -326,12 +326,14 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
|
|||||||
m_material = -4;
|
m_material = -4;
|
||||||
iFlags |= (Opacity < 1.0) ? 8 : 0x10; // zmienna tekstura 4
|
iFlags |= (Opacity < 1.0) ? 8 : 0x10; // zmienna tekstura 4
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{ // jeśli tylko nazwa pliku, to dawać bieżącą ścieżkę do tekstur
|
|
||||||
Name_Material(material);
|
Name_Material(material);
|
||||||
|
/*
|
||||||
if( material.find_first_of( "/\\" ) == material.npos ) {
|
if( material.find_first_of( "/\\" ) == material.npos ) {
|
||||||
|
// jeśli tylko nazwa pliku, to dawać bieżącą ścieżkę do tekstur
|
||||||
material.insert( 0, Global.asCurrentTexturePath );
|
material.insert( 0, Global.asCurrentTexturePath );
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
m_material = GfxRenderer.Fetch_Material( material );
|
m_material = GfxRenderer.Fetch_Material( material );
|
||||||
// renderowanie w cyklu przezroczystych tylko jeśli:
|
// renderowanie w cyklu przezroczystych tylko jeśli:
|
||||||
// 1. Opacity=0 (przejściowo <1, czy tam <100) oraz
|
// 1. Opacity=0 (przejściowo <1, czy tam <100) oraz
|
||||||
@@ -1657,9 +1659,11 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
|||||||
auto const materialindex = static_cast<std::size_t>( iTexture );
|
auto const materialindex = static_cast<std::size_t>( iTexture );
|
||||||
if( materialindex < t->size() ) {
|
if( materialindex < t->size() ) {
|
||||||
m_materialname = t->at( materialindex );
|
m_materialname = t->at( materialindex );
|
||||||
|
/*
|
||||||
if( m_materialname.find_last_of( "/\\" ) == std::string::npos ) {
|
if( m_materialname.find_last_of( "/\\" ) == std::string::npos ) {
|
||||||
m_materialname = Global.asCurrentTexturePath + m_materialname;
|
m_materialname = Global.asCurrentTexturePath + m_materialname;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
m_material = GfxRenderer.Fetch_Material( m_materialname );
|
m_material = GfxRenderer.Fetch_Material( m_materialname );
|
||||||
if( ( iFlags & 0x30 ) == 0 ) {
|
if( ( iFlags & 0x30 ) == 0 ) {
|
||||||
// texture-alpha based fallback if for some reason we don't have opacity flag set yet
|
// texture-alpha based fallback if for some reason we don't have opacity flag set yet
|
||||||
|
|||||||
@@ -762,6 +762,10 @@ texture_manager::create( std::string Filename, bool const Loadnow ) {
|
|||||||
|
|
||||||
erase_extension( Filename );
|
erase_extension( Filename );
|
||||||
replace_slashes( Filename );
|
replace_slashes( Filename );
|
||||||
|
if( Filename[ 0 ] == '/' ) {
|
||||||
|
// filename can potentially begin with a slash, and we don't need it
|
||||||
|
Filename.erase( 0, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> extensions { { ".dds" }, { ".tga" }, { ".bmp" }, { ".ext" } };
|
std::vector<std::string> extensions { { ".dds" }, { ".tga" }, { ".bmp" }, { ".ext" } };
|
||||||
|
|
||||||
|
|||||||
31
Train.cpp
31
Train.cpp
@@ -752,7 +752,8 @@ void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data con
|
|||||||
|
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
// on press or hold
|
// on press or hold
|
||||||
if( Train->mvControlled->ShuntMode ) {
|
if( ( Train->mvControlled->EngineType == DieselElectric )
|
||||||
|
&& ( true == Train->mvControlled->ShuntMode ) ) {
|
||||||
Train->mvControlled->AnPos = clamp(
|
Train->mvControlled->AnPos = clamp(
|
||||||
Train->mvControlled->AnPos + 0.025,
|
Train->mvControlled->AnPos + 0.025,
|
||||||
0.0, 1.0 );
|
0.0, 1.0 );
|
||||||
@@ -767,7 +768,13 @@ void TTrain::OnCommand_secondcontrollerincreasefast( TTrain *Train, command_data
|
|||||||
|
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
// on press or hold
|
// on press or hold
|
||||||
Train->mvControlled->IncScndCtrl( 2 );
|
if( ( Train->mvControlled->EngineType == DieselElectric )
|
||||||
|
&& ( true == Train->mvControlled->ShuntMode ) ) {
|
||||||
|
Train->mvControlled->AnPos = 1.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Train->mvControlled->IncScndCtrl( 2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,12 +820,15 @@ void TTrain::OnCommand_secondcontrollerdecrease( TTrain *Train, command_data con
|
|||||||
|
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
// on press or hold
|
// on press or hold
|
||||||
if( Train->mvControlled->ShuntMode ) {
|
if( ( Train->mvControlled->EngineType == DieselElectric )
|
||||||
|
&& ( true == Train->mvControlled->ShuntMode ) ) {
|
||||||
Train->mvControlled->AnPos = clamp(
|
Train->mvControlled->AnPos = clamp(
|
||||||
Train->mvControlled->AnPos - 0.025,
|
Train->mvControlled->AnPos - 0.025,
|
||||||
0.0, 1.0 );
|
0.0, 1.0 );
|
||||||
}
|
}
|
||||||
Train->mvControlled->DecScndCtrl( 1 );
|
else {
|
||||||
|
Train->mvControlled->DecScndCtrl( 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,7 +836,13 @@ void TTrain::OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data
|
|||||||
|
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
// on press or hold
|
// on press or hold
|
||||||
Train->mvControlled->DecScndCtrl( 2 );
|
if( ( Train->mvControlled->EngineType == DieselElectric )
|
||||||
|
&& ( true == Train->mvControlled->ShuntMode ) ) {
|
||||||
|
Train->mvControlled->AnPos = 0.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Train->mvControlled->DecScndCtrl( 2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5970,6 +5986,11 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
// bieżąca sciezka do tekstur to dynamic/...
|
// bieżąca sciezka do tekstur to dynamic/...
|
||||||
Global.asCurrentTexturePath = DynamicObject->asBaseDir;
|
Global.asCurrentTexturePath = DynamicObject->asBaseDir;
|
||||||
// szukaj kabinę jako oddzielny model
|
// szukaj kabinę jako oddzielny model
|
||||||
|
// name can contain leading slash, erase it to avoid creation of double slashes when the name is combined with current directory
|
||||||
|
replace_slashes( token );
|
||||||
|
if( token[ 0 ] == '/' ) {
|
||||||
|
token.erase( 0, 1 );
|
||||||
|
}
|
||||||
TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true);
|
TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true);
|
||||||
// z powrotem defaultowa sciezka do tekstur
|
// z powrotem defaultowa sciezka do tekstur
|
||||||
Global.asCurrentTexturePath = szTexturePath;
|
Global.asCurrentTexturePath = szTexturePath;
|
||||||
|
|||||||
35
material.cpp
35
material.cpp
@@ -112,6 +112,10 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
|
|||||||
|
|
||||||
erase_extension( filename );
|
erase_extension( filename );
|
||||||
replace_slashes( filename );
|
replace_slashes( filename );
|
||||||
|
if( filename[ 0 ] == '/' ) {
|
||||||
|
// filename can potentially begin with a slash, and we don't need it
|
||||||
|
filename.erase( 0, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
filename += ".mat";
|
filename += ".mat";
|
||||||
|
|
||||||
@@ -122,7 +126,6 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
|
|||||||
}
|
}
|
||||||
// if this fails, try to look for it on disk
|
// if this fails, try to look for it on disk
|
||||||
opengl_material material;
|
opengl_material material;
|
||||||
material.name = filename;
|
|
||||||
auto const disklookup = find_on_disk( filename );
|
auto const disklookup = find_on_disk( filename );
|
||||||
if( disklookup != "" ) {
|
if( disklookup != "" ) {
|
||||||
cParser materialparser( disklookup, cParser::buffer_FILE );
|
cParser materialparser( disklookup, cParser::buffer_FILE );
|
||||||
@@ -130,6 +133,7 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
|
|||||||
// deserialization failed but the .mat file does exist, so we give up at this point
|
// deserialization failed but the .mat file does exist, so we give up at this point
|
||||||
return null_handle;
|
return null_handle;
|
||||||
}
|
}
|
||||||
|
material.name = disklookup;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// if there's no .mat file, this could be legacy method of referring just to diffuse texture directly, make a material out of it in such case
|
// if there's no .mat file, this could be legacy method of referring just to diffuse texture directly, make a material out of it in such case
|
||||||
@@ -138,6 +142,10 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
|
|||||||
// if there's also no texture, give up
|
// if there's also no texture, give up
|
||||||
return null_handle;
|
return null_handle;
|
||||||
}
|
}
|
||||||
|
// use texture path and name to tell the newly created materials apart
|
||||||
|
filename = GfxRenderer.Texture( material.texture1 ).name;
|
||||||
|
erase_extension( filename );
|
||||||
|
material.name = filename + ".mat";
|
||||||
material.has_alpha = GfxRenderer.Texture( material.texture1 ).has_alpha;
|
material.has_alpha = GfxRenderer.Texture( material.texture1 ).has_alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,21 +155,23 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
|
|||||||
return handle;
|
return handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
// checks whether specified texture is in the texture bank. returns texture id, or npos.
|
// checks whether specified material is in the material bank. returns handle to the material, or a null handle
|
||||||
material_handle
|
material_handle
|
||||||
material_manager::find_in_databank( std::string const &Materialname ) const {
|
material_manager::find_in_databank( std::string const &Materialname ) const {
|
||||||
|
|
||||||
auto lookup = m_materialmappings.find( Materialname );
|
std::vector<std::string> filenames {
|
||||||
if( lookup != m_materialmappings.end() ) {
|
Global.asCurrentTexturePath + Materialname,
|
||||||
return lookup->second;
|
Materialname,
|
||||||
}
|
szTexturePath + Materialname };
|
||||||
// jeszcze próba z dodatkową ścieżką
|
|
||||||
lookup = m_materialmappings.find( szTexturePath + Materialname );
|
|
||||||
|
|
||||||
return (
|
for( auto const &filename : filenames ) {
|
||||||
lookup != m_materialmappings.end() ?
|
auto const lookup { m_materialmappings.find( filename ) };
|
||||||
lookup->second :
|
if( lookup != m_materialmappings.end() ) {
|
||||||
null_handle );
|
return lookup->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks whether specified file exists.
|
// checks whether specified file exists.
|
||||||
@@ -170,6 +180,7 @@ std::string
|
|||||||
material_manager::find_on_disk( std::string const &Materialname ) const {
|
material_manager::find_on_disk( std::string const &Materialname ) const {
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
FileExists( Global.asCurrentTexturePath + Materialname ) ? Global.asCurrentTexturePath + Materialname :
|
||||||
FileExists( Materialname ) ? Materialname :
|
FileExists( Materialname ) ? Materialname :
|
||||||
FileExists( szTexturePath + Materialname ) ? szTexturePath + Materialname :
|
FileExists( szTexturePath + Materialname ) ? szTexturePath + Materialname :
|
||||||
"" );
|
"" );
|
||||||
|
|||||||
@@ -740,7 +740,7 @@ ui_layer::update() {
|
|||||||
"HamZ=" + to_string( vehicle->MoverParameters->fBrakeCtrlPos, 2 )
|
"HamZ=" + to_string( vehicle->MoverParameters->fBrakeCtrlPos, 2 )
|
||||||
+ "; HamP=" + std::to_string( vehicle->MoverParameters->LocalBrakePos ) + "/" + to_string( vehicle->MoverParameters->LocalBrakePosA, 2 )
|
+ "; HamP=" + std::to_string( vehicle->MoverParameters->LocalBrakePos ) + "/" + to_string( vehicle->MoverParameters->LocalBrakePosA, 2 )
|
||||||
+ "; NasJ=" + std::to_string( vehicle->MoverParameters->MainCtrlPos ) + "(" + std::to_string( vehicle->MoverParameters->MainCtrlActualPos ) + ")"
|
+ "; NasJ=" + std::to_string( vehicle->MoverParameters->MainCtrlPos ) + "(" + std::to_string( vehicle->MoverParameters->MainCtrlActualPos ) + ")"
|
||||||
+ ( vehicle->MoverParameters->ShuntMode ?
|
+ ( ( vehicle->MoverParameters->ShuntMode && vehicle->MoverParameters->EngineType == DieselElectric ) ?
|
||||||
"; NasB=" + to_string( vehicle->MoverParameters->AnPos, 2 ) :
|
"; NasB=" + to_string( vehicle->MoverParameters->AnPos, 2 ) :
|
||||||
"; NasB=" + std::to_string( vehicle->MoverParameters->ScndCtrlPos ) + "(" + std::to_string( vehicle->MoverParameters->ScndCtrlActualPos ) + ")" )
|
"; NasB=" + std::to_string( vehicle->MoverParameters->ScndCtrlPos ) + "(" + std::to_string( vehicle->MoverParameters->ScndCtrlActualPos ) + ")" )
|
||||||
+ "; I=" +
|
+ "; I=" +
|
||||||
|
|||||||
Reference in New Issue
Block a user