@@ -171,6 +171,14 @@ static SceneNode& _getSceneNode(SceneManager* sceneMgr, const String& name)
171
171
return *mo->getParentSceneNode ();
172
172
}
173
173
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
+
174
182
struct Application : public OgreBites ::ApplicationContext, public OgreBites::InputListener
175
183
{
176
184
Ptr<LogManager> logMgr;
@@ -508,10 +516,7 @@ class WindowSceneImpl : public WindowScene
508
516
{
509
517
// hide background plane
510
518
bgplane->setVisible (false );
511
-
512
- // BGRA as uchar
513
- ColourValue _color = ColourValue (color[2 ], color[1 ], color[0 ], color[3 ]) / 255 ;
514
- rWin->getViewport (0 )->setBackgroundColour (_color);
519
+ rWin->getViewport (0 )->setBackgroundColour (convertColor (color));
515
520
}
516
521
517
522
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
975
CV_Assert (mat);
971
976
972
977
Pass* rpass = mat->getTechniques ()[0 ]->getPasses ()[0 ];
973
- ColourValue col;
974
978
979
+ ColourValue col;
975
980
switch (prop)
976
981
{
977
982
case MATERIAL_POINT_SIZE:
@@ -984,10 +989,13 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
984
989
rpass->setSceneBlending (SBT_TRANSPARENT_ALPHA);
985
990
rpass->setDepthWriteEnabled (false );
986
991
break ;
992
+ case MATERIAL_DIFFUSE:
993
+ col = convertColor (val);
994
+ col.a = rpass->getDiffuse ().a ;
995
+ rpass->setDiffuse (col);
996
+ break ;
987
997
case MATERIAL_EMISSIVE:
988
- col = ColourValue (val[2 ], val[1 ], val[0 ]) / 255 ; // BGR as uchar
989
- col.saturate ();
990
- rpass->setEmissive (col);
998
+ rpass->setEmissive (convertColor (val));
991
999
break ;
992
1000
case MATERIAL_LINE_WIDTH:
993
1001
rpass->setLineWidth (val[0 ]);
0 commit comments