diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index a6d18a0f2..dec7d493e 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -7,6 +7,8 @@ #include +#include + #include "../../model/doc/document.hpp" #include "../../model/world/data.hpp" @@ -23,10 +25,7 @@ void CSVRender::UnpagedWorldspaceWidget::update() const CSMWorld::Record& record = dynamic_cast&> (mCellsModel->getRecord (mCellId)); - ESM::Color clr = record.get().mAmbi.mAmbient; - osg::Vec4f colour(((clr >> 0) & 0xFF) / 255.0f, - ((clr >> 8) & 0xFF) / 255.0f, - ((clr >> 16) & 0xFF) / 255.0f, 1.f); + osg::Vec4f colour = SceneUtil::colourFromRGB(record.get().mAmbi.mAmbient); setDefaultAmbient (colour); diff --git a/components/sceneutil/util.cpp b/components/sceneutil/util.cpp index 0d99e762d..a41c6b74b 100644 --- a/components/sceneutil/util.cpp +++ b/components/sceneutil/util.cpp @@ -33,4 +33,21 @@ void transformBoundingSphere (const osg::Matrix& matrix, osg::BoundingSphere& bs if (bsphere._radius> 0) & 0xFF) / 255.0f, + ((clr >> 8) & 0xFF) / 255.0f, + ((clr >> 16) & 0xFF) / 255.0f, 1.f); + return colour; +} + +osg::Vec4f colourFromRGBA(unsigned int clr) +{ + osg::Vec4f colour(((clr >> 0) & 0xFF) / 255.0f, + ((clr >> 8) & 0xFF) / 255.0f, + ((clr >> 16) & 0xFF) / 255.0f, + ((clr >> 24) & 0xFF) / 255.0f); + return colour; +} + } diff --git a/components/sceneutil/util.hpp b/components/sceneutil/util.hpp index a8d970df1..c99771c5e 100644 --- a/components/sceneutil/util.hpp +++ b/components/sceneutil/util.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace SceneUtil { @@ -12,6 +13,10 @@ namespace SceneUtil // TODO: patch osg to make public void transformBoundingSphere (const osg::Matrix& matrix, osg::BoundingSphere& bsphere); + osg::Vec4f colourFromRGB (unsigned int clr); + + osg::Vec4f colourFromRGBA (unsigned int clr); + } #endif