1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00
OpenMW/apps/opencs/view/render/lightingnight.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.0 KiB
C++
Raw Normal View History

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