forked from teamnwah/openmw-tes3coop
Move setAlpha from NpcAnimation to Animation (Fixes #2917)
This commit is contained in:
parent
126960261f
commit
f8d4bc378f
4 changed files with 38 additions and 41 deletions
|
@ -9,6 +9,8 @@
|
||||||
#include <osg/ComputeBoundsVisitor>
|
#include <osg/ComputeBoundsVisitor>
|
||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
|
#include <osg/BlendFunc>
|
||||||
|
#include <osg/Material>
|
||||||
|
|
||||||
#include <osgParticle/ParticleSystem>
|
#include <osgParticle/ParticleSystem>
|
||||||
|
|
||||||
|
@ -292,6 +294,7 @@ namespace MWRender
|
||||||
, mTextKeyListener(NULL)
|
, mTextKeyListener(NULL)
|
||||||
, mHeadYawRadians(0.f)
|
, mHeadYawRadians(0.f)
|
||||||
, mHeadPitchRadians(0.f)
|
, mHeadPitchRadians(0.f)
|
||||||
|
, mAlpha(1.f)
|
||||||
{
|
{
|
||||||
for(size_t i = 0;i < sNumBlendMasks;i++)
|
for(size_t i = 0;i < sNumBlendMasks;i++)
|
||||||
mAnimationTimePtr[i].reset(new AnimationTime);
|
mAnimationTimePtr[i].reset(new AnimationTime);
|
||||||
|
@ -1247,6 +1250,37 @@ namespace MWRender
|
||||||
return found->second;
|
return found->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Animation::setAlpha(float alpha)
|
||||||
|
{
|
||||||
|
if (alpha == mAlpha)
|
||||||
|
return;
|
||||||
|
mAlpha = alpha;
|
||||||
|
|
||||||
|
if (alpha != 1.f)
|
||||||
|
{
|
||||||
|
osg::StateSet* stateset (new osg::StateSet);
|
||||||
|
|
||||||
|
osg::BlendFunc* blendfunc (new osg::BlendFunc);
|
||||||
|
stateset->setAttributeAndModes(blendfunc, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
|
||||||
|
|
||||||
|
// FIXME: overriding diffuse/ambient/emissive colors
|
||||||
|
osg::Material* material (new osg::Material);
|
||||||
|
material->setColorMode(osg::Material::OFF);
|
||||||
|
material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4f(1,1,1,alpha));
|
||||||
|
material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4f(1,1,1,1));
|
||||||
|
stateset->setAttributeAndModes(material, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
|
||||||
|
|
||||||
|
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||||
|
stateset->setRenderBinMode(osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
|
||||||
|
stateset->setNestRenderBins(false);
|
||||||
|
mObjectRoot->setStateSet(stateset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mObjectRoot->setStateSet(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Animation::setLightEffect(float effect)
|
void Animation::setLightEffect(float effect)
|
||||||
{
|
{
|
||||||
if (effect == 0)
|
if (effect == 0)
|
||||||
|
|
|
@ -253,6 +253,8 @@ protected:
|
||||||
|
|
||||||
osg::ref_ptr<SceneUtil::LightSource> mGlowLight;
|
osg::ref_ptr<SceneUtil::LightSource> mGlowLight;
|
||||||
|
|
||||||
|
float mAlpha;
|
||||||
|
|
||||||
/* Sets the appropriate animations on the bone groups based on priority.
|
/* Sets the appropriate animations on the bone groups based on priority.
|
||||||
*/
|
*/
|
||||||
void resetActiveGroups();
|
void resetActiveGroups();
|
||||||
|
@ -419,7 +421,8 @@ public:
|
||||||
virtual void showCarriedLeft(bool show) {}
|
virtual void showCarriedLeft(bool show) {}
|
||||||
virtual void setWeaponGroup(const std::string& group) {}
|
virtual void setWeaponGroup(const std::string& group) {}
|
||||||
virtual void setVampire(bool vampire) {}
|
virtual void setVampire(bool vampire) {}
|
||||||
virtual void setAlpha(float alpha) {}
|
/// A value < 1 makes the animation translucent, 1.f = fully opaque
|
||||||
|
void setAlpha(float alpha);
|
||||||
virtual void setPitchFactor(float factor) {}
|
virtual void setPitchFactor(float factor) {}
|
||||||
virtual void attachArrow() {}
|
virtual void attachArrow() {}
|
||||||
virtual void releaseArrow(float attackStrength) {}
|
virtual void releaseArrow(float attackStrength) {}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
#include <osg/UserDataContainer>
|
#include <osg/UserDataContainer>
|
||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
#include <osg/BlendFunc>
|
|
||||||
#include <osg/Material>
|
|
||||||
|
|
||||||
#include <components/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
|
@ -278,7 +276,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> par
|
||||||
mShowWeapons(false),
|
mShowWeapons(false),
|
||||||
mShowCarriedLeft(true),
|
mShowCarriedLeft(true),
|
||||||
mNpcType(Type_Normal),
|
mNpcType(Type_Normal),
|
||||||
mAlpha(1.f),
|
|
||||||
mSoundsDisabled(disableSounds)
|
mSoundsDisabled(disableSounds)
|
||||||
{
|
{
|
||||||
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
||||||
|
@ -422,7 +419,6 @@ void NpcAnimation::updateParts()
|
||||||
if (!mObjectRoot.get())
|
if (!mObjectRoot.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mAlpha = 1.f;
|
|
||||||
const MWWorld::Class &cls = mPtr.getClass();
|
const MWWorld::Class &cls = mPtr.getClass();
|
||||||
|
|
||||||
NpcType curType = Type_Normal;
|
NpcType curType = Type_Normal;
|
||||||
|
@ -902,7 +898,6 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
||||||
{
|
{
|
||||||
removeIndividualPart(ESM::PRT_Weapon);
|
removeIndividualPart(ESM::PRT_Weapon);
|
||||||
}
|
}
|
||||||
mAlpha = 1.f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::showCarriedLeft(bool show)
|
void NpcAnimation::showCarriedLeft(bool show)
|
||||||
|
@ -988,37 +983,6 @@ void NpcAnimation::permanentEffectAdded(const ESM::MagicEffect *magicEffect, boo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::setAlpha(float alpha)
|
|
||||||
{
|
|
||||||
if (alpha == mAlpha)
|
|
||||||
return;
|
|
||||||
mAlpha = alpha;
|
|
||||||
|
|
||||||
if (alpha != 1.f)
|
|
||||||
{
|
|
||||||
osg::StateSet* stateset (new osg::StateSet);
|
|
||||||
|
|
||||||
osg::BlendFunc* blendfunc (new osg::BlendFunc);
|
|
||||||
stateset->setAttributeAndModes(blendfunc, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
|
|
||||||
|
|
||||||
// FIXME: overriding diffuse/ambient/emissive colors
|
|
||||||
osg::Material* material (new osg::Material);
|
|
||||||
material->setColorMode(osg::Material::OFF);
|
|
||||||
material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4f(1,1,1,alpha));
|
|
||||||
material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4f(1,1,1,1));
|
|
||||||
stateset->setAttributeAndModes(material, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
|
|
||||||
|
|
||||||
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
|
||||||
stateset->setRenderBinMode(osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
|
|
||||||
stateset->setNestRenderBins(false);
|
|
||||||
mObjectRoot->setStateSet(stateset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mObjectRoot->setStateSet(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NpcAnimation::enableHeadAnimation(bool enable)
|
void NpcAnimation::enableHeadAnimation(bool enable)
|
||||||
{
|
{
|
||||||
mHeadAnimationTime->setEnabled(enable);
|
mHeadAnimationTime->setEnabled(enable);
|
||||||
|
|
|
@ -65,7 +65,6 @@ private:
|
||||||
boost::shared_ptr<HeadAnimationTime> mHeadAnimationTime;
|
boost::shared_ptr<HeadAnimationTime> mHeadAnimationTime;
|
||||||
boost::shared_ptr<WeaponAnimationTime> mWeaponAnimationTime;
|
boost::shared_ptr<WeaponAnimationTime> mWeaponAnimationTime;
|
||||||
|
|
||||||
float mAlpha;
|
|
||||||
bool mSoundsDisabled;
|
bool mSoundsDisabled;
|
||||||
|
|
||||||
void updateNpcBase();
|
void updateNpcBase();
|
||||||
|
@ -134,9 +133,6 @@ public:
|
||||||
/// Get the inventory slot that the given node path leads into, or -1 if not found.
|
/// Get the inventory slot that the given node path leads into, or -1 if not found.
|
||||||
int getSlot(const osg::NodePath& path) const;
|
int getSlot(const osg::NodePath& path) const;
|
||||||
|
|
||||||
/// Make the NPC only partially visible
|
|
||||||
virtual void setAlpha(float alpha);
|
|
||||||
|
|
||||||
virtual void setVampire(bool vampire);
|
virtual void setVampire(bool vampire);
|
||||||
|
|
||||||
/// Set a translation offset (in object root space) to apply to meshes when in first person mode.
|
/// Set a translation offset (in object root space) to apply to meshes when in first person mode.
|
||||||
|
|
Loading…
Reference in a new issue