mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:26:40 +00:00 
			
		
		
		
	fog
This commit is contained in:
		
							parent
							
								
									528cff5a59
								
							
						
					
					
						commit
						f79bf1f300
					
				
					 5 changed files with 28 additions and 9 deletions
				
			
		| 
						 | 
					@ -204,14 +204,22 @@ void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell)
 | 
				
			||||||
  Ogre::ColourValue color;
 | 
					  Ogre::ColourValue color;
 | 
				
			||||||
  color.setAsABGR (mCell.cell->ambi.fog);
 | 
					  color.setAsABGR (mCell.cell->ambi.fog);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  float high = /*4500 + 9000 * */(1-mCell.cell->ambi.fogDensity);
 | 
					  configureFog(mCell.cell->ambi.fogDensity, color);
 | 
				
			||||||
  float low = 200;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  mRendering.getScene()->setFog (FOG_LINEAR, color, 0, low, high);
 | 
					 | 
				
			||||||
  mRendering.getCamera()->setFarClipDistance (high + 10);
 | 
					 | 
				
			||||||
  mRendering.getViewport()->setBackgroundColour (color);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour)
 | 
				
			||||||
 | 
					{  
 | 
				
			||||||
 | 
					  /// \todo make the viewing distance and fog start/end configurable
 | 
				
			||||||
 | 
					  float low = 3000 / density;
 | 
				
			||||||
 | 
					  float high = 6200 / density;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  mRendering.getScene()->setFog (FOG_LINEAR, colour, 0, low, high);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  mRendering.getCamera()->setFarClipDistance ( high );
 | 
				
			||||||
 | 
					  mRendering.getViewport()->setBackgroundColour (colour);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void RenderingManager::setAmbientMode()
 | 
					void RenderingManager::setAmbientMode()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  switch (mAmbientMode)
 | 
					  switch (mAmbientMode)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,9 +102,13 @@ class RenderingManager: private RenderingInterface {
 | 
				
			||||||
    int skyGetSecundaPhase() const;
 | 
					    int skyGetSecundaPhase() const;
 | 
				
			||||||
    void skySetMoonColour (bool red);
 | 
					    void skySetMoonColour (bool red);
 | 
				
			||||||
    void configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell);
 | 
					    void configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    /// configure fog according to cell
 | 
					    /// configure fog according to cell
 | 
				
			||||||
    void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
 | 
					    void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    /// configure fog manually
 | 
				
			||||||
 | 
					    void configureFog(const float density, const Ogre::ColourValue& colour);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
 | 
					    void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
 | 
				
			||||||
        int number = 1);
 | 
					        int number = 1);
 | 
				
			||||||
    ///< Run animation for a MW-reference. Calls to this function for references that are currently not
 | 
					    ///< Run animation for a MW-reference. Calls to this function for references that are currently not
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -623,8 +623,6 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    mAtmosphereNight->setVisible(weather.mNight && mEnabled);
 | 
					    mAtmosphereNight->setVisible(weather.mNight && mEnabled);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    mViewport->setBackgroundColour(weather.mFogColor);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SkyManager::setGlare(bool glare)
 | 
					void SkyManager::setGlare(bool glare)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -235,6 +235,9 @@ namespace MWWorld
 | 
				
			||||||
        // adjust player
 | 
					        // adjust player
 | 
				
			||||||
        mCurrentCell = cell;
 | 
					        mCurrentCell = cell;
 | 
				
			||||||
        playerCellChange (cell, position);
 | 
					        playerCellChange (cell, position);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // adjust fog
 | 
				
			||||||
 | 
					        mRendering.configureFog(*cell);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Sky system
 | 
					        // Sky system
 | 
				
			||||||
        mWorld->adjustSky();
 | 
					        mWorld->adjustSky();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -354,6 +354,8 @@ WeatherResult WeatherManager::getResult(const String& weather)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration);
 | 
					    result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    // night
 | 
					    // night
 | 
				
			||||||
    if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration)
 | 
					    if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration)
 | 
				
			||||||
        || mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration))
 | 
					        || mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration))
 | 
				
			||||||
| 
						 | 
					@ -569,6 +571,8 @@ void WeatherManager::update(float duration)
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            result = getResult(mCurrentWeather);
 | 
					            result = getResult(mCurrentWeather);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        mRendering->configureFog(result.mFogDepth, result.mFogColor);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        // disable sun during night
 | 
					        // disable sun during night
 | 
				
			||||||
        if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration
 | 
					        if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration
 | 
				
			||||||
            || mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration)
 | 
					            || mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration)
 | 
				
			||||||
| 
						 | 
					@ -699,6 +703,8 @@ void WeatherManager::update(float duration)
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            mRendering->getSkyManager()->setThunder(0.f);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        mRendering->setAmbientColour(result.mAmbientColor);
 | 
					        mRendering->setAmbientColour(result.mAmbientColor);
 | 
				
			||||||
        mRendering->sunEnable();
 | 
					        mRendering->sunEnable();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue