From a50da4f5de6d0f6669666dd261cbc702c1589f66 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 11 Nov 2014 15:52:08 +0100 Subject: [PATCH] Loading texturesfrom objects/ subdirectory Closes #381 --- data | 2 +- src/graphics/engine/modelmanager.cpp | 5 ++++- src/object/robotmain.cpp | 28 ++++++++++++++-------------- src/ui/window.cpp | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/data b/data index 2eaf58e7..44c56d29 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 2eaf58e7722a43bbb1d183d8ccf0f2fb0b52b500 +Subproject commit 44c56d29eeceb62d51ac5543cd47bec9746756f1 diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp index 218edd92..d875ca1a 100644 --- a/src/graphics/engine/modelmanager.cpp +++ b/src/graphics/engine/modelmanager.cpp @@ -70,6 +70,9 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored) for (int i = 0; i < static_cast( modelInfo.triangles.size() ); i++) { int state = modelInfo.triangles[i].state; + std::string tex1Name = "objects/"+modelInfo.triangles[i].tex1Name; + if(modelInfo.triangles[i].tex1Name.empty()) + tex1Name.clear(); std::string tex2Name = modelInfo.triangles[i].tex2Name; if (modelInfo.triangles[i].variableTex2) @@ -91,7 +94,7 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored) m_engine->AddBaseObjTriangles(modelInfo.baseObjRank, vs, ENG_TRIANGLE_TYPE_TRIANGLES, modelInfo.triangles[i].material, state, - modelInfo.triangles[i].tex1Name, tex2Name, + tex1Name, tex2Name, modelInfo.triangles[i].lodLevel, false); } diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 698329c2..ac55ef14 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4885,7 +4885,7 @@ void CRobotMain::ChangeColor() exclu[3] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom screen exclu[4] = Math::Point(0.0f, 0.0f); exclu[5] = Math::Point(0.0f, 0.0f); // terminator - m_engine->ChangeTextureColor("textures/human.png", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu); + m_engine->ChangeTextureColor("textures/objects/human.png", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu); float tolerance; @@ -4927,7 +4927,7 @@ void CRobotMain::ChangeColor() colorNew2.b = 0.0f; char name[100]; - sprintf(name, "textures/face%.2d.png", face+1); + sprintf(name, "textures/objects/face%.2d.png", face+1); exclu[0] = Math::Point(105.0f/256.0f, 47.0f/166.0f); exclu[1] = Math::Point(153.0f/256.0f, 79.0f/166.0f); // blue canister exclu[2] = Math::Point(0.0f, 0.0f); @@ -4941,19 +4941,19 @@ void CRobotMain::ChangeColor() colorNew2.g = 0.0f; colorNew2.b = 0.0f; - m_engine->ChangeTextureColor("textures/base1.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("textures/convert.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("textures/derrick.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("textures/factory.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("textures/lemt.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("textures/roller.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("textures/search.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/objects/base1.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/objects/convert.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/objects/derrick.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/objects/factory.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/objects/lemt.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/objects/roller.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/objects/search.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); exclu[0] = Math::Point( 0.0f/256.0f, 160.0f/256.0f); exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // pencils exclu[2] = Math::Point(0.0f, 0.0f); exclu[3] = Math::Point(0.0f, 0.0f); // terminator - m_engine->ChangeTextureColor("textures/drawer.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); + m_engine->ChangeTextureColor("textures/objects/drawer.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); exclu[0] = Math::Point(237.0f/256.0f, 176.0f/256.0f); exclu[1] = Math::Point(256.0f/256.0f, 220.0f/256.0f); // blue canister @@ -4961,16 +4961,16 @@ void CRobotMain::ChangeColor() exclu[3] = Math::Point(130.0f/256.0f, 214.0f/256.0f); // safe location exclu[4] = Math::Point(0.0f, 0.0f); exclu[5] = Math::Point(0.0f, 0.0f); // terminator - m_engine->ChangeTextureColor("textures/subm.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); + m_engine->ChangeTextureColor("textures/objects/subm.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); exclu[0] = Math::Point(128.0f/256.0f, 160.0f/256.0f); exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom exclu[2] = Math::Point(0.0f, 0.0f); exclu[3] = Math::Point(0.0f, 0.0f); // terminator - m_engine->ChangeTextureColor("textures/ant.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu); - m_engine->ChangeTextureColor("textures/mother.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); + m_engine->ChangeTextureColor("textures/objects/ant.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu); + m_engine->ChangeTextureColor("textures/objects/mother.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); - m_engine->ChangeTextureColor("textures/plant.png", m_colorRefGreen, m_colorNewGreen, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); + m_engine->ChangeTextureColor("textures/objects/plant.png", m_colorRefGreen, m_colorNewGreen, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); // PARTIPLOUF0 and PARTIDROP : ts = Math::Point(0.500f, 0.500f); diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 7b57a2fd..9468023d 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -1216,7 +1216,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon) dim.x += 100.0f/640.0f; dim.y += 60.0f/480.0f; - m_engine->SetTexture("textures/human.png"); + m_engine->SetTexture("textures/objects/human.png"); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 140.0f/256.0f; uv1.y = 32.0f/256.0f;