Merge branch '54-improve-the-way-to-reskin-ryzhome-items-and-preview' into 'main/gingo-test'

Resolve "Improve the way to reskin ryzhome items and preview"

See merge request ryzom/ryzom-core!44
merge-requests/43/merge
Nuno Gonçalves (Ulukyn) 3 years ago
commit 9a24e7557f

@ -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<string> 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 // CInterface3DCamera
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

@ -265,11 +265,15 @@ public:
std::string getName() const; std::string getName() const;
void setName (const std::string &ht); void setName (const std::string &ht);
std::string getTextures() const;
void setTextures (const std::string &textures);
float getBBoxSizeX () const; float getBBoxSizeX () const;
float getBBoxSizeY () const; float getBBoxSizeY () const;
float getBBoxSizeZ () const; float getBBoxSizeZ () const;
REFLECT_EXPORT_START(CInterface3DShape, CInterfaceElement) REFLECT_EXPORT_START(CInterface3DShape, CInterfaceElement)
REFLECT_FLOAT("getBBoxSizeX", getBBoxSizeX, setPosX); REFLECT_FLOAT("getBBoxSizeX", getBBoxSizeX, setPosX);
REFLECT_FLOAT("getBBoxSizeY", getBBoxSizeY, setPosX); REFLECT_FLOAT("getBBoxSizeY", getBBoxSizeY, setPosX);
@ -281,6 +285,7 @@ public:
REFLECT_FLOAT ("roty", getRotY, setRotY); REFLECT_FLOAT ("roty", getRotY, setRotY);
REFLECT_FLOAT ("rotz", getRotZ, setRotZ); REFLECT_FLOAT ("rotz", getRotZ, setRotZ);
REFLECT_STRING ("name", getName, setName); REFLECT_STRING ("name", getName, setName);
REFLECT_STRING("textures", getTextures, setTextures);
REFLECT_EXPORT_END REFLECT_EXPORT_END
protected: protected:
@ -289,6 +294,7 @@ protected:
NLMISC::CVector _Pos; NLMISC::CVector _Pos;
NLMISC::CVector _Rot; NLMISC::CVector _Rot;
std::string _Name; std::string _Name;
std::string _Textures;
}; };
/** /**

@ -2420,15 +2420,13 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
texture = ""; texture = "";
} }
std::vector<string>texList;
if (!texture.empty())
splitString(texture, " ", texList);
for(uint j=0;j<instance.getNumMaterials();j++) for(uint j=0;j<instance.getNumMaterials();j++)
{ {
if (!highlight) if (highlight)
{
/*instance.getMaterial(j).setAmbient(CRGBA(0,0,0,255));
instance.getMaterial(j).setEmissive(CRGBA(255,255,255,255));
instance.getMaterial(j).setShininess(10.0f);*/
}
else
{ {
instance.getMaterial(j).setAmbient(CRGBA(0,0,0,255)); instance.getMaterial(j).setAmbient(CRGBA(0,0,0,255));
instance.getMaterial(j).setEmissive(CRGBA(255,0,0,255)); instance.getMaterial(j).setEmissive(CRGBA(255,0,0,255));
@ -2441,9 +2439,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
for(sint l = 0; l < numStages; l++) for(sint l = 0; l < numStages; l++)
{ {
if (instance.getMaterial(j).isTextureFile((uint) l)) if (instance.getMaterial(j).isTextureFile((uint) l))
{ instance.getMaterial(j).setTextureFileName(texList[std::min((int)j, (int)texList.size()-1)], (uint) l);
instance.getMaterial(j).setTextureFileName(texture, (uint) l);
}
} }
} }
} }

Loading…
Cancel
Save