Commit 61b03565 authored by Pavel Rojtberg's avatar Pavel Rojtberg

ovis: allow manipulating entity material and scale at runtime

parent 7d1aca38
...@@ -38,6 +38,12 @@ enum MaterialProperty ...@@ -38,6 +38,12 @@ enum MaterialProperty
MATERIAL_TEXTURE MATERIAL_TEXTURE
}; };
enum EntityProperty
{
ENTITY_MATERIAL,
ENTITY_SCALE,
};
/** /**
* A 3D viewport and the associated scene * A 3D viewport and the associated scene
*/ */
...@@ -76,6 +82,17 @@ public: ...@@ -76,6 +82,17 @@ public:
*/ */
CV_WRAP virtual void removeEntity(const String& name) = 0; CV_WRAP virtual void removeEntity(const String& name) = 0;
/**
* set the property of an entity to the given value
* @param name entity name
* @param prop @ref EntityProperty
* @param value the value
*/
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;
/** /**
* convenience method to visualize a camera position * convenience method to visualize a camera position
* *
......
...@@ -427,6 +427,33 @@ public: ...@@ -427,6 +427,33 @@ public:
node.setPosition(t); node.setPosition(t);
} }
void setEntityProperty(const String& name, int prop, const String& value)
{
CV_Assert(prop == ENTITY_MATERIAL);
SceneNode& node = _getSceneNode(sceneMgr, name);
MaterialPtr mat = MaterialManager::getSingleton().getByName(value, RESOURCEGROUP_NAME);
CV_Assert(mat && "material not found");
Camera* cam = dynamic_cast<Camera*>(node.getAttachedObject(name));
if(cam)
{
cam->setMaterial(mat);
return;
}
Entity* ent = dynamic_cast<Entity*>(node.getAttachedObject(name));
CV_Assert(ent && "invalid entity");
ent->setMaterial(mat);
}
void setEntityProperty(const String& name, int prop, const Scalar& value)
{
CV_Assert(prop == ENTITY_SCALE);
SceneNode& node = _getSceneNode(sceneMgr, name);
node.setScale(value[0], value[1], value[2]);
}
void _createBackground() void _createBackground()
{ {
String name = "_" + sceneMgr->getName() + "_DefaultBackground"; 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