mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-13 21:40:11 +00:00
moon positions and fading
This commit is contained in:
parent
4650672bb1
commit
e31ad90802
@ -21,7 +21,7 @@ using namespace Ogre;
|
|||||||
#define CELESTIAL_BODY_DISTANCE 1000.f
|
#define CELESTIAL_BODY_DISTANCE 1000.f
|
||||||
|
|
||||||
BillboardObject::BillboardObject( const String& textureName,
|
BillboardObject::BillboardObject( const String& textureName,
|
||||||
const unsigned int initialSize,
|
const float initialSize,
|
||||||
const Vector3& position,
|
const Vector3& position,
|
||||||
SceneNode* rootNode)
|
SceneNode* rootNode)
|
||||||
{
|
{
|
||||||
@ -63,21 +63,19 @@ SceneNode* BillboardObject::getNode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BillboardObject::init(const String& textureName,
|
void BillboardObject::init(const String& textureName,
|
||||||
const unsigned int initialSize,
|
const float initialSize,
|
||||||
const Vector3& position,
|
const Vector3& position,
|
||||||
SceneNode* rootNode)
|
SceneNode* rootNode)
|
||||||
{
|
{
|
||||||
SceneManager* sceneMgr = rootNode->getCreator();
|
SceneManager* sceneMgr = rootNode->getCreator();
|
||||||
|
|
||||||
const float scale = initialSize*550.f;
|
|
||||||
|
|
||||||
Vector3 finalPosition = position.normalisedCopy() * CELESTIAL_BODY_DISTANCE;
|
Vector3 finalPosition = position.normalisedCopy() * CELESTIAL_BODY_DISTANCE;
|
||||||
|
|
||||||
static unsigned int bodyCount=0;
|
static unsigned int bodyCount=0;
|
||||||
|
|
||||||
/// \todo These billboards are not 100% correct, might want to revisit them later
|
/// \todo These billboards are not 100% correct, might want to revisit them later
|
||||||
mBBSet = sceneMgr->createBillboardSet("SkyBillboardSet"+StringConverter::toString(bodyCount), 1);
|
mBBSet = sceneMgr->createBillboardSet("SkyBillboardSet"+StringConverter::toString(bodyCount), 1);
|
||||||
mBBSet->setDefaultDimensions(scale, scale);
|
mBBSet->setDefaultDimensions(550.f*initialSize, 550.f*initialSize);
|
||||||
mBBSet->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY+2);
|
mBBSet->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY+2);
|
||||||
mBBSet->setBillboardType(BBT_PERPENDICULAR_COMMON);
|
mBBSet->setBillboardType(BBT_PERPENDICULAR_COMMON);
|
||||||
mBBSet->setCommonDirection( -position.normalisedCopy() );
|
mBBSet->setCommonDirection( -position.normalisedCopy() );
|
||||||
@ -102,7 +100,7 @@ void BillboardObject::init(const String& textureName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Moon::Moon( const String& textureName,
|
Moon::Moon( const String& textureName,
|
||||||
const unsigned int initialSize,
|
const float initialSize,
|
||||||
const Vector3& position,
|
const Vector3& position,
|
||||||
SceneNode* rootNode)
|
SceneNode* rootNode)
|
||||||
{
|
{
|
||||||
@ -214,9 +212,13 @@ unsigned int Moon::getPhaseInt() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Moon::setVisibility(const float pVisibility)
|
void Moon::setVisibility(const float visibility)
|
||||||
{
|
{
|
||||||
mMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("visibilityFactor", Real(pVisibility));
|
if (mVisibility != visibility)
|
||||||
|
{
|
||||||
|
mMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("visibilityFactor", Real(visibility));
|
||||||
|
mVisibility = visibility;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
|
void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
|
||||||
@ -302,14 +304,19 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
|
|||||||
overlay_panel->show();
|
overlay_panel->show();
|
||||||
mThunderOverlay->add2D(overlay_panel);
|
mThunderOverlay->add2D(overlay_panel);
|
||||||
mThunderOverlay->hide();
|
mThunderOverlay->hide();
|
||||||
|
|
||||||
|
mSecunda = new Moon("textures\\tx_secunda_full.dds", 0.5, Vector3(-0.4, 0.4, 0.5), mRootNode);
|
||||||
|
mSecunda->setType(Moon::Type_Secunda);
|
||||||
|
mSecunda->setRenderQueue(RENDER_QUEUE_SKIES_EARLY+4);
|
||||||
|
|
||||||
|
mMasser = new Moon("textures\\tx_masser_full.dds", 0.75, Vector3(-0.4, 0.4, 0.5), mRootNode);
|
||||||
|
mMasser->setRenderQueue(RENDER_QUEUE_SKIES_EARLY+3);
|
||||||
|
mMasser->setType(Moon::Type_Masser);
|
||||||
|
|
||||||
mSun = new BillboardObject("textures\\tx_sun_05.dds", 1, Vector3(0.4, 0.4, 0.4), mRootNode);
|
mSun = new BillboardObject("textures\\tx_sun_05.dds", 1, Vector3(0.4, 0.4, 0.4), mRootNode);
|
||||||
mSunGlare = new BillboardObject("textures\\tx_sun_flash_grey_05.dds", 3, Vector3(0.4, 0.4, 0.4), mRootNode);
|
mSunGlare = new BillboardObject("textures\\tx_sun_flash_grey_05.dds", 3, Vector3(0.4, 0.4, 0.4), mRootNode);
|
||||||
mSunGlare->setRenderQueue(RENDER_QUEUE_SKIES_LATE);
|
mSunGlare->setRenderQueue(RENDER_QUEUE_SKIES_LATE);
|
||||||
mMasser = new Moon("textures\\tx_masser_full.dds", 1, Vector3(-0.4, 0.4, 0.5), mRootNode);
|
|
||||||
mSecunda = new Moon("textures\\tx_secunda_full.dds", 0.5, Vector3(0.4, -0.4, 0.5), mRootNode);
|
|
||||||
mMasser->setType(Moon::Type_Masser);
|
|
||||||
mSecunda->setType(Moon::Type_Secunda);
|
|
||||||
|
|
||||||
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
|
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
|
||||||
|
|
||||||
@ -427,7 +434,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
|
|||||||
// Clouds
|
// Clouds
|
||||||
NifOgre::NIFLoader::load("meshes\\sky_clouds_01.nif");
|
NifOgre::NIFLoader::load("meshes\\sky_clouds_01.nif");
|
||||||
Entity* clouds_ent = mSceneMgr->createEntity("meshes\\sky_clouds_01.nif");
|
Entity* clouds_ent = mSceneMgr->createEntity("meshes\\sky_clouds_01.nif");
|
||||||
clouds_ent->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY+3);
|
clouds_ent->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY+5);
|
||||||
SceneNode* clouds_node = mRootNode->createChildSceneNode();
|
SceneNode* clouds_node = mRootNode->createChildSceneNode();
|
||||||
clouds_node->attachObject(clouds_ent);
|
clouds_node->attachObject(clouds_ent);
|
||||||
mCloudMaterial = clouds_ent->getSubEntity(0)->getMaterial();
|
mCloudMaterial = clouds_ent->getSubEntity(0)->getMaterial();
|
||||||
@ -538,12 +545,10 @@ void SkyManager::enable()
|
|||||||
mRootNode->setVisible(true);
|
mRootNode->setVisible(true);
|
||||||
mEnabled = true;
|
mEnabled = true;
|
||||||
|
|
||||||
mSunGlare->setVisible(mGlareEnabled && mSunEnabled && mEnabled);
|
mSunGlare->setVisible(mGlareEnabled && mSunEnabled);
|
||||||
mSun->setVisible(mSunEnabled && mEnabled);
|
mSun->setVisible(mSunEnabled);
|
||||||
|
mMasser->setVisible(mMasserEnabled);
|
||||||
/// \todo
|
mSecunda->setVisible(mSecundaEnabled);
|
||||||
mMasser->setVisible(false);
|
|
||||||
mSecunda->setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyManager::disable()
|
void SkyManager::disable()
|
||||||
@ -554,8 +559,7 @@ void SkyManager::disable()
|
|||||||
|
|
||||||
void SkyManager::setMoonColour (bool red)
|
void SkyManager::setMoonColour (bool red)
|
||||||
{
|
{
|
||||||
/// \todo tweak these colors
|
mSecunda->setColour( red ? ColourValue(1.0, 0.0784, 0.0784)
|
||||||
mSecunda->setColour( red ? ColourValue(1.0, 0.0, 0.0)
|
|
||||||
: ColourValue(1.0, 1.0, 1.0));
|
: ColourValue(1.0, 1.0, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,6 +650,36 @@ void SkyManager::setSunDirection(const Vector3& direction)
|
|||||||
mSunGlare->setPosition(direction);
|
mSunGlare->setPosition(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkyManager::setMasserDirection(const Vector3& direction)
|
||||||
|
{
|
||||||
|
mMasser->setPosition(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkyManager::setSecundaDirection(const Vector3& direction)
|
||||||
|
{
|
||||||
|
mSecunda->setPosition(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkyManager::masserEnable()
|
||||||
|
{
|
||||||
|
mMasserEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkyManager::secundaEnable()
|
||||||
|
{
|
||||||
|
mSecundaEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkyManager::masserDisable()
|
||||||
|
{
|
||||||
|
mMasserEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkyManager::secundaDisable()
|
||||||
|
{
|
||||||
|
mSecundaEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
void SkyManager::setThunder(const float factor)
|
void SkyManager::setThunder(const float factor)
|
||||||
{
|
{
|
||||||
if (factor > 0.f)
|
if (factor > 0.f)
|
||||||
@ -656,3 +690,13 @@ void SkyManager::setThunder(const float factor)
|
|||||||
else
|
else
|
||||||
mThunderOverlay->hide();
|
mThunderOverlay->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkyManager::setMasserFade(const float fade)
|
||||||
|
{
|
||||||
|
mMasser->setVisibility(fade);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkyManager::setSecundaFade(const float fade)
|
||||||
|
{
|
||||||
|
mSecunda->setVisibility(fade);
|
||||||
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace MWRender
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BillboardObject( const Ogre::String& textureName,
|
BillboardObject( const Ogre::String& textureName,
|
||||||
const unsigned int size,
|
const float size,
|
||||||
const Ogre::Vector3& position,
|
const Ogre::Vector3& position,
|
||||||
Ogre::SceneNode* rootNode
|
Ogre::SceneNode* rootNode
|
||||||
);
|
);
|
||||||
@ -44,7 +44,7 @@ namespace MWRender
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void init(const Ogre::String& textureName,
|
virtual void init(const Ogre::String& textureName,
|
||||||
const unsigned int size,
|
const float size,
|
||||||
const Ogre::Vector3& position,
|
const Ogre::Vector3& position,
|
||||||
Ogre::SceneNode* rootNode);
|
Ogre::SceneNode* rootNode);
|
||||||
|
|
||||||
@ -61,12 +61,12 @@ namespace MWRender
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Moon( const Ogre::String& textureName,
|
Moon( const Ogre::String& textureName,
|
||||||
const unsigned int size,
|
const float size,
|
||||||
const Ogre::Vector3& position,
|
const Ogre::Vector3& position,
|
||||||
Ogre::SceneNode* rootNode
|
Ogre::SceneNode* rootNode
|
||||||
);
|
);
|
||||||
|
|
||||||
void setVisibility(const float pVisibility);
|
void setVisibility(const float visibility);
|
||||||
///< set the transparency factor for this moon
|
///< set the transparency factor for this moon
|
||||||
|
|
||||||
enum Phase
|
enum Phase
|
||||||
@ -94,6 +94,7 @@ namespace MWRender
|
|||||||
unsigned int getPhaseInt() const;
|
unsigned int getPhaseInt() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
float mVisibility;
|
||||||
Type mType;
|
Type mType;
|
||||||
Phase mPhase;
|
Phase mPhase;
|
||||||
};
|
};
|
||||||
@ -138,6 +139,20 @@ namespace MWRender
|
|||||||
|
|
||||||
void setSunDirection(const Ogre::Vector3& direction);
|
void setSunDirection(const Ogre::Vector3& direction);
|
||||||
|
|
||||||
|
void setMasserDirection(const Ogre::Vector3& direction);
|
||||||
|
|
||||||
|
void setSecundaDirection(const Ogre::Vector3& direction);
|
||||||
|
|
||||||
|
void setMasserFade(const float fade);
|
||||||
|
|
||||||
|
void setSecundaFade(const float fade);
|
||||||
|
|
||||||
|
void masserEnable();
|
||||||
|
void masserDisable();
|
||||||
|
|
||||||
|
void secundaEnable();
|
||||||
|
void secundaDisable();
|
||||||
|
|
||||||
void setThunder(const float factor);
|
void setThunder(const float factor);
|
||||||
|
|
||||||
void setGlare(bool glare);
|
void setGlare(bool glare);
|
||||||
@ -183,6 +198,8 @@ namespace MWRender
|
|||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
bool mGlareEnabled;
|
bool mGlareEnabled;
|
||||||
bool mSunEnabled;
|
bool mSunEnabled;
|
||||||
|
bool mMasserEnabled;
|
||||||
|
bool mSecundaEnabled;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen
|
|||||||
mWeatherSettings["overcast"] = overcast;
|
mWeatherSettings["overcast"] = overcast;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
setWeather("thunderstorm", true);
|
setWeather("clear", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeatherManager::setWeather(const String& weather, bool instant)
|
void WeatherManager::setWeather(const String& weather, bool instant)
|
||||||
@ -319,6 +319,74 @@ void WeatherManager::update(float duration)
|
|||||||
mRendering->getSkyManager()->sunEnable();
|
mRendering->getSkyManager()->sunEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// moon calculations
|
||||||
|
float night;
|
||||||
|
if (mHour >= 14)
|
||||||
|
night = mHour-14;
|
||||||
|
else if (mHour <= 10)
|
||||||
|
night = mHour+10;
|
||||||
|
else
|
||||||
|
night = 0;
|
||||||
|
|
||||||
|
night /= 20.f;
|
||||||
|
|
||||||
|
if (night != 0)
|
||||||
|
{
|
||||||
|
float moonHeight = 1-std::abs((night-0.5)*2);
|
||||||
|
int facing = (mHour > 0.f && mHour<12.f) ? 1 : -1;
|
||||||
|
Vector3 masser(
|
||||||
|
(1-moonHeight)*facing,
|
||||||
|
(1-moonHeight)*facing,
|
||||||
|
moonHeight);
|
||||||
|
|
||||||
|
Vector3 secunda(
|
||||||
|
(1-moonHeight)*facing*0.8,
|
||||||
|
(1-moonHeight)*facing*1.25,
|
||||||
|
moonHeight);
|
||||||
|
|
||||||
|
mRendering->getSkyManager()->setMasserDirection(masser);
|
||||||
|
mRendering->getSkyManager()->setSecundaDirection(secunda);
|
||||||
|
mRendering->getSkyManager()->masserEnable();
|
||||||
|
mRendering->getSkyManager()->secundaEnable();
|
||||||
|
|
||||||
|
float hour_fade;
|
||||||
|
if (mHour >= 7.f && mHour <= 14.f)
|
||||||
|
hour_fade = 1-(mHour-7)/3.f;
|
||||||
|
else if (mHour >= 14 && mHour <= 15.f)
|
||||||
|
hour_fade = mHour-14;
|
||||||
|
else
|
||||||
|
hour_fade = 1;
|
||||||
|
|
||||||
|
float secunda_angle_fade;
|
||||||
|
float masser_angle_fade;
|
||||||
|
float angle = moonHeight*90.f;
|
||||||
|
|
||||||
|
if (angle >= 30 && angle <= 50)
|
||||||
|
secunda_angle_fade = (angle-30)/20.f;
|
||||||
|
else if (angle <30)
|
||||||
|
secunda_angle_fade = 0.f;
|
||||||
|
else
|
||||||
|
secunda_angle_fade = 1.f;
|
||||||
|
|
||||||
|
if (angle >= 40 && angle <= 50)
|
||||||
|
masser_angle_fade = (angle-40)/10.f;
|
||||||
|
else if (angle <40)
|
||||||
|
masser_angle_fade = 0.f;
|
||||||
|
else
|
||||||
|
masser_angle_fade = 1.f;
|
||||||
|
|
||||||
|
masser_angle_fade *= hour_fade;
|
||||||
|
secunda_angle_fade *= hour_fade;
|
||||||
|
|
||||||
|
mRendering->getSkyManager()->setMasserFade(masser_angle_fade);
|
||||||
|
mRendering->getSkyManager()->setSecundaFade(secunda_angle_fade);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mRendering->getSkyManager()->masserDisable();
|
||||||
|
mRendering->getSkyManager()->secundaDisable();
|
||||||
|
}
|
||||||
|
|
||||||
if (mCurrentWeather == "thunderstorm" && mNextWeather == "")
|
if (mCurrentWeather == "thunderstorm" && mNextWeather == "")
|
||||||
{
|
{
|
||||||
if (mThunderFlash > 0)
|
if (mThunderFlash > 0)
|
||||||
|
@ -17,6 +17,7 @@ namespace MWWorld
|
|||||||
struct WeatherGlobals
|
struct WeatherGlobals
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
[Weather]
|
||||||
EnvReduceColor=255,255,255,255
|
EnvReduceColor=255,255,255,255
|
||||||
LerpCloseColor=037,046,048,255
|
LerpCloseColor=037,046,048,255
|
||||||
BumpFadeColor=230,239,255,255
|
BumpFadeColor=230,239,255,255
|
||||||
@ -66,6 +67,32 @@ namespace MWWorld
|
|||||||
Snow Gravity Scale=0.1
|
Snow Gravity Scale=0.1
|
||||||
Snow High Kill=700
|
Snow High Kill=700
|
||||||
Snow Low Kill=150
|
Snow Low Kill=150
|
||||||
|
|
||||||
|
|
||||||
|
[Moons]
|
||||||
|
Masser Size=94
|
||||||
|
Masser Fade In Start=14
|
||||||
|
Masser Fade In Finish=15
|
||||||
|
Masser Fade Out Start=7
|
||||||
|
Masser Fade Out Finish=10
|
||||||
|
Masser Axis Offset=35
|
||||||
|
Masser Speed=.5
|
||||||
|
Masser Daily Increment=1
|
||||||
|
Masser Fade Start Angle=50
|
||||||
|
Masser Fade End Angle=40
|
||||||
|
Masser Moon Shadow Early Fade Angle=0.5
|
||||||
|
Secunda Size=40
|
||||||
|
Secunda Fade In Start=14
|
||||||
|
Secunda Fade In Finish=15
|
||||||
|
Secunda Fade Out Start=7
|
||||||
|
Secunda Fade Out Finish=10
|
||||||
|
Secunda Axis Offset=50
|
||||||
|
Secunda Speed=.6
|
||||||
|
Secunda Daily Increment=1.2
|
||||||
|
Secunda Fade Start Angle=50
|
||||||
|
Secunda Fade End Angle=30
|
||||||
|
Secunda Moon Shadow Early Fade Angle=0.5
|
||||||
|
Script Color=255,20,20
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const float mSunriseTime = 8;
|
static const float mSunriseTime = 8;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user