From 8708fd74c616fcdd144687b80a14f35d9c48cb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Gon=C3=A7alves=20=28Ulukyn=29?= Date: Wed, 2 Feb 2022 15:58:28 +0000 Subject: [PATCH] Resolve "Improve the way to reskin ryzhome items and preview" --- .../src/interface_v3/interface_3d_scene.cpp | 36 ++++++++++++++++--- .../src/interface_v3/interface_3d_scene.h | 8 ++++- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 16 ++++----- 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/ryzom/client/src/interface_v3/interface_3d_scene.cpp index cd2160489..dacb9a37a 100644 --- a/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -713,7 +713,7 @@ int CInterface3DScene::luaGetElement(CLuaState &ls) } return 1; } - + // ---------------------------------------------------------------------------- string CInterface3DScene::getCurrentCamera() const { @@ -1288,7 +1288,7 @@ float CInterface3DShape::getBBoxSizeX () const { CAABBox bbox; _Instance.getShapeAABBox(bbox); - + if (bbox.getCenter() == CVector::Null) return -0.5f; @@ -1299,7 +1299,7 @@ float CInterface3DShape::getBBoxSizeY () const { CAABBox bbox; _Instance.getShapeAABBox(bbox); - + if (bbox.getCenter() == CVector::Null) return -0.5f; @@ -1310,7 +1310,7 @@ float CInterface3DShape::getBBoxSizeZ () const { CAABBox bbox; _Instance.getShapeAABBox(bbox); - + if (bbox.getCenter() == CVector::Null) return -0.5f; @@ -1437,6 +1437,34 @@ void CInterface3DShape::setName (const std::string &ht) } } +std::string CInterface3DShape::getTextures() const +{ + return _Textures; +} + + +void CInterface3DShape::setTextures(const std::string &textures) +{ + if (textures.empty()) + return; + + _Textures = textures; + vector texList; + splitString(textures, " ", texList); + + for(uint j=0;j<_Instance.getNumMaterials();j++) + { + sint numStages = _Instance.getMaterial(j).getLastTextureStage() + 1; + for(sint l = 0; l < numStages; l++) + { + if (_Instance.getMaterial(j).isTextureFile((uint) l)) + { + _Instance.getMaterial(j).setTextureFileName(texList[std::min((int)j, (int)texList.size()-1)], (uint) l); + } + } + } +} + // ---------------------------------------------------------------------------- // CInterface3DCamera // ---------------------------------------------------------------------------- diff --git a/ryzom/client/src/interface_v3/interface_3d_scene.h b/ryzom/client/src/interface_v3/interface_3d_scene.h index 89355e6df..7db17ae85 100644 --- a/ryzom/client/src/interface_v3/interface_3d_scene.h +++ b/ryzom/client/src/interface_v3/interface_3d_scene.h @@ -87,7 +87,7 @@ public: void setDistLimitMax(float limitMax) { _DistLimitMax = limitMax;} int luaGetElement(CLuaState &ls); - + REFLECT_EXPORT_START(CInterface3DScene, CInterfaceGroup) REFLECT_LUA_METHOD ("getElement", luaGetElement); REFLECT_STRING ("curcam", getCurrentCamera, setCurrentCamera); @@ -265,11 +265,15 @@ public: std::string getName() const; void setName (const std::string &ht); + std::string getTextures() const; + void setTextures (const std::string &textures); + float getBBoxSizeX () const; float getBBoxSizeY () const; float getBBoxSizeZ () const; + REFLECT_EXPORT_START(CInterface3DShape, CInterfaceElement) REFLECT_FLOAT("getBBoxSizeX", getBBoxSizeX, setPosX); REFLECT_FLOAT("getBBoxSizeY", getBBoxSizeY, setPosX); @@ -281,6 +285,7 @@ public: REFLECT_FLOAT ("roty", getRotY, setRotY); REFLECT_FLOAT ("rotz", getRotZ, setRotZ); REFLECT_STRING ("name", getName, setName); + REFLECT_STRING("textures", getTextures, setTextures); REFLECT_EXPORT_END protected: @@ -289,6 +294,7 @@ protected: NLMISC::CVector _Pos; NLMISC::CVector _Rot; std::string _Name; + std::string _Textures; }; /** diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 09a096fd8..ca72dc359 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -2420,15 +2420,13 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) texture = ""; } + std::vectortexList; + if (!texture.empty()) + splitString(texture, " ", texList); + for(uint j=0;j