OpenCS: lighting modes
parent
173887c2d9
commit
00deacc27e
@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
#include "lighting.hpp"
|
#include "lighting.hpp"
|
||||||
|
|
||||||
|
#include <osg/LightSource>
|
||||||
|
|
||||||
CSVRender::Lighting::~Lighting() {}
|
CSVRender::Lighting::~Lighting() {}
|
||||||
|
@ -1,30 +1,35 @@
|
|||||||
|
|
||||||
#include "lightingbright.hpp"
|
#include "lightingbright.hpp"
|
||||||
|
|
||||||
#include <OgreSceneManager.h>
|
#include <osg/LightSource>
|
||||||
|
|
||||||
#include <osgViewer/View>
|
CSVRender::LightingBright::LightingBright() {}
|
||||||
|
|
||||||
CSVRender::LightingBright::LightingBright() : mView(NULL) {}
|
void CSVRender::LightingBright::activate (osg::Group* rootNode)
|
||||||
|
|
||||||
void CSVRender::LightingBright::activate (osgViewer::View* view,
|
|
||||||
const osg::Vec4f* /*defaultAmbient*/)
|
|
||||||
{
|
{
|
||||||
mView = view;
|
mRootNode = rootNode;
|
||||||
|
|
||||||
// FIXME: ambient should be applied to LightModel instead of the light
|
mLightSource = (new osg::LightSource);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Light> light (new osg::Light);
|
osg::ref_ptr<osg::Light> light (new osg::Light);
|
||||||
light->setConstantAttenuation(1.f);
|
light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
|
||||||
light->setDirection(osg::Vec3f(0.f, 0.f, -1.f));
|
light->setDirection(osg::Vec3f(0.f, 0.f, -1.f));
|
||||||
light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
|
light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
|
||||||
light->setAmbient(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
|
light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f));
|
||||||
|
light->setConstantAttenuation(1.f);
|
||||||
|
|
||||||
mView->setLight(light);
|
mLightSource->setLight(light);
|
||||||
|
|
||||||
|
mRootNode->addChild(mLightSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingBright::deactivate()
|
void CSVRender::LightingBright::deactivate()
|
||||||
{
|
{
|
||||||
|
if (mRootNode && mLightSource.get())
|
||||||
|
mRootNode->removeChild(mLightSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingBright::setDefaultAmbient (const osg::Vec4f& colour) {}
|
osg::Vec4f CSVRender::LightingBright::getAmbientColour(osg::Vec4f* /*defaultAmbient*/)
|
||||||
|
{
|
||||||
|
return osg::Vec4f(1.f, 1.f, 1.f, 1.f);
|
||||||
|
}
|
||||||
|
@ -1,33 +1,36 @@
|
|||||||
#include "lightingday.hpp"
|
#include "lightingday.hpp"
|
||||||
|
|
||||||
#include <osgViewer/View>
|
#include <osg/LightSource>
|
||||||
|
|
||||||
CSVRender::LightingDay::LightingDay() : mView(NULL) {}
|
CSVRender::LightingDay::LightingDay(){}
|
||||||
|
|
||||||
void CSVRender::LightingDay::activate (osgViewer::View* view,
|
void CSVRender::LightingDay::activate (osg::Group* rootNode)
|
||||||
const osg::Vec4f *defaultAmbient)
|
|
||||||
{
|
{
|
||||||
mView = view;
|
mRootNode = rootNode;
|
||||||
|
|
||||||
|
mLightSource = new osg::LightSource;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Light> light (new osg::Light);
|
osg::ref_ptr<osg::Light> light (new osg::Light);
|
||||||
light->setDirection(osg::Vec3f(0.f, 0.f, -1.f));
|
light->setDirection(osg::Vec3f(0.f, 0.f, -1.f));
|
||||||
|
light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
|
||||||
light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
|
light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
|
||||||
|
light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f));
|
||||||
light->setConstantAttenuation(1.f);
|
light->setConstantAttenuation(1.f);
|
||||||
|
|
||||||
if (defaultAmbient)
|
mLightSource->setLight(light);
|
||||||
light->setAmbient(*defaultAmbient);
|
mRootNode->addChild(mLightSource);
|
||||||
else
|
|
||||||
light->setAmbient(osg::Vec4f(0.7f, 0.7f, 0.7f, 1.f));
|
|
||||||
|
|
||||||
mView->setLight(light);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingDay::deactivate()
|
void CSVRender::LightingDay::deactivate()
|
||||||
{
|
{
|
||||||
|
if (mRootNode && mLightSource.get())
|
||||||
|
mRootNode->removeChild(mLightSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingDay::setDefaultAmbient (const osg::Vec4f& colour)
|
osg::Vec4f CSVRender::LightingDay::getAmbientColour(osg::Vec4f *defaultAmbient)
|
||||||
{
|
{
|
||||||
if (mView)
|
if (defaultAmbient)
|
||||||
mView->getLight()->setAmbient(colour);
|
return *defaultAmbient;
|
||||||
|
else
|
||||||
|
return osg::Vec4f(0.7f, 0.7f, 0.7f, 1.f);
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,37 @@
|
|||||||
#include "lightingnight.hpp"
|
#include "lightingnight.hpp"
|
||||||
|
|
||||||
#include <osgViewer/View>
|
#include <osg/LightSource>
|
||||||
|
|
||||||
CSVRender::LightingNight::LightingNight() : mView(NULL) {}
|
CSVRender::LightingNight::LightingNight() {}
|
||||||
|
|
||||||
void CSVRender::LightingNight::activate (osgViewer::View* view,
|
void CSVRender::LightingNight::activate (osg::Group* rootNode)
|
||||||
const osg::Vec4f *defaultAmbient)
|
|
||||||
{
|
{
|
||||||
mView = view;
|
mRootNode = rootNode;
|
||||||
|
|
||||||
|
mLightSource = new osg::LightSource;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Light> light (new osg::Light);
|
osg::ref_ptr<osg::Light> light (new osg::Light);
|
||||||
light->setDirection(osg::Vec3f(0.f, 0.f, -1.f));
|
light->setDirection(osg::Vec3f(0.f, 0.f, -1.f));
|
||||||
|
light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f));
|
||||||
light->setDiffuse(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f));
|
light->setDiffuse(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f));
|
||||||
|
light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f));
|
||||||
light->setConstantAttenuation(1.f);
|
light->setConstantAttenuation(1.f);
|
||||||
|
|
||||||
if (defaultAmbient)
|
mLightSource->setLight(light);
|
||||||
light->setAmbient(*defaultAmbient);
|
|
||||||
else
|
|
||||||
light->setAmbient(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f));
|
|
||||||
|
|
||||||
mView->setLight(light);
|
mRootNode->addChild(mLightSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingNight::deactivate()
|
void CSVRender::LightingNight::deactivate()
|
||||||
{
|
{
|
||||||
|
if (mRootNode && mLightSource.get())
|
||||||
|
mRootNode->removeChild(mLightSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::LightingNight::setDefaultAmbient (const osg::Vec4f& colour)
|
osg::Vec4f CSVRender::LightingNight::getAmbientColour(osg::Vec4f *defaultAmbient)
|
||||||
{
|
{
|
||||||
if (mView)
|
if (defaultAmbient)
|
||||||
mView->getLight()->setAmbient(colour);
|
return *defaultAmbient;
|
||||||
|
else
|
||||||
|
return osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue