2014-03-26 16:47:56 +00:00
|
|
|
#include "lightingday.hpp"
|
|
|
|
|
2015-03-28 20:26:16 +00:00
|
|
|
#include <osg/LightSource>
|
2014-03-26 16:47:56 +00:00
|
|
|
|
2015-03-28 20:26:16 +00:00
|
|
|
CSVRender::LightingDay::LightingDay(){}
|
2014-03-26 16:47:56 +00:00
|
|
|
|
2015-03-28 20:26:16 +00:00
|
|
|
void CSVRender::LightingDay::activate (osg::Group* rootNode)
|
2014-03-26 16:47:56 +00:00
|
|
|
{
|
2015-03-28 20:26:16 +00:00
|
|
|
mRootNode = rootNode;
|
|
|
|
|
|
|
|
mLightSource = new osg::LightSource;
|
2015-03-28 19:15:17 +00:00
|
|
|
|
|
|
|
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));
|
2015-03-28 19:15:17 +00:00
|
|
|
light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
|
2015-03-28 20:26:16 +00:00
|
|
|
light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f));
|
2015-03-28 19:15:17 +00:00
|
|
|
light->setConstantAttenuation(1.f);
|
2014-03-26 16:47:56 +00:00
|
|
|
|
2015-03-28 20:26:16 +00:00
|
|
|
mLightSource->setLight(light);
|
|
|
|
mRootNode->addChild(mLightSource);
|
2014-03-26 16:47:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSVRender::LightingDay::deactivate()
|
|
|
|
{
|
2015-03-28 20:26:16 +00:00
|
|
|
if (mRootNode && mLightSource.get())
|
|
|
|
mRootNode->removeChild(mLightSource);
|
2014-03-26 16:47:56 +00:00
|
|
|
}
|
|
|
|
|
2015-03-28 20:26:16 +00:00
|
|
|
osg::Vec4f CSVRender::LightingDay::getAmbientColour(osg::Vec4f *defaultAmbient)
|
2014-03-26 16:47:56 +00:00
|
|
|
{
|
2015-03-28 20:26:16 +00:00
|
|
|
if (defaultAmbient)
|
|
|
|
return *defaultAmbient;
|
|
|
|
else
|
|
|
|
return osg::Vec4f(0.7f, 0.7f, 0.7f, 1.f);
|
2015-03-11 14:54:45 +00:00
|
|
|
}
|