mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:15:31 +00:00
Port HeadAnimationTime
This commit is contained in:
parent
f7d2a28930
commit
c924e64047
2 changed files with 48 additions and 41 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "npcanimation.hpp"
|
#include "npcanimation.hpp"
|
||||||
|
|
||||||
|
#include <osg/UserDataContainer>
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <openengine/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/misc/resourcehelpers.hpp>
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
|
@ -8,6 +10,8 @@
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/sceneutil/attach.hpp>
|
#include <components/sceneutil/attach.hpp>
|
||||||
|
|
||||||
|
#include <components/nifosg/nifloader.hpp> // TextKeyMapHolder
|
||||||
|
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
@ -67,7 +71,6 @@ std::string getVampireHead(const std::string& race, bool female)
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
|
||||||
HeadAnimationTime::HeadAnimationTime(MWWorld::Ptr reference)
|
HeadAnimationTime::HeadAnimationTime(MWWorld::Ptr reference)
|
||||||
: mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mValue(0), mEnabled(true)
|
: mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mValue(0), mEnabled(true)
|
||||||
{
|
{
|
||||||
|
@ -107,13 +110,14 @@ void HeadAnimationTime::update(float dt)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// FIXME: would be nice to hold on to the SoundPtr so we don't have to retrieve it every frame
|
||||||
mValue = mTalkStart +
|
mValue = mTalkStart +
|
||||||
(mTalkStop - mTalkStart) *
|
(mTalkStop - mTalkStart) *
|
||||||
std::min(1.f, MWBase::Environment::get().getSoundManager()->getSaySoundLoudness(mReference)*2); // Rescale a bit (most voices are not very loud)
|
std::min(1.f, MWBase::Environment::get().getSoundManager()->getSaySoundLoudness(mReference)*2); // Rescale a bit (most voices are not very loud)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float HeadAnimationTime::getValue() const
|
float HeadAnimationTime::getValue(osg::NodeVisitor*)
|
||||||
{
|
{
|
||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +141,6 @@ void HeadAnimationTime::setBlinkStop(float value)
|
||||||
{
|
{
|
||||||
mBlinkStop = value;
|
mBlinkStop = value;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
static NpcAnimation::PartBoneMap createPartListMap()
|
static NpcAnimation::PartBoneMap createPartListMap()
|
||||||
{
|
{
|
||||||
|
@ -196,7 +199,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> par
|
||||||
{
|
{
|
||||||
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
//mHeadAnimationTime = Ogre::SharedPtr<HeadAnimationTime>(new HeadAnimationTime(mPtr));
|
mHeadAnimationTime = boost::shared_ptr<HeadAnimationTime>(new HeadAnimationTime(mPtr));
|
||||||
//mWeaponAnimationTime = Ogre::SharedPtr<WeaponAnimationTime>(new WeaponAnimationTime(this));
|
//mWeaponAnimationTime = Ogre::SharedPtr<WeaponAnimationTime>(new WeaponAnimationTime(this));
|
||||||
|
|
||||||
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
||||||
|
@ -577,13 +580,13 @@ Animation::PartHolderPtr NpcAnimation::insertBoundedPart(const std::string& mode
|
||||||
return PartHolderPtr(new PartHolder(attached));
|
return PartHolderPtr(new PartHolder(attached));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
osg::Vec3f NpcAnimation::runAnimation(float timepassed)
|
||||||
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
|
||||||
{
|
{
|
||||||
Ogre::Vector3 ret = Animation::runAnimation(timepassed);
|
osg::Vec3f ret = Animation::runAnimation(timepassed);
|
||||||
|
|
||||||
mHeadAnimationTime->update(timepassed);
|
mHeadAnimationTime->update(timepassed);
|
||||||
|
|
||||||
|
/*
|
||||||
if (mSkelBase)
|
if (mSkelBase)
|
||||||
{
|
{
|
||||||
Ogre::SkeletonInstance *baseinst = mSkelBase->getSkeleton();
|
Ogre::SkeletonInstance *baseinst = mSkelBase->getSkeleton();
|
||||||
|
@ -625,10 +628,10 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
||||||
|
|
||||||
mObjectParts[i]->mSkelBase->getAllAnimationStates()->_notifyDirty();
|
mObjectParts[i]->mSkelBase->getAllAnimationStates()->_notifyDirty();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
void NpcAnimation::removeIndividualPart(ESM::PartReferenceType type)
|
void NpcAnimation::removeIndividualPart(ESM::PartReferenceType type)
|
||||||
{
|
{
|
||||||
|
@ -697,35 +700,44 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(mObjectParts[type]->mControllers.begin());
|
|
||||||
for(;ctrl != mObjectParts[type]->mControllers.end();++ctrl)
|
|
||||||
{
|
|
||||||
if(ctrl->getSource().isNull())
|
|
||||||
{
|
|
||||||
ctrl->setSource(mNullAnimationTimePtr);
|
|
||||||
|
|
||||||
if (type == ESM::PRT_Head)
|
boost::shared_ptr<SceneUtil::ControllerSource> src;
|
||||||
|
if (type == ESM::PRT_Head)
|
||||||
|
{
|
||||||
|
src = mHeadAnimationTime;
|
||||||
|
|
||||||
|
osg::Node* node = mObjectParts[type]->getNode();
|
||||||
|
if (node->getUserDataContainer())
|
||||||
|
{
|
||||||
|
for (unsigned int i=0; i<node->getUserDataContainer()->getNumUserObjects(); ++i)
|
||||||
{
|
{
|
||||||
ctrl->setSource(mHeadAnimationTime);
|
osg::Object* obj = node->getUserDataContainer()->getUserObject(i);
|
||||||
const NifOgre::TextKeyMap& keys = mObjectParts[type]->mTextKeys;
|
if (NifOsg::TextKeyMapHolder* keys = dynamic_cast<NifOsg::TextKeyMapHolder*>(obj))
|
||||||
for (NifOgre::TextKeyMap::const_iterator it = keys.begin(); it != keys.end(); ++it)
|
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual(it->second, "talk: start"))
|
for (NifOsg::TextKeyMap::const_iterator it = keys->mTextKeys.begin(); it != keys->mTextKeys.end(); ++it)
|
||||||
mHeadAnimationTime->setTalkStart(it->first);
|
{
|
||||||
if (Misc::StringUtils::ciEqual(it->second, "talk: stop"))
|
if (Misc::StringUtils::ciEqual(it->second, "talk: start"))
|
||||||
mHeadAnimationTime->setTalkStop(it->first);
|
mHeadAnimationTime->setTalkStart(it->first);
|
||||||
if (Misc::StringUtils::ciEqual(it->second, "blink: start"))
|
if (Misc::StringUtils::ciEqual(it->second, "talk: stop"))
|
||||||
mHeadAnimationTime->setBlinkStart(it->first);
|
mHeadAnimationTime->setTalkStop(it->first);
|
||||||
if (Misc::StringUtils::ciEqual(it->second, "blink: stop"))
|
if (Misc::StringUtils::ciEqual(it->second, "blink: start"))
|
||||||
mHeadAnimationTime->setBlinkStop(it->first);
|
mHeadAnimationTime->setBlinkStart(it->first);
|
||||||
|
if (Misc::StringUtils::ciEqual(it->second, "blink: stop"))
|
||||||
|
mHeadAnimationTime->setBlinkStop(it->first);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == ESM::PRT_Weapon)
|
|
||||||
ctrl->setSource(mWeaponAnimationTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
//else if (type == ESM::PRT_Weapon)
|
||||||
|
// src = mWeaponAnimationTime;
|
||||||
|
else
|
||||||
|
src.reset(new NullAnimationTime);
|
||||||
|
|
||||||
|
SceneUtil::AssignControllerSourcesVisitor assignVisitor(src);
|
||||||
|
mObjectParts[type]->getNode()->accept(assignVisitor);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -825,6 +837,7 @@ void NpcAnimation::showCarriedLeft(bool show)
|
||||||
if (addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
|
if (addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
|
||||||
mesh, !iter->getClass().getEnchantment(*iter).empty(), &glowColor))
|
mesh, !iter->getClass().getEnchantment(*iter).empty(), &glowColor))
|
||||||
{
|
{
|
||||||
|
// TODO
|
||||||
//if (iter->getTypeName() == typeid(ESM::Light).name())
|
//if (iter->getTypeName() == typeid(ESM::Light).name())
|
||||||
//addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], iter->get<ESM::Light>()->mBase);
|
//addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], iter->get<ESM::Light>()->mBase);
|
||||||
}
|
}
|
||||||
|
@ -863,13 +876,11 @@ void NpcAnimation::permanentEffectAdded(const ESM::MagicEffect *magicEffect, boo
|
||||||
|
|
||||||
if (!magicEffect->mHit.empty())
|
if (!magicEffect->mHit.empty())
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit);
|
const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit);
|
||||||
bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
|
bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
|
||||||
// Don't play particle VFX unless the effect is new or it should be looping.
|
// Don't play particle VFX unless the effect is new or it should be looping.
|
||||||
if (isNew || loop)
|
if (isNew || loop)
|
||||||
addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "");
|
addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "");
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -884,7 +895,7 @@ void NpcAnimation::setAlpha(float alpha)
|
||||||
|
|
||||||
void NpcAnimation::enableHeadAnimation(bool enable)
|
void NpcAnimation::enableHeadAnimation(bool enable)
|
||||||
{
|
{
|
||||||
//mHeadAnimationTime->setEnabled(enable);
|
mHeadAnimationTime->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::setWeaponGroup(const std::string &group)
|
void NpcAnimation::setWeaponGroup(const std::string &group)
|
||||||
|
|
|
@ -15,8 +15,7 @@ namespace ESM
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
class HeadAnimationTime : public SceneUtil::ControllerSource
|
||||||
class HeadAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
MWWorld::Ptr mReference;
|
MWWorld::Ptr mReference;
|
||||||
|
@ -44,11 +43,8 @@ public:
|
||||||
void setBlinkStart(float value);
|
void setBlinkStart(float value);
|
||||||
void setBlinkStop(float value);
|
void setBlinkStop(float value);
|
||||||
|
|
||||||
virtual Ogre::Real getValue() const;
|
virtual float getValue(osg::NodeVisitor* nv);
|
||||||
virtual void setValue(Ogre::Real value)
|
|
||||||
{ }
|
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
class NpcAnimation : public Animation, public WeaponAnimation, public MWWorld::InventoryStoreListener
|
class NpcAnimation : public Animation, public WeaponAnimation, public MWWorld::InventoryStoreListener
|
||||||
{
|
{
|
||||||
|
@ -96,7 +92,7 @@ private:
|
||||||
|
|
||||||
Ogre::Vector3 mFirstPersonOffset;
|
Ogre::Vector3 mFirstPersonOffset;
|
||||||
|
|
||||||
//Ogre::SharedPtr<HeadAnimationTime> mHeadAnimationTime;
|
boost::shared_ptr<HeadAnimationTime> mHeadAnimationTime;
|
||||||
//Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime;
|
//Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime;
|
||||||
|
|
||||||
float mAlpha;
|
float mAlpha;
|
||||||
|
@ -142,7 +138,7 @@ public:
|
||||||
|
|
||||||
virtual void setWeaponGroup(const std::string& group);
|
virtual void setWeaponGroup(const std::string& group);
|
||||||
|
|
||||||
//virtual Ogre::Vector3 runAnimation(float timepassed);
|
virtual osg::Vec3f runAnimation(float timepassed);
|
||||||
|
|
||||||
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
||||||
/// to indicate the facing orientation of the character.
|
/// to indicate the facing orientation of the character.
|
||||||
|
|
Loading…
Reference in a new issue