forked from teamnwah/openmw-tes3coop
Renamed AnimationValue to AnimationTime
This commit is contained in:
parent
11394d83c5
commit
240d96a0f1
4 changed files with 32 additions and 31 deletions
|
@ -30,7 +30,7 @@
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
Ogre::Real Animation::AnimationValue::getValue() const
|
Ogre::Real Animation::AnimationTime::getValue() const
|
||||||
{
|
{
|
||||||
AnimStateMap::const_iterator iter = mAnimation->mStates.find(mAnimationName);
|
AnimStateMap::const_iterator iter = mAnimation->mStates.find(mAnimationName);
|
||||||
if(iter != mAnimation->mStates.end())
|
if(iter != mAnimation->mStates.end())
|
||||||
|
@ -38,16 +38,16 @@ Ogre::Real Animation::AnimationValue::getValue() const
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::AnimationValue::setValue(Ogre::Real)
|
void Animation::AnimationTime::setValue(Ogre::Real)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::Real Animation::EffectAnimationValue::getValue() const
|
Ogre::Real Animation::EffectAnimationTime::getValue() const
|
||||||
{
|
{
|
||||||
return mTime;
|
return mTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::EffectAnimationValue::setValue(Ogre::Real)
|
void Animation::EffectAnimationTime::setValue(Ogre::Real)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,10 +60,10 @@ Animation::Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node)
|
||||||
, mNonAccumRoot(NULL)
|
, mNonAccumRoot(NULL)
|
||||||
, mNonAccumCtrl(NULL)
|
, mNonAccumCtrl(NULL)
|
||||||
, mAccumulate(0.0f)
|
, mAccumulate(0.0f)
|
||||||
, mNullAnimationValuePtr(OGRE_NEW NullAnimationValue)
|
, mNullAnimationTimePtr(OGRE_NEW NullAnimationTime)
|
||||||
{
|
{
|
||||||
for(size_t i = 0;i < sNumGroups;i++)
|
for(size_t i = 0;i < sNumGroups;i++)
|
||||||
mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this));
|
mAnimationTimePtr[i].bind(OGRE_NEW AnimationTime(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::~Animation()
|
Animation::~Animation()
|
||||||
|
@ -139,7 +139,7 @@ void Animation::setObjectRoot(const std::string &model, bool baseonly)
|
||||||
for(size_t i = 0;i < mObjectRoot->mControllers.size();i++)
|
for(size_t i = 0;i < mObjectRoot->mControllers.size();i++)
|
||||||
{
|
{
|
||||||
if(mObjectRoot->mControllers[i].getSource().isNull())
|
if(mObjectRoot->mControllers[i].getSource().isNull())
|
||||||
mObjectRoot->mControllers[i].setSource(mAnimationValuePtr[0]);
|
mObjectRoot->mControllers[i].setSource(mAnimationTimePtr[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ void Animation::addAnimSource(const std::string &model)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrls[i].setSource(mAnimationValuePtr[grp]);
|
ctrls[i].setSource(mAnimationTimePtr[grp]);
|
||||||
grpctrls[grp].push_back(ctrls[i]);
|
grpctrls[grp].push_back(ctrls[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ void Animation::clearAnimSources()
|
||||||
mStates.clear();
|
mStates.clear();
|
||||||
|
|
||||||
for(size_t i = 0;i < sNumGroups;i++)
|
for(size_t i = 0;i < sNumGroups;i++)
|
||||||
mAnimationValuePtr[i]->setAnimName(std::string());
|
mAnimationTimePtr[i]->setAnimName(std::string());
|
||||||
|
|
||||||
mNonAccumCtrl = NULL;
|
mNonAccumCtrl = NULL;
|
||||||
|
|
||||||
|
@ -789,7 +789,7 @@ void Animation::resetActiveGroups()
|
||||||
active = state;
|
active = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
mAnimationValuePtr[grp]->setAnimName((active == mStates.end()) ?
|
mAnimationTimePtr[grp]->setAnimName((active == mStates.end()) ?
|
||||||
std::string() : active->first);
|
std::string() : active->first);
|
||||||
}
|
}
|
||||||
mNonAccumCtrl = NULL;
|
mNonAccumCtrl = NULL;
|
||||||
|
@ -797,7 +797,7 @@ void Animation::resetActiveGroups()
|
||||||
if(!mNonAccumRoot || mAccumulate == Ogre::Vector3(0.0f))
|
if(!mNonAccumRoot || mAccumulate == Ogre::Vector3(0.0f))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AnimStateMap::const_iterator state = mStates.find(mAnimationValuePtr[0]->getAnimName());
|
AnimStateMap::const_iterator state = mStates.find(mAnimationTimePtr[0]->getAnimName());
|
||||||
if(state == mStates.end())
|
if(state == mStates.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -869,13 +869,13 @@ Ogre::Vector3 Animation::runAnimation(float duration)
|
||||||
targetTime = state.mTime + timepassed;
|
targetTime = state.mTime + timepassed;
|
||||||
if(textkey == textkeys.end() || textkey->first > targetTime)
|
if(textkey == textkeys.end() || textkey->first > targetTime)
|
||||||
{
|
{
|
||||||
if(mNonAccumCtrl && stateiter->first == mAnimationValuePtr[0]->getAnimName())
|
if(mNonAccumCtrl && stateiter->first == mAnimationTimePtr[0]->getAnimName())
|
||||||
updatePosition(state.mTime, targetTime, movement);
|
updatePosition(state.mTime, targetTime, movement);
|
||||||
state.mTime = std::min(targetTime, state.mStopTime);
|
state.mTime = std::min(targetTime, state.mStopTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(mNonAccumCtrl && stateiter->first == mAnimationValuePtr[0]->getAnimName())
|
if(mNonAccumCtrl && stateiter->first == mAnimationTimePtr[0]->getAnimName())
|
||||||
updatePosition(state.mTime, textkey->first, movement);
|
updatePosition(state.mTime, textkey->first, movement);
|
||||||
state.mTime = textkey->first;
|
state.mTime = textkey->first;
|
||||||
}
|
}
|
||||||
|
@ -926,7 +926,7 @@ Ogre::Vector3 Animation::runAnimation(float duration)
|
||||||
// Apply group controllers
|
// Apply group controllers
|
||||||
for(size_t grp = 0;grp < sNumGroups;grp++)
|
for(size_t grp = 0;grp < sNumGroups;grp++)
|
||||||
{
|
{
|
||||||
const std::string &name = mAnimationValuePtr[grp]->getAnimName();
|
const std::string &name = mAnimationTimePtr[grp]->getAnimName();
|
||||||
if(!name.empty() && (stateiter=mStates.find(name)) != mStates.end())
|
if(!name.empty() && (stateiter=mStates.find(name)) != mStates.end())
|
||||||
{
|
{
|
||||||
const Ogre::SharedPtr<AnimSource> &src = stateiter->second.mSource;
|
const Ogre::SharedPtr<AnimSource> &src = stateiter->second.mSource;
|
||||||
|
@ -1052,7 +1052,7 @@ void Animation::addEffect(const std::string &model, int effectId, bool loop, con
|
||||||
for(size_t i = 0;i < params.mObjects->mControllers.size();i++)
|
for(size_t i = 0;i < params.mObjects->mControllers.size();i++)
|
||||||
{
|
{
|
||||||
if(params.mObjects->mControllers[i].getSource().isNull())
|
if(params.mObjects->mControllers[i].getSource().isNull())
|
||||||
params.mObjects->mControllers[i].setSource(Ogre::SharedPtr<EffectAnimationValue> (new EffectAnimationValue()));
|
params.mObjects->mControllers[i].setSource(Ogre::SharedPtr<EffectAnimationTime> (new EffectAnimationTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!texture.empty())
|
if (!texture.empty())
|
||||||
|
@ -1110,7 +1110,7 @@ void Animation::updateEffects(float duration)
|
||||||
NifOgre::ObjectScenePtr objects = it->mObjects;
|
NifOgre::ObjectScenePtr objects = it->mObjects;
|
||||||
for(size_t i = 0; i < objects->mControllers.size() ;i++)
|
for(size_t i = 0; i < objects->mControllers.size() ;i++)
|
||||||
{
|
{
|
||||||
EffectAnimationValue* value = dynamic_cast<EffectAnimationValue*>(objects->mControllers[i].getSource().get());
|
EffectAnimationTime* value = dynamic_cast<EffectAnimationTime*>(objects->mControllers[i].getSource().get());
|
||||||
if (value)
|
if (value)
|
||||||
value->addTime(duration);
|
value->addTime(duration);
|
||||||
|
|
||||||
|
@ -1125,7 +1125,7 @@ void Animation::updateEffects(float duration)
|
||||||
float remainder = objects->mControllers[0].getSource()->getValue() - objects->mMaxControllerLength;
|
float remainder = objects->mControllers[0].getSource()->getValue() - objects->mMaxControllerLength;
|
||||||
for(size_t i = 0; i < objects->mControllers.size() ;i++)
|
for(size_t i = 0; i < objects->mControllers.size() ;i++)
|
||||||
{
|
{
|
||||||
EffectAnimationValue* value = dynamic_cast<EffectAnimationValue*>(objects->mControllers[i].getSource().get());
|
EffectAnimationTime* value = dynamic_cast<EffectAnimationTime*>(objects->mControllers[i].getSource().get());
|
||||||
if (value)
|
if (value)
|
||||||
value->resetTime(remainder);
|
value->resetTime(remainder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ protected:
|
||||||
/* This is the number of *discrete* groups. */
|
/* This is the number of *discrete* groups. */
|
||||||
static const size_t sNumGroups = 4;
|
static const size_t sNumGroups = 4;
|
||||||
|
|
||||||
class AnimationValue : public Ogre::ControllerValue<Ogre::Real>
|
class AnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Animation *mAnimation;
|
Animation *mAnimation;
|
||||||
std::string mAnimationName;
|
std::string mAnimationName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnimationValue(Animation *anim)
|
AnimationTime(Animation *anim)
|
||||||
: mAnimation(anim)
|
: mAnimation(anim)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -52,12 +52,12 @@ protected:
|
||||||
virtual void setValue(Ogre::Real value);
|
virtual void setValue(Ogre::Real value);
|
||||||
};
|
};
|
||||||
|
|
||||||
class EffectAnimationValue : public Ogre::ControllerValue<Ogre::Real>
|
class EffectAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
float mTime;
|
float mTime;
|
||||||
public:
|
public:
|
||||||
EffectAnimationValue() : mTime(0) { }
|
EffectAnimationTime() : mTime(0) { }
|
||||||
void addTime(float time) { mTime += time; }
|
void addTime(float time) { mTime += time; }
|
||||||
void resetTime(float value) { mTime = value; }
|
void resetTime(float value) { mTime = value; }
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class NullAnimationValue : public Ogre::ControllerValue<Ogre::Real>
|
class NullAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual Ogre::Real getValue() const
|
virtual Ogre::Real getValue() const
|
||||||
|
@ -134,8 +134,8 @@ protected:
|
||||||
|
|
||||||
AnimStateMap mStates;
|
AnimStateMap mStates;
|
||||||
|
|
||||||
Ogre::SharedPtr<AnimationValue> mAnimationValuePtr[sNumGroups];
|
Ogre::SharedPtr<AnimationTime> mAnimationTimePtr[sNumGroups];
|
||||||
Ogre::SharedPtr<NullAnimationValue> mNullAnimationValuePtr;
|
Ogre::SharedPtr<NullAnimationTime> mNullAnimationTimePtr;
|
||||||
|
|
||||||
ObjectAttachMap mAttachedObjects;
|
ObjectAttachMap mAttachedObjects;
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,9 @@ std::string getVampireHead(const std::string& race, bool female)
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
float SayAnimationValue::getValue() const
|
float HeadAnimationTime::getValue() const
|
||||||
{
|
{
|
||||||
|
// TODO: Handle eye blinking (time is in the text keys)
|
||||||
if (MWBase::Environment::get().getSoundManager()->sayDone(mReference))
|
if (MWBase::Environment::get().getSoundManager()->sayDone(mReference))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
|
@ -124,7 +125,7 @@ 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));
|
mHeadAnimationTime = Ogre::SharedPtr<HeadAnimationTime>(new HeadAnimationTime(mPtr));
|
||||||
|
|
||||||
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
||||||
{
|
{
|
||||||
|
@ -595,10 +596,10 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||||
{
|
{
|
||||||
if(ctrl->getSource().isNull())
|
if(ctrl->getSource().isNull())
|
||||||
{
|
{
|
||||||
ctrl->setSource(mNullAnimationValuePtr);
|
ctrl->setSource(mNullAnimationTimePtr);
|
||||||
|
|
||||||
if (type == ESM::PRT_Head)
|
if (type == ESM::PRT_Head)
|
||||||
ctrl->setSource(mSayAnimationValue);
|
ctrl->setSource(mHeadAnimationTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@ namespace ESM
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
class SayAnimationValue : public Ogre::ControllerValue<Ogre::Real>
|
class HeadAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
MWWorld::Ptr mReference;
|
MWWorld::Ptr mReference;
|
||||||
public:
|
public:
|
||||||
SayAnimationValue(MWWorld::Ptr reference) : mReference(reference) {}
|
HeadAnimationTime(MWWorld::Ptr reference) : mReference(reference) {}
|
||||||
|
|
||||||
virtual Ogre::Real getValue() const;
|
virtual Ogre::Real getValue() const;
|
||||||
virtual void setValue(Ogre::Real value)
|
virtual void setValue(Ogre::Real value)
|
||||||
|
@ -70,7 +70,7 @@ private:
|
||||||
|
|
||||||
Ogre::Vector3 mFirstPersonOffset;
|
Ogre::Vector3 mFirstPersonOffset;
|
||||||
|
|
||||||
Ogre::SharedPtr<SayAnimationValue> mSayAnimationValue;
|
Ogre::SharedPtr<HeadAnimationTime> mHeadAnimationTime;
|
||||||
|
|
||||||
float mAlpha;
|
float mAlpha;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue