|
|
|
@ -1182,8 +1182,8 @@ namespace MWRender
|
|
|
|
|
int mLowestUnusedTexUnit;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void Animation::addSpellCastGlow(const ESM::MagicEffect *effect){
|
|
|
|
|
|
|
|
|
|
void Animation::addSpellCastGlow(const ESM::MagicEffect *effect)
|
|
|
|
|
{
|
|
|
|
|
osg::Vec4f glowColor(1,1,1,1);
|
|
|
|
|
glowColor.x() = effect->mData.mRed / 255.f;
|
|
|
|
|
glowColor.y() = effect->mData.mGreen / 255.f;
|
|
|
|
@ -1197,6 +1197,20 @@ namespace MWRender
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Animation::addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor, float glowDuration)
|
|
|
|
|
{
|
|
|
|
|
if (mGlowUpdater && mGlowUpdater->isDone())
|
|
|
|
|
node->removeUpdateCallback(mGlowUpdater);
|
|
|
|
|
|
|
|
|
|
FindLowestUnusedTexUnitVisitor findLowestUnusedTexUnitVisitor;
|
|
|
|
|
node->accept(findLowestUnusedTexUnitVisitor);
|
|
|
|
|
int texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit;
|
|
|
|
|
|
|
|
|
|
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
|
|
|
|
|
{
|
|
|
|
|
mGlowUpdater->setColor(glowColor);
|
|
|
|
|
mGlowUpdater->setDuration(glowDuration);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
std::vector<osg::ref_ptr<osg::Texture2D> > textures;
|
|
|
|
|
for (int i=0; i<32; ++i)
|
|
|
|
@ -1217,24 +1231,10 @@ namespace MWRender
|
|
|
|
|
textures.push_back(tex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mGlowUpdater && mGlowUpdater->isDone())
|
|
|
|
|
node->removeUpdateCallback(mGlowUpdater);
|
|
|
|
|
|
|
|
|
|
FindLowestUnusedTexUnitVisitor findLowestUnusedTexUnitVisitor;
|
|
|
|
|
node->accept(findLowestUnusedTexUnitVisitor);
|
|
|
|
|
int texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit;
|
|
|
|
|
|
|
|
|
|
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
|
|
|
|
|
{
|
|
|
|
|
mGlowUpdater->setColor(glowColor);
|
|
|
|
|
mGlowUpdater->setDuration(glowDuration);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
osg::ref_ptr<GlowUpdater> glowUpdater = new GlowUpdater(texUnit, glowColor, textures, node, glowDuration, mResourceSystem);
|
|
|
|
|
mGlowUpdater = glowUpdater;
|
|
|
|
|
node->addUpdateCallback(glowUpdater);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set a texture now so that the ShaderVisitor can find it
|
|
|
|
|
osg::ref_ptr<osg::StateSet> writableStateSet = NULL;
|
|
|
|
@ -1247,9 +1247,9 @@ namespace MWRender
|
|
|
|
|
}
|
|
|
|
|
writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON);
|
|
|
|
|
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
|
|
|
|
|
|
|
|
|
|
mResourceSystem->getSceneManager()->recreateShaders(node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Should not be here
|
|
|
|
|
osg::Vec4f Animation::getEnchantmentColor(const MWWorld::ConstPtr& item) const
|
|
|
|
|