Commit 8f2b705d authored by Pavel Rojtberg's avatar Pavel Rojtberg

ovis: implement setting diffuse color

parent 8a8d609a
...@@ -36,6 +36,7 @@ enum MaterialProperty ...@@ -36,6 +36,7 @@ enum MaterialProperty
MATERIAL_LINE_WIDTH, MATERIAL_LINE_WIDTH,
MATERIAL_OPACITY, MATERIAL_OPACITY,
MATERIAL_EMISSIVE, MATERIAL_EMISSIVE,
MATERIAL_DIFFUSE,
MATERIAL_TEXTURE0, MATERIAL_TEXTURE0,
MATERIAL_TEXTURE = MATERIAL_TEXTURE0, MATERIAL_TEXTURE = MATERIAL_TEXTURE0,
MATERIAL_TEXTURE1, MATERIAL_TEXTURE1,
......
...@@ -171,6 +171,14 @@ static SceneNode& _getSceneNode(SceneManager* sceneMgr, const String& name) ...@@ -171,6 +171,14 @@ static SceneNode& _getSceneNode(SceneManager* sceneMgr, const String& name)
return *mo->getParentSceneNode(); return *mo->getParentSceneNode();
} }
static ColourValue convertColor(const Scalar& val)
{
// BGR 0..255 (uchar) to RGB 0..1
ColourValue ret = ColourValue(val[2], val[1], val[0]) / 255;
ret.saturate();
return ret;
}
struct Application : public OgreBites::ApplicationContext, public OgreBites::InputListener struct Application : public OgreBites::ApplicationContext, public OgreBites::InputListener
{ {
Ptr<LogManager> logMgr; Ptr<LogManager> logMgr;
...@@ -508,10 +516,7 @@ public: ...@@ -508,10 +516,7 @@ public:
{ {
// hide background plane // hide background plane
bgplane->setVisible(false); bgplane->setVisible(false);
rWin->getViewport(0)->setBackgroundColour(convertColor(color));
// BGRA as uchar
ColourValue _color = ColourValue(color[2], color[1], color[0], color[3]) / 255;
rWin->getViewport(0)->setBackgroundColour(_color);
} }
void createEntity(const String& name, const String& meshname, InputArray tvec, InputArray rot) CV_OVERRIDE void createEntity(const String& name, const String& meshname, InputArray tvec, InputArray rot) CV_OVERRIDE
...@@ -970,8 +975,8 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val) ...@@ -970,8 +975,8 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
CV_Assert(mat); CV_Assert(mat);
Pass* rpass = mat->getTechniques()[0]->getPasses()[0]; Pass* rpass = mat->getTechniques()[0]->getPasses()[0];
ColourValue col;
ColourValue col;
switch (prop) switch (prop)
{ {
case MATERIAL_POINT_SIZE: case MATERIAL_POINT_SIZE:
...@@ -984,10 +989,13 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val) ...@@ -984,10 +989,13 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
rpass->setSceneBlending(SBT_TRANSPARENT_ALPHA); rpass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
rpass->setDepthWriteEnabled(false); rpass->setDepthWriteEnabled(false);
break; break;
case MATERIAL_DIFFUSE:
col = convertColor(val);
col.a = rpass->getDiffuse().a;
rpass->setDiffuse(col);
break;
case MATERIAL_EMISSIVE: case MATERIAL_EMISSIVE:
col = ColourValue(val[2], val[1], val[0]) / 255; // BGR as uchar rpass->setEmissive(convertColor(val));
col.saturate();
rpass->setEmissive(col);
break; break;
case MATERIAL_LINE_WIDTH: case MATERIAL_LINE_WIDTH:
rpass->setLineWidth(val[0]); rpass->setLineWidth(val[0]);
......
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