|
|
|
@ -17,7 +17,7 @@
|
|
|
|
|
|
|
|
|
|
using namespace MWRender;
|
|
|
|
|
|
|
|
|
|
// These are the Morrowind.ini defaults
|
|
|
|
|
/// \todo Replace these, once fallback values from the ini file are available.
|
|
|
|
|
float Objects::lightLinearValue = 3;
|
|
|
|
|
float Objects::lightLinearRadiusMult = 1;
|
|
|
|
|
|
|
|
|
@ -31,7 +31,6 @@ int Objects::uniqueID = 0;
|
|
|
|
|
|
|
|
|
|
void Objects::clearSceneNode (Ogre::SceneNode *node)
|
|
|
|
|
{
|
|
|
|
|
/// \todo This should probably be moved into OpenEngine at some point.
|
|
|
|
|
for (int i=node->numAttachedObjects()-1; i>=0; --i)
|
|
|
|
|
{
|
|
|
|
|
Ogre::MovableObject *object = node->getAttachedObject (i);
|
|
|
|
@ -374,20 +373,17 @@ void Objects::disableLights()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace pulse
|
|
|
|
|
namespace MWRender
|
|
|
|
|
{
|
|
|
|
|
static float frequency (float x)
|
|
|
|
|
namespace Pulse
|
|
|
|
|
{
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float amplitude (float phase)
|
|
|
|
|
{
|
|
|
|
|
return sin (phase);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace flicker
|
|
|
|
|
namespace Flicker
|
|
|
|
|
{
|
|
|
|
|
static const float fa = 0.785398f;
|
|
|
|
|
static const float fb = 1.17024f;
|
|
|
|
@ -415,6 +411,7 @@ namespace flicker
|
|
|
|
|
return v * s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Objects::update(const float dt)
|
|
|
|
|
{
|
|
|
|
@ -425,7 +422,6 @@ void Objects::update(const float dt)
|
|
|
|
|
{
|
|
|
|
|
Ogre::Light* light = mMwRoot->getCreator()->getLight(it->name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float brightness;
|
|
|
|
|
float cycle_time;
|
|
|
|
|
float time_distortion;
|
|
|
|
@ -438,8 +434,8 @@ void Objects::update(const float dt)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cycle_time = 500.0f;
|
|
|
|
|
it->phase = fmod (it->phase + dt, flicker::phase_wavelength);
|
|
|
|
|
time_distortion = flicker::frequency (it->phase);
|
|
|
|
|
it->phase = fmod (it->phase + dt, Flicker::phase_wavelength);
|
|
|
|
|
time_distortion = Flicker::frequency (it->phase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it->time += it->dir*dt*time_distortion;
|
|
|
|
@ -461,23 +457,23 @@ void Objects::update(const float dt)
|
|
|
|
|
if (it->type == LT_Normal)
|
|
|
|
|
{
|
|
|
|
|
// Less than 1/255 light modifier for a constant light:
|
|
|
|
|
brightness = (const float)(1.0 + flicker::amplitude(it->time*slow) / 255.0 );
|
|
|
|
|
brightness = (const float)(1.0 + Flicker::amplitude(it->time*slow) / 255.0 );
|
|
|
|
|
}
|
|
|
|
|
else if (it->type == LT_Flicker)
|
|
|
|
|
{
|
|
|
|
|
brightness = (const float)(0.75 + flicker::amplitude(it->time*fast) * 0.25);
|
|
|
|
|
brightness = (const float)(0.75 + Flicker::amplitude(it->time*fast) * 0.25);
|
|
|
|
|
}
|
|
|
|
|
else if (it->type == LT_FlickerSlow)
|
|
|
|
|
{
|
|
|
|
|
brightness = (const float)(0.75 + flicker::amplitude(it->time*slow) * 0.25);
|
|
|
|
|
brightness = (const float)(0.75 + Flicker::amplitude(it->time*slow) * 0.25);
|
|
|
|
|
}
|
|
|
|
|
else if (it->type == LT_Pulse)
|
|
|
|
|
{
|
|
|
|
|
brightness = (const float)(1.0 + pulse::amplitude (it->time*fast) * 0.25);
|
|
|
|
|
brightness = (const float)(1.0 + Pulse::amplitude (it->time*fast) * 0.25);
|
|
|
|
|
}
|
|
|
|
|
else if (it->type == LT_PulseSlow)
|
|
|
|
|
{
|
|
|
|
|
brightness = (const float)(1.0 + pulse::amplitude (it->time*slow) * 0.25);
|
|
|
|
|
brightness = (const float)(1.0 + Pulse::amplitude (it->time*slow) * 0.25);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
assert(0 && "Invalid light type");
|
|
|
|
@ -506,8 +502,7 @@ void Objects::rebuildStaticGeometry()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Objects::updateObjectCell(const MWWorld::Ptr &ptr)
|
|
|
|
|
void Objects::updateObjectCell(const MWWorld::Ptr &ptr)
|
|
|
|
|
{
|
|
|
|
|
Ogre::SceneNode *node;
|
|
|
|
|
MWWorld::CellStore *newCell = ptr.getCell();
|
|
|
|
|