mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 13:15:32 +00:00
Rotate clouds/particles to come from red mountain (Fixes #245)
This commit is contained in:
parent
9eb8addc70
commit
07d0f4458d
7 changed files with 68 additions and 26 deletions
|
@ -608,7 +608,7 @@ void CharacterController::updateIdleStormState()
|
|||
{
|
||||
Ogre::Vector3 stormDirection = MWBase::Environment::get().getWorld()->getStormDirection();
|
||||
Ogre::Vector3 characterDirection = mPtr.getRefData().getBaseNode()->getOrientation().yAxis();
|
||||
inStormDirection = stormDirection.angleBetween(characterDirection) < Ogre::Degree(40);
|
||||
inStormDirection = stormDirection.angleBetween(characterDirection) > Ogre::Degree(120);
|
||||
}
|
||||
if (inStormDirection && mUpperBodyState == UpperCharState_Nothing && mAnimation->hasAnimation("idlestorm"))
|
||||
{
|
||||
|
|
|
@ -219,6 +219,7 @@ SkyManager::SkyManager(Ogre::SceneNode *root, Ogre::Camera *pCamera)
|
|||
, mSceneMgr(NULL)
|
||||
, mAtmosphereDay(NULL)
|
||||
, mAtmosphereNight(NULL)
|
||||
, mCloudNode(NULL)
|
||||
, mClouds()
|
||||
, mNextClouds()
|
||||
, mCloudBlendFactor(0.0f)
|
||||
|
@ -240,10 +241,11 @@ SkyManager::SkyManager(Ogre::SceneNode *root, Ogre::Camera *pCamera)
|
|||
, mRainTimer(0)
|
||||
, mRainSpeed(0)
|
||||
, mRainFrequency(1)
|
||||
, mStormDirection(0,-1,0)
|
||||
, mIsStorm(false)
|
||||
{
|
||||
mSceneMgr = root->getCreator();
|
||||
mRootNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
|
||||
mRootNode->setInheritOrientation(false);
|
||||
}
|
||||
|
||||
void SkyManager::create()
|
||||
|
@ -335,8 +337,8 @@ void SkyManager::create()
|
|||
mObjects.push_back(objects);
|
||||
|
||||
// Clouds
|
||||
SceneNode* clouds_node = mRootNode->createChildSceneNode();
|
||||
objects = NifOgre::Loader::createObjects(clouds_node, "meshes\\sky_clouds_01.nif");
|
||||
mCloudNode = mRootNode->createChildSceneNode();
|
||||
objects = NifOgre::Loader::createObjects(mCloudNode, "meshes\\sky_clouds_01.nif");
|
||||
for(size_t i = 0;i < objects->mEntities.size();i++)
|
||||
{
|
||||
Entity* clouds_ent = objects->mEntities[i];
|
||||
|
@ -453,8 +455,16 @@ void SkyManager::update(float duration)
|
|||
{
|
||||
for (unsigned int i=0; i<mParticle->mControllers.size(); ++i)
|
||||
mParticle->mControllers[i].update();
|
||||
|
||||
if (mIsStorm)
|
||||
mParticleNode->setOrientation(Ogre::Vector3::UNIT_Y.getRotationTo(mStormDirection));
|
||||
}
|
||||
|
||||
if (mIsStorm)
|
||||
mCloudNode->setOrientation(Ogre::Vector3::UNIT_Y.getRotationTo(mStormDirection));
|
||||
else
|
||||
mCloudNode->setOrientation(Ogre::Quaternion::IDENTITY);
|
||||
|
||||
updateRain(duration);
|
||||
|
||||
// UV Scroll the clouds
|
||||
|
@ -539,6 +549,7 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
|||
mRainEnabled = !mRainEffect.empty();
|
||||
mRainFrequency = weather.mRainFrequency;
|
||||
mRainSpeed = weather.mRainSpeed;
|
||||
mIsStorm = weather.mIsStorm;
|
||||
|
||||
if (mCurrentParticleEffect != weather.mParticleEffect)
|
||||
{
|
||||
|
@ -676,6 +687,11 @@ void SkyManager::sunDisable()
|
|||
mSunEnabled = false;
|
||||
}
|
||||
|
||||
void SkyManager::setStormDirection(const Vector3 &direction)
|
||||
{
|
||||
mStormDirection = direction;
|
||||
}
|
||||
|
||||
void SkyManager::setSunDirection(const Vector3& direction, bool is_moon)
|
||||
{
|
||||
if (!mCreated) return;
|
||||
|
|
|
@ -150,6 +150,8 @@ namespace MWRender
|
|||
|
||||
void setRainSpeed(float speed);
|
||||
|
||||
void setStormDirection(const Ogre::Vector3& direction);
|
||||
|
||||
void setSunDirection(const Ogre::Vector3& direction, bool is_moon);
|
||||
|
||||
void setMasserDirection(const Ogre::Vector3& direction);
|
||||
|
@ -185,6 +187,8 @@ namespace MWRender
|
|||
|
||||
bool mMoonRed;
|
||||
|
||||
bool mIsStorm;
|
||||
|
||||
float mHour;
|
||||
int mDay;
|
||||
int mMonth;
|
||||
|
@ -203,6 +207,8 @@ namespace MWRender
|
|||
Ogre::SceneNode* mAtmosphereDay;
|
||||
Ogre::SceneNode* mAtmosphereNight;
|
||||
|
||||
Ogre::SceneNode* mCloudNode;
|
||||
|
||||
std::vector<NifOgre::ObjectScenePtr> mObjects;
|
||||
|
||||
Ogre::SceneNode* mParticleNode;
|
||||
|
@ -211,6 +217,8 @@ namespace MWRender
|
|||
std::map<Ogre::SceneNode*, NifOgre::ObjectScenePtr> mRainModels;
|
||||
float mRainTimer;
|
||||
|
||||
Ogre::Vector3 mStormDirection;
|
||||
|
||||
// remember some settings so we don't have to apply them again if they didnt change
|
||||
Ogre::String mClouds;
|
||||
Ogre::String mNextClouds;
|
||||
|
|
|
@ -115,7 +115,8 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fa
|
|||
mHour(14), mCurrentWeather("clear"), mNextWeather(""), mFirstUpdate(true),
|
||||
mWeatherUpdateTime(0), mThunderFlash(0), mThunderChance(0),
|
||||
mThunderChanceNeeded(50), mThunderSoundDelay(0), mRemainingTransitionTime(0),
|
||||
mTimePassed(0), mFallback(fallback), mWindSpeed(0.f), mRendering(rendering), mIsStorm(false)
|
||||
mTimePassed(0), mFallback(fallback), mWindSpeed(0.f), mRendering(rendering), mIsStorm(false),
|
||||
mStormDirection(0,1,0)
|
||||
{
|
||||
//Globals
|
||||
mThunderSoundID0 = mFallback->getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_0");
|
||||
|
@ -389,6 +390,17 @@ void WeatherManager::update(float duration)
|
|||
mWindSpeed = mResult.mWindSpeed;
|
||||
mIsStorm = mResult.mIsStorm;
|
||||
|
||||
if (mIsStorm)
|
||||
{
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
Ogre::Vector3 playerPos (player.getRefData().getPosition().pos);
|
||||
Ogre::Vector3 redMountainPos (19950, 72032, 27831);
|
||||
|
||||
mStormDirection = (playerPos - redMountainPos);
|
||||
mStormDirection.z = 0;
|
||||
mRendering->getSkyManager()->setStormDirection(mStormDirection);
|
||||
}
|
||||
|
||||
mRendering->configureFog(mResult.mFogDepth, mResult.mFogColor);
|
||||
|
||||
// disable sun during night
|
||||
|
@ -812,5 +824,5 @@ bool WeatherManager::isInStorm() const
|
|||
|
||||
Ogre::Vector3 WeatherManager::getStormDirection() const
|
||||
{
|
||||
return Ogre::Vector3(0,-1,0);
|
||||
return mStormDirection;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <string>
|
||||
|
||||
#include <OgreColourValue.h>
|
||||
#include <OgreVector3.h>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -202,6 +203,8 @@ namespace MWWorld
|
|||
float mHour;
|
||||
float mWindSpeed;
|
||||
bool mIsStorm;
|
||||
Ogre::Vector3 mStormDirection;
|
||||
|
||||
MWWorld::Fallback* mFallback;
|
||||
void setFallbackWeather(Weather& weather,const std::string& name);
|
||||
MWRender::RenderingManager* mRendering;
|
||||
|
|
|
@ -3,25 +3,27 @@
|
|||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, view) @shAutoConstant(view, view_matrix)
|
||||
shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix)
|
||||
shUniform(float4x4, worldview) @shAutoConstant(worldview, worldview_matrix)
|
||||
shUniform(float4x4, proj) @shAutoConstant(proj, projection_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shOutput(float, alphaFade)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4x4 viewFixed = view;
|
||||
float4x4 worldviewFixed = worldview;
|
||||
|
||||
#if !SH_GLSL
|
||||
viewFixed[0][3] = 0;
|
||||
viewFixed[1][3] = 0;
|
||||
viewFixed[2][3] = 0;
|
||||
worldviewFixed[0][3] = 0;
|
||||
worldviewFixed[1][3] = 0;
|
||||
worldviewFixed[2][3] = 0;
|
||||
#else
|
||||
viewFixed[3][0] = 0;
|
||||
viewFixed[3][1] = 0;
|
||||
viewFixed[3][2] = 0;
|
||||
worldviewFixed[3][0] = 0;
|
||||
worldviewFixed[3][1] = 0;
|
||||
worldviewFixed[3][2] = 0;
|
||||
#endif
|
||||
shOutputPosition = shMatrixMult(projection, shMatrixMult(viewFixed, shInputPosition));
|
||||
|
||||
shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition));
|
||||
UV = uv0;
|
||||
alphaFade = (shInputPosition.z <= 200.f) ? ((shInputPosition.z <= 100.f) ? 0.0 : 0.25) : 1.0;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, view) @shAutoConstant(view, view_matrix)
|
||||
shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix)
|
||||
shUniform(float4x4, worldview) @shAutoConstant(worldview, worldview_matrix)
|
||||
shUniform(float4x4, proj) @shAutoConstant(proj, projection_matrix)
|
||||
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
@ -12,17 +12,18 @@ shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix)
|
|||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4x4 viewFixed = view;
|
||||
float4x4 worldviewFixed = worldview;
|
||||
#if !SH_GLSL
|
||||
viewFixed[0][3] = 0;
|
||||
viewFixed[1][3] = 0;
|
||||
viewFixed[2][3] = 0;
|
||||
worldviewFixed[0][3] = 0;
|
||||
worldviewFixed[1][3] = 0;
|
||||
worldviewFixed[2][3] = 0;
|
||||
#else
|
||||
viewFixed[3][0] = 0;
|
||||
viewFixed[3][1] = 0;
|
||||
viewFixed[3][2] = 0;
|
||||
worldviewFixed[3][0] = 0;
|
||||
worldviewFixed[3][1] = 0;
|
||||
worldviewFixed[3][2] = 0;
|
||||
#endif
|
||||
shOutputPosition = shMatrixMult(projection, shMatrixMult(viewFixed, shInputPosition));
|
||||
|
||||
shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition));
|
||||
UV = uv0;
|
||||
|
||||
fade = (shInputPosition.z > 50) ? 1 : 0;
|
||||
|
|
Loading…
Reference in a new issue