1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-22 21:09:45 +00:00

Implement ashstorm, blightstorm, snow and blizzard effects (Feature #41)

This commit is contained in:
scrawl 2014-06-24 15:00:15 +02:00
parent 30be59c029
commit 36132e054a
4 changed files with 64 additions and 12 deletions

View file

@ -8,10 +8,11 @@
#include <OgreSceneManager.h> #include <OgreSceneManager.h>
#include <OgreHardwareVertexBuffer.h> #include <OgreHardwareVertexBuffer.h>
#include <OgreHighLevelGpuProgramManager.h> #include <OgreHighLevelGpuProgramManager.h>
#include <OgreBillboardSet.h> #include <OgreParticleSystem.h>
#include <OgreEntity.h> #include <OgreEntity.h>
#include <OgreSubEntity.h> #include <OgreSubEntity.h>
#include <OgreTechnique.h> #include <OgreTechnique.h>
#include <OgreControllerManager.h>
#include <OgreMeshManager.h> #include <OgreMeshManager.h>
@ -234,6 +235,7 @@ SkyManager::SkyManager(Ogre::SceneNode *root, Ogre::Camera *pCamera)
, mCreated(false) , mCreated(false)
, mCloudAnimationTimer(0.f) , mCloudAnimationTimer(0.f)
, mMoonRed(false) , mMoonRed(false)
, mParticleNode(NULL)
{ {
mSceneMgr = root->getCreator(); mSceneMgr = root->getCreator();
mRootNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); mRootNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
@ -372,6 +374,12 @@ void SkyManager::update(float duration)
if (!mEnabled) return; if (!mEnabled) return;
const MWWorld::Fallback* fallback=MWBase::Environment::get().getWorld()->getFallback(); const MWWorld::Fallback* fallback=MWBase::Environment::get().getWorld()->getFallback();
if (!mParticle.isNull())
{
for (unsigned int i=0; i<mParticle->mControllers.size(); ++i)
mParticle->mControllers[i].update();
}
// UV Scroll the clouds // UV Scroll the clouds
mCloudAnimationTimer += duration * mCloudSpeed; mCloudAnimationTimer += duration * mCloudSpeed;
sh::Factory::getInstance().setSharedParameter ("cloudAnimationTimer", sh::Factory::getInstance().setSharedParameter ("cloudAnimationTimer",
@ -441,6 +449,37 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
{ {
if (!mCreated) return; if (!mCreated) return;
if (mCurrentParticleEffect != weather.mParticleEffect)
{
mCurrentParticleEffect = weather.mParticleEffect;
if (mCurrentParticleEffect.empty())
{
mParticle.setNull();
}
else
{
if (!mParticleNode)
{
mParticleNode = mCamera->getParentSceneNode()->createChildSceneNode();
mParticleNode->setInheritOrientation(false);
}
mParticle = NifOgre::Loader::createObjects(mParticleNode, mCurrentParticleEffect);
for(size_t i = 0; i < mParticle->mParticles.size(); ++i)
{
ParticleSystem* particle = mParticle->mParticles[i];
particle->setRenderQueueGroup(RQG_Alpha);
particle->setVisibilityFlags(RV_Sky);
}
for (size_t i = 0; i < mParticle->mControllers.size(); ++i)
{
if (mParticle->mControllers[i].getSource().isNull())
mParticle->mControllers[i].setSource(Ogre::ControllerManager::getSingleton().getFrameTimeSource());
}
}
}
if (mClouds != weather.mCloudTexture) if (mClouds != weather.mCloudTexture)
{ {
sh::Factory::getInstance().setTextureAlias ("cloud_texture_1", "textures\\"+weather.mCloudTexture); sh::Factory::getInstance().setTextureAlias ("cloud_texture_1", "textures\\"+weather.mCloudTexture);

View file

@ -200,6 +200,9 @@ namespace MWRender
std::vector<NifOgre::ObjectScenePtr> mObjects; std::vector<NifOgre::ObjectScenePtr> mObjects;
Ogre::SceneNode* mParticleNode;
NifOgre::ObjectScenePtr mParticle;
// remember some settings so we don't have to apply them again if they didnt change // remember some settings so we don't have to apply them again if they didnt change
Ogre::String mClouds; Ogre::String mClouds;
Ogre::String mNextClouds; Ogre::String mNextClouds;
@ -211,6 +214,8 @@ namespace MWRender
Ogre::ColourValue mSkyColour; Ogre::ColourValue mSkyColour;
Ogre::ColourValue mFogColour; Ogre::ColourValue mFogColour;
std::string mCurrentParticleEffect;
Ogre::Light* mLightning; Ogre::Light* mLightning;
float mRemainingTransitionTime; float mRemainingTransitionTime;

View file

@ -58,6 +58,11 @@ void WeatherManager::setFallbackWeather(Weather& weather,const std::string& name
weather.mWindSpeed = mFallback->getFallbackFloat("Weather_"+upper+"_Wind_Speed"); weather.mWindSpeed = mFallback->getFallbackFloat("Weather_"+upper+"_Wind_Speed");
weather.mCloudSpeed = mFallback->getFallbackFloat("Weather_"+upper+"_Cloud_Speed"); weather.mCloudSpeed = mFallback->getFallbackFloat("Weather_"+upper+"_Cloud_Speed");
weather.mGlareView = mFallback->getFallbackFloat("Weather_"+upper+"_Glare_View"); weather.mGlareView = mFallback->getFallbackFloat("Weather_"+upper+"_Glare_View");
weather.mCloudTexture = mFallback->getFallbackString("Weather_"+upper+"_Cloud_Texture");
size_t offset = weather.mCloudTexture.find(".tga");
if (offset != std::string::npos)
weather.mCloudTexture.replace(offset, weather.mCloudTexture.length() - offset, ".dds");
mWeatherSettings[name] = weather; mWeatherSettings[name] = weather;
} }
@ -123,48 +128,42 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fa
//Weather //Weather
Weather clear; Weather clear;
clear.mCloudTexture = "tx_sky_clear.dds";
setFallbackWeather(clear,"clear"); setFallbackWeather(clear,"clear");
Weather cloudy; Weather cloudy;
cloudy.mCloudTexture = "tx_sky_cloudy.dds";
setFallbackWeather(cloudy,"cloudy"); setFallbackWeather(cloudy,"cloudy");
Weather foggy; Weather foggy;
foggy.mCloudTexture = "tx_sky_foggy.dds";
setFallbackWeather(foggy,"foggy"); setFallbackWeather(foggy,"foggy");
Weather thunderstorm; Weather thunderstorm;
thunderstorm.mCloudTexture = "tx_sky_thunder.dds";
thunderstorm.mRainLoopSoundID = "rain heavy"; thunderstorm.mRainLoopSoundID = "rain heavy";
setFallbackWeather(thunderstorm,"thunderstorm"); setFallbackWeather(thunderstorm,"thunderstorm");
Weather rain; Weather rain;
rain.mCloudTexture = "tx_sky_rainy.dds";
rain.mRainLoopSoundID = "rain"; rain.mRainLoopSoundID = "rain";
setFallbackWeather(rain,"rain"); setFallbackWeather(rain,"rain");
Weather overcast; Weather overcast;
overcast.mCloudTexture = "tx_sky_overcast.dds";
setFallbackWeather(overcast,"overcast"); setFallbackWeather(overcast,"overcast");
Weather ashstorm; Weather ashstorm;
ashstorm.mCloudTexture = "tx_sky_ashstorm.dds";
ashstorm.mAmbientLoopSoundID = "ashstorm"; ashstorm.mAmbientLoopSoundID = "ashstorm";
ashstorm.mParticleEffect = "meshes\\ashcloud.nif";
setFallbackWeather(ashstorm,"ashstorm"); setFallbackWeather(ashstorm,"ashstorm");
Weather blight; Weather blight;
blight.mCloudTexture = "tx_sky_blight.dds";
blight.mAmbientLoopSoundID = "blight"; blight.mAmbientLoopSoundID = "blight";
blight.mParticleEffect = "meshes\\blightcloud.nif";
setFallbackWeather(blight,"blight"); setFallbackWeather(blight,"blight");
Weather snow; Weather snow;
snow.mCloudTexture = "tx_bm_sky_snow.dds"; snow.mParticleEffect = "meshes\\snow.nif";
setFallbackWeather(snow, "snow"); setFallbackWeather(snow, "snow");
Weather blizzard; Weather blizzard;
blizzard.mCloudTexture = "tx_bm_sky_blizzard.dds";
blizzard.mAmbientLoopSoundID = "BM Blizzard"; blizzard.mAmbientLoopSoundID = "BM Blizzard";
blizzard.mParticleEffect = "meshes\\blizzard.nif";
setFallbackWeather(blizzard,"blizzard"); setFallbackWeather(blizzard,"blizzard");
} }
@ -214,6 +213,8 @@ void WeatherManager::setResult(const String& weatherType)
mResult.mAmbientLoopSoundID = current.mAmbientLoopSoundID; mResult.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
mResult.mSunColor = current.mSunDiscSunsetColor; mResult.mSunColor = current.mSunDiscSunsetColor;
mResult.mParticleEffect = current.mParticleEffect;
mResult.mNight = (mHour < mSunriseTime || mHour > mNightStart - 1); mResult.mNight = (mHour < mSunriseTime || mHour > mNightStart - 1);
mResult.mFogDepth = mResult.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth; mResult.mFogDepth = mResult.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth;
@ -316,6 +317,8 @@ void WeatherManager::transition(float factor)
mResult.mNightFade = lerp(current.mNightFade, other.mNightFade, factor); mResult.mNightFade = lerp(current.mNightFade, other.mNightFade, factor);
mResult.mNight = current.mNight; mResult.mNight = current.mNight;
mResult.mParticleEffect = current.mParticleEffect;
} }
void WeatherManager::update(float duration) void WeatherManager::update(float duration)

View file

@ -58,6 +58,8 @@ namespace MWWorld
float mNightFade; // fading factor for night skybox float mNightFade; // fading factor for night skybox
std::string mAmbientLoopSoundID; std::string mAmbientLoopSoundID;
std::string mParticleEffect;
}; };
@ -119,7 +121,10 @@ namespace MWWorld
// Rain sound effect // Rain sound effect
std::string mRainLoopSoundID; std::string mRainLoopSoundID;
/// \todo disease chance std::string mParticleEffect;
// Note: For Weather Blight, there is a "Disease Chance" (=0.1) setting. But according to MWSFD this feature
// is broken in the vanilla game and was disabled.
}; };
/// ///