Commit cd7a6eaf authored by Pavel Rojtberg's avatar Pavel Rojtberg

ovis: add ENTITY_AABB_WORLD property and implement getEntityProperty

parent 31dff1e0
......@@ -45,6 +45,7 @@ enum EntityProperty
{
ENTITY_MATERIAL,
ENTITY_SCALE,
ENTITY_AABB_WORLD
};
/**
......@@ -106,6 +107,14 @@ public:
/// @overload
CV_WRAP virtual void setEntityProperty(const String& name, int prop, const String& value) = 0;
/**
* get the property of an entity
* @param name entity name
* @param prop @ref EntityProperty
* @param value the value
*/
CV_WRAP virtual void getEntityProperty(const String& name, int prop, OutputArray value) = 0;
/**
* convenience method to visualize a camera position
*
......
......@@ -563,6 +563,35 @@ public:
node.setScale(value[0], value[1], value[2]);
}
void getEntityProperty(const String& name, int prop, OutputArray value)
{
SceneNode& node = _getSceneNode(sceneMgr, name);
switch(prop)
{
case ENTITY_SCALE:
{
Vector3 s = node.getScale();
Mat_<Real>(1, 3, s.ptr()).copyTo(value);
return;
}
case ENTITY_AABB_WORLD:
{
Entity* ent = dynamic_cast<Entity*>(node.getAttachedObject(name));
CV_Assert(ent && "invalid entity");
AxisAlignedBox aabb = ent->getWorldBoundingBox(true);
Vector3 mn = aabb.getMinimum();
Vector3 mx = aabb.getMaximum();
Mat_<Real> ret(2, 3);
Mat_<Real>(1, 3, mn.ptr()).copyTo(ret.row(0));
Mat_<Real>(1, 3, mx.ptr()).copyTo(ret.row(1));
ret.copyTo(value);
return;
}
default:
CV_Error(Error::StsBadArg, "unsupported property");
}
}
void _createBackground()
{
String name = "_" + sceneMgr->getName() + "_DefaultBackground";
......
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