ovis: allow setting material at sub-entity granularity

pull/2454/head
Pavel Rojtberg 5 years ago
parent 1d77931b30
commit 788b783631
  1. 3
      modules/ovis/include/opencv2/ovis.hpp
  2. 9
      modules/ovis/src/ovis.cpp

@ -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");
ent->setMaterial(mat);
if (subEntityIdx < 0)
ent->setMaterial(mat);
else
ent->getSubEntities()[subEntityIdx]->setMaterial(mat);
}
void setEntityProperty(const String& name, int prop, const Scalar& value) CV_OVERRIDE

Loading…
Cancel
Save