Adding light and fog functions

actorid
Jason Hooks 13 years ago
parent edf85b26f9
commit e041006063

@ -154,4 +154,71 @@ bool RenderingManager::toggleRenderMode(int mode){
return mDebugging.toggleRenderMode(mode);
}
void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell)
{
Ogre::ColourValue color;
color.setAsABGR (mCell.cell->ambi.fog);
float high = 4500 + 9000 * (1-mCell.cell->ambi.fogDensity);
float low = 200;
rend.getScene()->setFog (FOG_LINEAR, color, 0, low, high);
rend.getCamera()->setFarClipDistance (high + 10);
rend.getViewport()->setBackgroundColour (color);
}
void RenderingManager::setAmbientMode()
{
switch (mAmbientMode)
{
case 0:
rend.getScene()->setAmbientLight(mAmbientColor);
break;
case 1:
rend.getScene()->setAmbientLight(0.7f*mAmbientColor + 0.3f*ColourValue(1,1,1));
break;
case 2:
rend.getScene()->setAmbientLight(ColourValue(1,1,1));
break;
}
}
void RenderingManager::configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell)
{
mAmbientColor.setAsABGR (mCell.cell->ambi.ambient);
setAmbientMode();
// Create a "sun" that shines light downwards. It doesn't look
// completely right, but leave it for now.
Ogre::Light *light = rend.getScene()->createLight();
Ogre::ColourValue colour;
colour.setAsABGR (mCell.cell->ambi.sunlight);
light->setDiffuseColour (colour);
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(0,-1,0);
}
// Switch through lighting modes.
void RenderingManager::toggleLight()
{
if (mAmbientMode==2)
mAmbientMode = 0;
else
++mAmbientMode;
switch (mAmbientMode)
{
case 0: std::cout << "Setting lights to normal\n"; break;
case 1: std::cout << "Turning the lights up\n"; break;
case 2: std::cout << "Turning the lights to full\n"; break;
}
setAmbientMode();
}
}

@ -57,6 +57,8 @@ class RenderingManager: private RenderingInterface {
virtual MWRender::Creatures& getCreatures();
virtual MWRender::Objects& getObjects();
virtual MWRender::Player& getPlayer();
void toggleLight();
bool toggleRenderMode(int mode);
void removeCell (MWWorld::Ptr::CellStore *store); // TODO do we want this?
@ -86,7 +88,10 @@ class RenderingManager: private RenderingInterface {
Ogre::SceneNode *getRoot() { return mwRoot; }
private:
void configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell);
/// configure fog according to cell
void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
void setAmbientMode();
SkyManager* mSkyManager;
OEngine::Render::OgreRenderer &rend;
Ogre::Camera* camera;
@ -94,6 +99,11 @@ class RenderingManager: private RenderingInterface {
MWRender::Creatures creatures;
MWRender::Objects objects;
// 0 normal, 1 more bright, 2 max
int mAmbientMode;
Ogre::ColourValue mAmbientColor;
/// Root node for all objects added to the scene. This is rotated so
/// that the OGRE coordinate system matches that used internally in
/// Morrowind.

Loading…
Cancel
Save