1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:23:51 +00:00

Add an incomplete implementation of SayAnimationValue (lip animation)

This commit is contained in:
scrawl 2013-12-07 14:11:06 +01:00
parent c5e543b91b
commit bb70deabb1
2 changed files with 30 additions and 2 deletions

View file

@ -59,6 +59,15 @@ std::string getVampireHead(const std::string& race, bool female)
namespace MWRender namespace MWRender
{ {
float SayAnimationValue::getValue() const
{
if (MWBase::Environment::get().getSoundManager()->sayDone(mReference))
return 0;
else
// TODO: Use the loudness of the currently playing sound
return 1;
}
static NpcAnimation::PartBoneMap createPartListMap() static NpcAnimation::PartBoneMap createPartListMap()
{ {
NpcAnimation::PartBoneMap result; NpcAnimation::PartBoneMap result;
@ -115,6 +124,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int v
{ {
mNpc = mPtr.get<ESM::NPC>()->mBase; mNpc = mPtr.get<ESM::NPC>()->mBase;
mSayAnimationValue = Ogre::SharedPtr<SayAnimationValue>(new SayAnimationValue(mPtr));
for(size_t i = 0;i < ESM::PRT_Count;i++) for(size_t i = 0;i < ESM::PRT_Count;i++)
{ {
mPartslots[i] = -1; //each slot is empty mPartslots[i] = -1; //each slot is empty
@ -558,15 +569,18 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
} }
// TODO: // TODO:
// type == ESM::PRT_Head should get an animation source based on the current output of
// the actor's 'say' sound (0 = silent, 1 = loud?).
// type == ESM::PRT_Weapon should get an animation source based on the current offset // type == ESM::PRT_Weapon should get an animation source based on the current offset
// of the weapon attack animation (from its beginning, or start marker?) // of the weapon attack animation (from its beginning, or start marker?)
std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(mObjectParts[type].mControllers.begin()); std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(mObjectParts[type].mControllers.begin());
for(;ctrl != mObjectParts[type].mControllers.end();ctrl++) for(;ctrl != mObjectParts[type].mControllers.end();ctrl++)
{ {
if(ctrl->getSource().isNull()) if(ctrl->getSource().isNull())
{
ctrl->setSource(mNullAnimationValuePtr); ctrl->setSource(mNullAnimationValuePtr);
if (type == ESM::PRT_Head)
ctrl->setSource(mSayAnimationValue);
}
} }
return true; return true;

View file

@ -13,6 +13,18 @@ namespace ESM
namespace MWRender namespace MWRender
{ {
class SayAnimationValue : public Ogre::ControllerValue<Ogre::Real>
{
private:
MWWorld::Ptr mReference;
public:
SayAnimationValue(MWWorld::Ptr reference) : mReference(reference) {}
virtual Ogre::Real getValue() const;
virtual void setValue(Ogre::Real value)
{ }
};
class NpcAnimation : public Animation, public MWWorld::InventoryStoreListener class NpcAnimation : public Animation, public MWWorld::InventoryStoreListener
{ {
public: public:
@ -50,6 +62,8 @@ private:
Ogre::Vector3 mFirstPersonOffset; Ogre::Vector3 mFirstPersonOffset;
Ogre::SharedPtr<SayAnimationValue> mSayAnimationValue;
void updateNpcBase(); void updateNpcBase();
NifOgre::ObjectList insertBoundedPart(const std::string &model, int group, const std::string &bonename, NifOgre::ObjectList insertBoundedPart(const std::string &model, int group, const std::string &bonename,