mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:45:34 +00:00
Light magic effect
Notable change compared to the old (Ogre) effect: uses the ambient instead of diffuse term (Fixes #2364)
This commit is contained in:
parent
631cec7304
commit
6724585777
2 changed files with 40 additions and 1 deletions
|
@ -267,6 +267,8 @@ namespace MWRender
|
|||
|
||||
Animation::~Animation()
|
||||
{
|
||||
setLightEffect(0.f);
|
||||
|
||||
if (mObjectRoot)
|
||||
mInsert->removeChild(mObjectRoot);
|
||||
}
|
||||
|
@ -1224,6 +1226,36 @@ namespace MWRender
|
|||
return found->second;
|
||||
}
|
||||
|
||||
void Animation::setLightEffect(float effect)
|
||||
{
|
||||
if (effect == 0)
|
||||
{
|
||||
if (mGlowLight)
|
||||
{
|
||||
mInsert->removeChild(mGlowLight);
|
||||
mGlowLight = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mGlowLight)
|
||||
{
|
||||
mGlowLight = new SceneUtil::LightSource;
|
||||
mGlowLight->setLight(new osg::Light);
|
||||
osg::Light* light = mGlowLight->getLight();
|
||||
light->setDiffuse(osg::Vec4f(0,0,0,0));
|
||||
light->setSpecular(osg::Vec4f(0,0,0,0));
|
||||
light->setAmbient(osg::Vec4f(1.5f,1.5f,1.5f,1.f));
|
||||
mInsert->addChild(mGlowLight);
|
||||
}
|
||||
|
||||
effect += 3;
|
||||
osg::Light* light = mGlowLight->getLight();
|
||||
mGlowLight->setRadius(effect * 66.f);
|
||||
light->setLinearAttenuation(0.5f/effect);
|
||||
}
|
||||
}
|
||||
|
||||
void Animation::addControllers()
|
||||
{
|
||||
mHeadController = NULL;
|
||||
|
|
|
@ -21,6 +21,11 @@ namespace NifOsg
|
|||
class KeyframeController;
|
||||
}
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
class LightSource;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
|
||||
|
@ -202,6 +207,8 @@ protected:
|
|||
float mHeadYawRadians;
|
||||
float mHeadPitchRadians;
|
||||
|
||||
osg::ref_ptr<SceneUtil::LightSource> mGlowLight;
|
||||
|
||||
/* Sets the appropriate animations on the bone groups based on priority.
|
||||
*/
|
||||
void resetActiveGroups();
|
||||
|
@ -377,7 +384,7 @@ public:
|
|||
// TODO: move outside of this class
|
||||
/// Makes this object glow, by placing a Light in its center.
|
||||
/// @param effect Controls the radius and intensity of the light.
|
||||
virtual void setLightEffect(float effect) {}
|
||||
virtual void setLightEffect(float effect);
|
||||
|
||||
virtual void setHeadPitch(float pitchRadians);
|
||||
virtual void setHeadYaw(float yawRadians);
|
||||
|
|
Loading…
Reference in a new issue