Merge branch 'main/gingo-test' into main/yubo-dev

main/yubo-dev
Nuno 3 years ago
commit 053620e3ac

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

@ -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;
};
/**

@ -2420,15 +2420,13 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
texture = "";
}
std::vector<string>texList;
if (!texture.empty())
splitString(texture, " ", texList);
for(uint j=0;j<instance.getNumMaterials();j++)
{
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
if (highlight)
{
instance.getMaterial(j).setAmbient(CRGBA(0,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++)
{
if (instance.getMaterial(j).isTextureFile((uint) l))
{
instance.getMaterial(j).setTextureFileName(texture, (uint) l);
}
instance.getMaterial(j).setTextureFileName(texList[std::min((int)j, (int)texList.size()-1)], (uint) l);
}
}
}

Loading…
Cancel
Save