Skip to content

Commit 3ae0e12

Browse files
committed
Merge pull request #2364 from paroj:ovisup
2 parents c9514b8 + 8f2b705 commit 3ae0e12

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

modules/ovis/include/opencv2/ovis.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum MaterialProperty
3636
MATERIAL_LINE_WIDTH,
3737
MATERIAL_OPACITY,
3838
MATERIAL_EMISSIVE,
39+
MATERIAL_DIFFUSE,
3940
MATERIAL_TEXTURE0,
4041
MATERIAL_TEXTURE = MATERIAL_TEXTURE0,
4142
MATERIAL_TEXTURE1,

modules/ovis/src/ovis.cpp

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ static SceneNode& _getSceneNode(SceneManager* sceneMgr, const String& name)
171171
return *mo->getParentSceneNode();
172172
}
173173

174+
static ColourValue convertColor(const Scalar& val)
175+
{
176+
// BGR 0..255 (uchar) to RGB 0..1
177+
ColourValue ret = ColourValue(val[2], val[1], val[0]) / 255;
178+
ret.saturate();
179+
return ret;
180+
}
181+
174182
struct Application : public OgreBites::ApplicationContext, public OgreBites::InputListener
175183
{
176184
Ptr<LogManager> logMgr;
@@ -335,11 +343,7 @@ class WindowSceneImpl : public WindowScene
335343
{
336344
camman.reset(new OgreBites::CameraMan(camNode));
337345
camman->setStyle(OgreBites::CS_ORBIT);
338-
#if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5)
339346
camman->setFixedYaw(false);
340-
#else
341-
camNode->setFixedYawAxis(true, Vector3::NEGATIVE_UNIT_Y); // OpenCV +Y in Ogre CS
342-
#endif
343347
}
344348

345349
if (!app->sceneMgr)
@@ -512,10 +516,7 @@ class WindowSceneImpl : public WindowScene
512516
{
513517
// hide background plane
514518
bgplane->setVisible(false);
515-
516-
// BGRA as uchar
517-
ColourValue _color = ColourValue(color[2], color[1], color[0], color[3]) / 255;
518-
rWin->getViewport(0)->setBackgroundColour(_color);
519+
rWin->getViewport(0)->setBackgroundColour(convertColor(color));
519520
}
520521

521522
void createEntity(const String& name, const String& meshname, InputArray tvec, InputArray rot) CV_OVERRIDE
@@ -579,7 +580,6 @@ class WindowSceneImpl : public WindowScene
579580
const Scalar& specularColour) CV_OVERRIDE
580581
{
581582
Light* light = sceneMgr->createLight(name);
582-
light->setDirection(Vector3::NEGATIVE_UNIT_Z);
583583
// convert to BGR
584584
light->setDiffuseColour(ColourValue(diffuseColour[2], diffuseColour[1], diffuseColour[0]));
585585
light->setSpecularColour(ColourValue(specularColour[2], specularColour[1], specularColour[0]));
@@ -838,9 +838,7 @@ class WindowSceneImpl : public WindowScene
838838

839839
void fixCameraYawAxis(bool useFixed, InputArray _up) CV_OVERRIDE
840840
{
841-
#if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5)
842841
if(camman) camman->setFixedYaw(useFixed);
843-
#endif
844842

845843
Vector3 up = Vector3::NEGATIVE_UNIT_Y;
846844
if (!_up.empty())
@@ -977,8 +975,8 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
977975
CV_Assert(mat);
978976

979977
Pass* rpass = mat->getTechniques()[0]->getPasses()[0];
980-
ColourValue col;
981978

979+
ColourValue col;
982980
switch (prop)
983981
{
984982
case MATERIAL_POINT_SIZE:
@@ -991,17 +989,16 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
991989
rpass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
992990
rpass->setDepthWriteEnabled(false);
993991
break;
992+
case MATERIAL_DIFFUSE:
993+
col = convertColor(val);
994+
col.a = rpass->getDiffuse().a;
995+
rpass->setDiffuse(col);
996+
break;
994997
case MATERIAL_EMISSIVE:
995-
col = ColourValue(val[2], val[1], val[0]) / 255; // BGR as uchar
996-
col.saturate();
997-
rpass->setEmissive(col);
998+
rpass->setEmissive(convertColor(val));
998999
break;
9991000
case MATERIAL_LINE_WIDTH:
1000-
#if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 2)
10011001
rpass->setLineWidth(val[0]);
1002-
#else
1003-
CV_Error(Error::StsError, "needs OGRE 1.11.2+ for this");
1004-
#endif
10051002
break;
10061003
default:
10071004
CV_Error(Error::StsBadArg, "invalid or non Scalar property");

0 commit comments

Comments
 (0)