mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Update animation source controller targets
This commit is contained in:
parent
44a59e1b87
commit
f69a8259e1
@ -78,6 +78,7 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
|
|||||||
destroyObjectList(sceneMgr, mAnimationSources[i]);
|
destroyObjectList(sceneMgr, mAnimationSources[i]);
|
||||||
mAnimationSources.clear();
|
mAnimationSources.clear();
|
||||||
|
|
||||||
|
Ogre::SkeletonInstance *skelinst = mObjectList.mSkelBase->getSkeleton();
|
||||||
std::vector<std::string>::const_iterator nameiter;
|
std::vector<std::string>::const_iterator nameiter;
|
||||||
for(nameiter = names.begin();nameiter != names.end();nameiter++)
|
for(nameiter = names.begin();nameiter != names.end();nameiter++)
|
||||||
{
|
{
|
||||||
@ -89,6 +90,19 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
|
|||||||
mAnimationSources.pop_back();
|
mAnimationSources.pop_back();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const NifOgre::ObjectList &objects = mAnimationSources.back();
|
||||||
|
|
||||||
|
for(size_t i = 0;i < objects.mControllers.size();i++)
|
||||||
|
{
|
||||||
|
NifOgre::NodeTargetValue<Ogre::Real> *dstval = dynamic_cast<NifOgre::NodeTargetValue<Ogre::Real>*>(objects.mControllers[i].getDestination().getPointer());
|
||||||
|
if(!dstval) continue;
|
||||||
|
|
||||||
|
const Ogre::String &trgtname = dstval->getNode()->getName();
|
||||||
|
if(!skelinst->hasBone(trgtname)) continue;
|
||||||
|
|
||||||
|
Ogre::Bone *bone = skelinst->getBone(trgtname);
|
||||||
|
dstval->setNode(bone);
|
||||||
|
}
|
||||||
|
|
||||||
Ogre::Entity *ent = mAnimationSources.back().mSkelBase;
|
Ogre::Entity *ent = mAnimationSources.back().mSkelBase;
|
||||||
Ogre::SkeletonPtr skel = Ogre::SkeletonManager::getSingleton().getByName(ent->getSkeleton()->getName());
|
Ogre::SkeletonPtr skel = Ogre::SkeletonManager::getSingleton().getByName(ent->getSkeleton()->getName());
|
||||||
|
@ -108,10 +108,9 @@ public:
|
|||||||
class VisController
|
class VisController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class Value : public Ogre::ControllerValue<Ogre::Real>
|
class Value : public NodeTargetValue<Ogre::Real>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Ogre::Bone *mTarget;
|
|
||||||
std::vector<Nif::NiVisData::VisData> mData;
|
std::vector<Nif::NiVisData::VisData> mData;
|
||||||
|
|
||||||
virtual bool calculate(Ogre::Real time)
|
virtual bool calculate(Ogre::Real time)
|
||||||
@ -149,8 +148,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Value(Ogre::Bone *target, const Nif::NiVisData *data)
|
Value(Ogre::Node *target, const Nif::NiVisData *data)
|
||||||
: mTarget(target)
|
: NodeTargetValue<Ogre::Real>(target)
|
||||||
, mData(data->mVis)
|
, mData(data->mVis)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -163,7 +162,7 @@ public:
|
|||||||
virtual void setValue(Ogre::Real time)
|
virtual void setValue(Ogre::Real time)
|
||||||
{
|
{
|
||||||
bool vis = calculate(time);
|
bool vis = calculate(time);
|
||||||
setVisible(mTarget, vis);
|
setVisible(mNode, vis);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,6 +74,24 @@ public:
|
|||||||
const std::string &group="General");
|
const std::string &group="General");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME: Should be with other general Ogre extensions.
|
||||||
|
template<typename T>
|
||||||
|
class NodeTargetValue : public Ogre::ControllerValue<T>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
Ogre::Node *mNode;
|
||||||
|
|
||||||
|
public:
|
||||||
|
NodeTargetValue(Ogre::Node *target) : mNode(target)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void setNode(Ogre::Node *target)
|
||||||
|
{ mNode = target; }
|
||||||
|
Ogre::Node *getNode() const
|
||||||
|
{ return mNode; }
|
||||||
|
};
|
||||||
|
typedef Ogre::SharedPtr<NodeTargetValue<Ogre::Real> > NodeTargetValueRealPtr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
|
Loading…
x
Reference in New Issue
Block a user