Commit 788b7836 authored by Pavel Rojtberg's avatar Pavel Rojtberg

ovis: allow setting material at sub-entity granularity

parent 1d77931b
......@@ -109,7 +109,8 @@ public:
CV_WRAP virtual void setEntityProperty(const String& name, int prop, const Scalar& value) = 0;
/// @overload
CV_WRAP virtual void setEntityProperty(const String& name, int prop, const String& value) = 0;
CV_WRAP virtual void setEntityProperty(const String& name, int prop, const String& value,
int subEntityIdx = -1) = 0;
/**
* get the property of an entity
......
......@@ -687,7 +687,7 @@ public:
frameCtrlrs.erase(animstate);
}
void setEntityProperty(const String& name, int prop, const String& value) CV_OVERRIDE
void setEntityProperty(const String& name, int prop, const String& value, int subEntityIdx) CV_OVERRIDE
{
CV_Assert(prop == ENTITY_MATERIAL);
SceneNode& node = _getSceneNode(sceneMgr, name);
......@@ -698,13 +698,18 @@ public:
Camera* cam = dynamic_cast<Camera*>(node.getAttachedObject(name));
if(cam)
{
CV_Assert(subEntityIdx == -1 && "Camera Entities do not have SubEntities");
cam->setMaterial(mat);
return;
}
Entity* ent = dynamic_cast<Entity*>(node.getAttachedObject(name));
CV_Assert(ent && "invalid entity");
if (subEntityIdx < 0)
ent->setMaterial(mat);
else
ent->getSubEntities()[subEntityIdx]->setMaterial(mat);
}
void setEntityProperty(const String& name, int prop, const Scalar& value) CV_OVERRIDE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment