|
|
|
@ -1199,66 +1199,62 @@ namespace MWRender
|
|
|
|
|
glowColor.y() = effect->mData.mGreen / 255.f;
|
|
|
|
|
glowColor.z() = effect->mData.mBlue / 255.f;
|
|
|
|
|
|
|
|
|
|
if (!mGlowUpdater) // If there is no glow on object
|
|
|
|
|
addGlow(mObjectRoot, glowColor, 1.5); // Glow length measured from original engine as about 1.5 seconds
|
|
|
|
|
if (!mGlowUpdater || (mGlowUpdater->isDone() || (mGlowUpdater->isPermanentGlowUpdater() == true)))
|
|
|
|
|
{
|
|
|
|
|
if (mGlowUpdater && mGlowUpdater->isDone())
|
|
|
|
|
mObjectRoot->removeUpdateCallback(mGlowUpdater);
|
|
|
|
|
|
|
|
|
|
else if (mGlowUpdater->isDone() || (mGlowUpdater->isPermanentGlowUpdater() == true))
|
|
|
|
|
addGlow(mObjectRoot, glowColor, 1.5);
|
|
|
|
|
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
|
|
|
|
|
{
|
|
|
|
|
mGlowUpdater->setColor(glowColor);
|
|
|
|
|
mGlowUpdater->setDuration(1.5); // Glow length measured from original engine as about 1.5 seconds
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
addGlow(mObjectRoot, glowColor, 1.5);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Animation::addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor, float glowDuration)
|
|
|
|
|
{
|
|
|
|
|
if (mGlowUpdater && mGlowUpdater->isDone())
|
|
|
|
|
node->removeUpdateCallback(mGlowUpdater);
|
|
|
|
|
{
|
|
|
|
|
std::vector<osg::ref_ptr<osg::Texture2D> > textures;
|
|
|
|
|
for (int i=0; i<32; ++i)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream stream;
|
|
|
|
|
stream << "textures/magicitem/caust";
|
|
|
|
|
stream << std::setw(2);
|
|
|
|
|
stream << std::setfill('0');
|
|
|
|
|
stream << i;
|
|
|
|
|
stream << ".dds";
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Image> image = mResourceSystem->getImageManager()->getImage(stream.str());
|
|
|
|
|
osg::ref_ptr<osg::Texture2D> tex (new osg::Texture2D(image));
|
|
|
|
|
tex->setName("envMap");
|
|
|
|
|
tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT);
|
|
|
|
|
tex->setWrap(osg::Texture::WRAP_T, osg::Texture2D::REPEAT);
|
|
|
|
|
mResourceSystem->getSceneManager()->applyFilterSettings(tex);
|
|
|
|
|
textures.push_back(tex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream stream;
|
|
|
|
|
stream << "textures/magicitem/caust";
|
|
|
|
|
stream << std::setw(2);
|
|
|
|
|
stream << std::setfill('0');
|
|
|
|
|
stream << i;
|
|
|
|
|
stream << ".dds";
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Image> image = mResourceSystem->getImageManager()->getImage(stream.str());
|
|
|
|
|
osg::ref_ptr<osg::Texture2D> tex (new osg::Texture2D(image));
|
|
|
|
|
tex->setName("envMap");
|
|
|
|
|
tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT);
|
|
|
|
|
tex->setWrap(osg::Texture::WRAP_T, osg::Texture2D::REPEAT);
|
|
|
|
|
mResourceSystem->getSceneManager()->applyFilterSettings(tex);
|
|
|
|
|
textures.push_back(tex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<GlowUpdater> glowUpdater = new GlowUpdater(texUnit, glowColor, textures, node, glowDuration, mResourceSystem);
|
|
|
|
|
mGlowUpdater = glowUpdater;
|
|
|
|
|
node->addUpdateCallback(glowUpdater);
|
|
|
|
|
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;
|
|
|
|
|
if (!node->getStateSet())
|
|
|
|
|
writableStateSet = node->getOrCreateStateSet();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
writableStateSet = osg::clone(node->getStateSet(), osg::CopyOp::SHALLOW_COPY);
|
|
|
|
|
node->setStateSet(writableStateSet);
|
|
|
|
|
}
|
|
|
|
|
writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON);
|
|
|
|
|
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
|
|
|
|
|
mResourceSystem->getSceneManager()->recreateShaders(node);
|
|
|
|
|
// set a texture now so that the ShaderVisitor can find it
|
|
|
|
|
osg::ref_ptr<osg::StateSet> writableStateSet = NULL;
|
|
|
|
|
if (!node->getStateSet())
|
|
|
|
|
writableStateSet = node->getOrCreateStateSet();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
writableStateSet = osg::clone(node->getStateSet(), osg::CopyOp::SHALLOW_COPY);
|
|
|
|
|
node->setStateSet(writableStateSet);
|
|
|
|
|
}
|
|
|
|
|
writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON);
|
|
|
|
|
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
|
|
|
|
|
mResourceSystem->getSceneManager()->recreateShaders(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Should not be here
|
|
|
|
|