1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00
OpenMW/apps/opencs/view/render/lightingnight.cpp

40 lines
1.0 KiB
C++
Raw Normal View History

2014-03-26 17:59:42 +01:00
#include "lightingnight.hpp"
2015-03-28 21:26:16 +01:00
#include <osg/LightSource>
2014-03-26 17:59:42 +01:00
2015-03-28 21:26:16 +01:00
CSVRender::LightingNight::LightingNight() {}
2014-03-26 17:59:42 +01:00
void CSVRender::LightingNight::activate (osg::Group* rootNode, bool isExterior)
2014-03-26 17:59:42 +01:00
{
2015-03-28 21:26:16 +01:00
mRootNode = rootNode;
mLightSource = new osg::LightSource;
osg::ref_ptr<osg::Light> light (new osg::Light);
2015-05-20 02:07:18 +02:00
light->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f));
2015-03-28 21:26:16 +01:00
light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
light->setDiffuse(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f));
2015-03-28 21:26:16 +01:00
light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f));
light->setConstantAttenuation(1.f);
2014-03-26 17:59:42 +01:00
2015-03-28 21:26:16 +01:00
mLightSource->setLight(light);
2014-03-26 17:59:42 +01:00
2015-03-28 21:26:16 +01:00
mRootNode->addChild(mLightSource);
updateDayNightMode(isExterior ? 1 : 0);
2014-03-26 17:59:42 +01:00
}
void CSVRender::LightingNight::deactivate()
{
2015-03-28 21:26:16 +01:00
if (mRootNode && mLightSource.get())
mRootNode->removeChild(mLightSource);
2014-03-26 17:59:42 +01:00
}
2015-03-28 21:26:16 +01:00
osg::Vec4f CSVRender::LightingNight::getAmbientColour(osg::Vec4f *defaultAmbient)
2014-03-26 17:59:42 +01:00
{
2015-03-28 21:26:16 +01:00
if (defaultAmbient)
return *defaultAmbient;
else
return osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f);
2015-03-11 10:54:45 -04:00
}