1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-22 04:39:43 +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 <OgreHardwareVertexBuffer.h>
#include <OgreHighLevelGpuProgramManager.h>
#include <OgreBillboardSet.h>
#include <OgreParticleSystem.h>
#include <OgreEntity.h>
#include <OgreSubEntity.h>
#include <OgreTechnique.h>
#include <OgreControllerManager.h>
#include <OgreMeshManager.h>
@ -234,6 +235,7 @@ SkyManager::SkyManager(Ogre::SceneNode *root, Ogre::Camera *pCamera)
, mCreated(false)
, mCloudAnimationTimer(0.f)
, mMoonRed(false)
, mParticleNode(NULL)
{
mSceneMgr = root->getCreator();
mRootNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
@ -372,6 +374,12 @@ void SkyManager::update(float duration)
if (!mEnabled) return;
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
mCloudAnimationTimer += duration * mCloudSpeed;
sh::Factory::getInstance().setSharedParameter ("cloudAnimationTimer",
@ -441,6 +449,37 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
{
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)
{
sh::Factory::getInstance().setTextureAlias ("cloud_texture_1", "textures\\"+weather.mCloudTexture);

View file

@ -200,6 +200,9 @@ namespace MWRender
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
Ogre::String mClouds;
Ogre::String mNextClouds;
@ -211,6 +214,8 @@ namespace MWRender
Ogre::ColourValue mSkyColour;
Ogre::ColourValue mFogColour;
std::string mCurrentParticleEffect;
Ogre::Light* mLightning;
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.mCloudSpeed = mFallback->getFallbackFloat("Weather_"+upper+"_Cloud_Speed");
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;
}
@ -123,48 +128,42 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fa
//Weather
Weather clear;
clear.mCloudTexture = "tx_sky_clear.dds";
setFallbackWeather(clear,"clear");
Weather cloudy;
cloudy.mCloudTexture = "tx_sky_cloudy.dds";
setFallbackWeather(cloudy,"cloudy");
Weather foggy;
foggy.mCloudTexture = "tx_sky_foggy.dds";
setFallbackWeather(foggy,"foggy");
Weather thunderstorm;
thunderstorm.mCloudTexture = "tx_sky_thunder.dds";
thunderstorm.mRainLoopSoundID = "rain heavy";
setFallbackWeather(thunderstorm,"thunderstorm");
Weather rain;
rain.mCloudTexture = "tx_sky_rainy.dds";
rain.mRainLoopSoundID = "rain";
setFallbackWeather(rain,"rain");
Weather overcast;
overcast.mCloudTexture = "tx_sky_overcast.dds";
setFallbackWeather(overcast,"overcast");
Weather ashstorm;
ashstorm.mCloudTexture = "tx_sky_ashstorm.dds";
ashstorm.mAmbientLoopSoundID = "ashstorm";
ashstorm.mParticleEffect = "meshes\\ashcloud.nif";
setFallbackWeather(ashstorm,"ashstorm");
Weather blight;
blight.mCloudTexture = "tx_sky_blight.dds";
blight.mAmbientLoopSoundID = "blight";
blight.mParticleEffect = "meshes\\blightcloud.nif";
setFallbackWeather(blight,"blight");
Weather snow;
snow.mCloudTexture = "tx_bm_sky_snow.dds";
snow.mParticleEffect = "meshes\\snow.nif";
setFallbackWeather(snow, "snow");
Weather blizzard;
blizzard.mCloudTexture = "tx_bm_sky_blizzard.dds";
blizzard.mAmbientLoopSoundID = "BM Blizzard";
blizzard.mParticleEffect = "meshes\\blizzard.nif";
setFallbackWeather(blizzard,"blizzard");
}
@ -214,6 +213,8 @@ void WeatherManager::setResult(const String& weatherType)
mResult.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
mResult.mSunColor = current.mSunDiscSunsetColor;
mResult.mParticleEffect = current.mParticleEffect;
mResult.mNight = (mHour < mSunriseTime || mHour > mNightStart - 1);
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.mNight = current.mNight;
mResult.mParticleEffect = current.mParticleEffect;
}
void WeatherManager::update(float duration)

View file

@ -58,6 +58,8 @@ namespace MWWorld
float mNightFade; // fading factor for night skybox
std::string mAmbientLoopSoundID;
std::string mParticleEffect;
};
@ -119,7 +121,10 @@ namespace MWWorld
// Rain sound effect
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.
};
///