forked from teamnwah/openmw-tes3coop
added day lighting mode
This commit is contained in:
parent
d5506172e8
commit
fa29942b27
5 changed files with 80 additions and 11 deletions
|
@ -69,7 +69,7 @@ opencs_units (view/render
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/render
|
opencs_units_noqt (view/render
|
||||||
navigation navigation1st navigationfree navigationorbit lighting
|
navigation navigation1st navigationfree navigationorbit lighting lightingday
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/world
|
opencs_units_noqt (view/world
|
||||||
|
|
36
apps/opencs/view/render/lightingday.cpp
Normal file
36
apps/opencs/view/render/lightingday.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
#include "lightingday.hpp"
|
||||||
|
|
||||||
|
#include <OgreSceneManager.h>
|
||||||
|
|
||||||
|
CSVRender::LightingDay::LightingDay() : mSceneManager (0), mLight (0) {}
|
||||||
|
|
||||||
|
void CSVRender::LightingDay::activate (Ogre::SceneManager *sceneManager,
|
||||||
|
const Ogre::ColourValue *defaultAmbient)
|
||||||
|
{
|
||||||
|
mSceneManager = sceneManager;
|
||||||
|
|
||||||
|
if (defaultAmbient)
|
||||||
|
mSceneManager->setAmbientLight (*defaultAmbient);
|
||||||
|
else
|
||||||
|
mSceneManager->setAmbientLight (Ogre::ColourValue (0.7, 0.7, 0.7, 1));
|
||||||
|
|
||||||
|
mLight = mSceneManager->createLight();
|
||||||
|
mLight->setType (Ogre::Light::LT_DIRECTIONAL);
|
||||||
|
mLight->setDirection (Ogre::Vector3 (0, 0, -1));
|
||||||
|
mLight->setDiffuseColour (Ogre::ColourValue (1, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::LightingDay::deactivate()
|
||||||
|
{
|
||||||
|
if (mLight)
|
||||||
|
{
|
||||||
|
mSceneManager->destroyLight (mLight);
|
||||||
|
mLight = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::LightingDay::setDefaultAmbient (const Ogre::ColourValue& colour)
|
||||||
|
{
|
||||||
|
mSceneManager->setAmbientLight (colour);
|
||||||
|
}
|
31
apps/opencs/view/render/lightingday.hpp
Normal file
31
apps/opencs/view/render/lightingday.hpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef OPENCS_VIEW_LIGHTING_DAY_H
|
||||||
|
#define OPENCS_VIEW_LIGHTING_DAY_H
|
||||||
|
|
||||||
|
#include "lighting.hpp"
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Light;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class LightingDay : public Lighting
|
||||||
|
{
|
||||||
|
Ogre::SceneManager *mSceneManager;
|
||||||
|
Ogre::Light *mLight;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
LightingDay();
|
||||||
|
|
||||||
|
virtual void activate (Ogre::SceneManager *sceneManager,
|
||||||
|
const Ogre::ColourValue *defaultAmbient = 0);
|
||||||
|
|
||||||
|
virtual void deactivate();
|
||||||
|
|
||||||
|
virtual void setDefaultAmbient (const Ogre::ColourValue& colour);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -38,19 +38,16 @@ namespace CSVRender
|
||||||
|
|
||||||
mSceneMgr->setAmbientLight (Ogre::ColourValue (0,0,0,1));
|
mSceneMgr->setAmbientLight (Ogre::ColourValue (0,0,0,1));
|
||||||
|
|
||||||
Ogre::Light* l = mSceneMgr->createLight();
|
|
||||||
l->setType (Ogre::Light::LT_DIRECTIONAL);
|
|
||||||
l->setDirection (Ogre::Vector3(-0.4, -0.7, 0.3));
|
|
||||||
l->setDiffuseColour (Ogre::ColourValue(0.7,0.7,0.7));
|
|
||||||
|
|
||||||
mCamera = mSceneMgr->createCamera("foo");
|
mCamera = mSceneMgr->createCamera("foo");
|
||||||
|
|
||||||
mCamera->setPosition(300,0,000);
|
mCamera->setPosition (300, 0, 0);
|
||||||
mCamera->lookAt(0,0,0);
|
mCamera->lookAt (0, 0, 0);
|
||||||
mCamera->setNearClipDistance(0.1);
|
mCamera->setNearClipDistance (0.1);
|
||||||
mCamera->setFarClipDistance(30000);
|
mCamera->setFarClipDistance (30000);
|
||||||
mCamera->roll (Ogre::Degree (90));
|
mCamera->roll (Ogre::Degree (90));
|
||||||
|
|
||||||
|
setLighting (&mLightingDay);
|
||||||
|
|
||||||
QTimer *timer = new QTimer (this);
|
QTimer *timer = new QTimer (this);
|
||||||
|
|
||||||
connect (timer, SIGNAL (timeout()), this, SLOT (update()));
|
connect (timer, SIGNAL (timeout()), this, SLOT (update()));
|
||||||
|
@ -341,11 +338,13 @@ namespace CSVRender
|
||||||
mLighting->deactivate();
|
mLighting->deactivate();
|
||||||
|
|
||||||
mLighting = lighting;
|
mLighting = lighting;
|
||||||
mLighting->activate (mSceneManager, mHasDefaultAmbient ? &mDefaultAmbient : 0);
|
mLighting->activate (mSceneMgr, mHasDefaultAmbient ? &mDefaultAmbient : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneWidget::selectLightingMode (const std::string& mode)
|
void SceneWidget::selectLightingMode (const std::string& mode)
|
||||||
{
|
{
|
||||||
|
if (mode=="day")
|
||||||
|
setLighting (&mLightingDay);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include <OgreColourValue.h>
|
#include <OgreColourValue.h>
|
||||||
|
|
||||||
|
#include "lightingday.hpp"
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
class Camera;
|
class Camera;
|
||||||
|
@ -96,6 +98,7 @@ namespace CSVRender
|
||||||
int mFastFactor;
|
int mFastFactor;
|
||||||
Ogre::ColourValue mDefaultAmbient;
|
Ogre::ColourValue mDefaultAmbient;
|
||||||
bool mHasDefaultAmbient;
|
bool mHasDefaultAmbient;
|
||||||
|
LightingDay mLightingDay;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue