Added: luaGetElement for CInterface3DScene and getBBoxSize* for CInterface3DShape

--HG--
branch : patches-from-atys
hg/hotfix/patches-from-atys
ulukyn 6 years ago
parent 892d11d2be
commit dcf959fe3d

@ -661,24 +661,25 @@ CInterfaceElement* CInterface3DScene::getElement (const string &id)
return this;
string sTmp = id.substr(0, getId().size());
if (sTmp != getId()) return NULL;
//if (sTmp != getId()) return NULL;
uint i;
for (i = 0; i < _Characters.size(); ++i)
if (id == _Characters[i]->getId())
if (id == _Characters[i]->getId() || id == toString("character#%d", i))
return _Characters[i];
for (i = 0; i < _IGs.size(); ++i)
if (id == _IGs[i]->getId())
return _IGs[i];
for (i = 0; i < _Shapes.size(); ++i)
if (id == _Shapes[i]->getId())
for (i = 0; i < _Shapes.size(); ++i) {
if (id == _Shapes[i]->getId() || id == toString("shape#%d", i))
return _Shapes[i];
}
for (i = 0; i < _Cameras.size(); ++i)
if (id == _Cameras[i]->getId())
if (id == _Cameras[i]->getId() || id == toString("camera#%d", i))
return _Cameras[i];
for (i = 0; i < _Lights.size(); ++i)
@ -691,6 +692,24 @@ CInterfaceElement* CInterface3DScene::getElement (const string &id)
return NULL;
}
int CInterface3DScene::luaGetElement(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "CInterfaceGroup::find", 1);
CLuaIHM::checkArgType(ls, "CInterfaceGroup::find", 1, LUA_TSTRING);
std::string id = ls.toString(1);
CInterfaceElement* element = getElement(id);
if (!element)
{
ls.pushNil();
}
else
{
CLuaIHM::pushUIOnStack(ls, element);
}
return 1;
}
// ----------------------------------------------------------------------------
string CInterface3DScene::getCurrentCamera() const
{
@ -1237,6 +1256,7 @@ CInterface3DShape::~CInterface3DShape()
// ----------------------------------------------------------------------------
bool CInterface3DShape::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
nlinfo("SHAPE ID PARENT = %s", parentGroup->getId().c_str());
if (!CInterfaceElement::parse(cur, parentGroup))
return false;
@ -1260,6 +1280,39 @@ bool CInterface3DShape::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
return true;
}
float CInterface3DShape::getBBoxSizeX () const
{
CAABBox bbox;
_Instance.getShapeAABBox(bbox);
if (bbox.getCenter() == CVector::Null)
return -0.5f;
return bbox.getMax().x - bbox.getMin().x;
}
float CInterface3DShape::getBBoxSizeY () const
{
CAABBox bbox;
_Instance.getShapeAABBox(bbox);
if (bbox.getCenter() == CVector::Null)
return -0.5f;
return bbox.getMax().y - bbox.getMin().y;
}
float CInterface3DShape::getBBoxSizeZ () const
{
CAABBox bbox;
_Instance.getShapeAABBox(bbox);
if (bbox.getCenter() == CVector::Null)
return -0.5f;
return bbox.getMax().z - bbox.getMin().z;
}
// ----------------------------------------------------------------------------
float CInterface3DShape::getPosX () const
{

@ -83,7 +83,10 @@ public:
float getDistLimitMax() const { return _DistLimitMax;}
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);
REFLECT_STRING ("curcs", getCurrentClusterSystem, setCurrentClusterSystem);
REFLECT_FLOAT ("rotzfactor", getRotFactor, setRotFactor);
@ -259,7 +262,15 @@ public:
std::string getName() const;
void setName (const std::string &ht);
float getBBoxSizeX () const;
float getBBoxSizeY () const;
float getBBoxSizeZ () const;
REFLECT_EXPORT_START(CInterface3DShape, CInterfaceElement)
REFLECT_FLOAT("getBBoxSizeX", getBBoxSizeX, setPosX);
REFLECT_FLOAT("getBBoxSizeY", getBBoxSizeY, setPosX);
REFLECT_FLOAT("getBBoxSizeZ", getBBoxSizeZ, setPosX);
REFLECT_FLOAT ("posx", getPosX, setPosX);
REFLECT_FLOAT ("posy", getPosY, setPosY);
REFLECT_FLOAT ("posz", getPosZ, setPosZ);

Loading…
Cancel
Save