forked from mirror/openmw-tes3mp
Colour conversion utility
This commit is contained in:
parent
e6cf959134
commit
b0ea51a5c8
3 changed files with 25 additions and 4 deletions
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
#include <components/sceneutil/util.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
#include "../../model/world/data.hpp"
|
||||
|
@ -23,10 +25,7 @@ void CSVRender::UnpagedWorldspaceWidget::update()
|
|||
const CSMWorld::Record<CSMWorld::Cell>& record =
|
||||
dynamic_cast<const CSMWorld::Record<CSMWorld::Cell>&> (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);
|
||||
|
||||
|
|
|
@ -33,4 +33,21 @@ void transformBoundingSphere (const osg::Matrix& matrix, osg::BoundingSphere& bs
|
|||
if (bsphere._radius<len_zdash) bsphere._radius = len_zdash;
|
||||
}
|
||||
|
||||
osg::Vec4f colourFromRGB(unsigned int clr)
|
||||
{
|
||||
osg::Vec4f colour(((clr >> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <osg/Matrix>
|
||||
#include <osg/BoundingSphere>
|
||||
#include <osg/Vec4f>
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue