Create the Animation SceneNode in the constructor

actorid
Chris Robinson 12 years ago
parent 48784c7e2f
commit a9dca21d05

@ -12,16 +12,16 @@ ActivatorAnimation::~ActivatorAnimation()
}
ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr)
: Animation(ptr)
: Animation(ptr, ptr.getRefData().getBaseNode())
{
MWWorld::LiveCellRef<ESM::Activator> *ref = mPtr.get<ESM::Activator>();
assert (ref->mBase != NULL);
assert(ref->mBase != NULL);
if(!ref->mBase->mModel.empty())
{
const std::string name = "meshes\\"+ref->mBase->mModel;
setObjectRoot(mPtr.getRefData().getBaseNode(), name, false);
setObjectRoot(name, false);
setRenderProperties(mObjectRoot, RV_Misc, RQG_Main, RQG_Alpha);
addAnimSource(name);

@ -58,7 +58,7 @@ void Animation::destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectL
objects.mSkelBase = NULL;
}
Animation::Animation(const MWWorld::Ptr &ptr)
Animation::Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node)
: mPtr(ptr)
, mCamera(NULL)
, mInsert(NULL)
@ -71,6 +71,8 @@ Animation::Animation(const MWWorld::Ptr &ptr)
{
for(size_t i = 0;i < sNumGroups;i++)
mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this));
mInsert = node ? node->createChildSceneNode() :
mPtr.getRefData().getBaseNode()->createChildSceneNode();
}
Animation::~Animation()
@ -85,11 +87,9 @@ Animation::~Animation()
}
void Animation::setObjectRoot(Ogre::SceneNode *node, const std::string &model, bool baseonly)
void Animation::setObjectRoot(const std::string &model, bool baseonly)
{
OgreAssert(mAnimSources.empty(), "Setting object root while animation sources are set!");
if(!mInsert)
mInsert = node->createChildSceneNode();
std::string mdlname = Misc::StringUtils::lowerCase(model);
std::string::size_type p = mdlname.rfind('\\');

@ -153,7 +153,7 @@ protected:
* Note that you must make sure all animation sources are cleared before reseting the object
* root. All nodes previously retrieved with getNode will also become invalidated.
*/
void setObjectRoot(Ogre::SceneNode *node, const std::string &model, bool baseonly);
void setObjectRoot(const std::string &model, bool baseonly);
/* Adds the keyframe controllers in the specified model as a new animation source. Note that
* the filename portion of the provided model name will be prepended with 'x', and the .nif
@ -170,7 +170,7 @@ protected:
void clearAnimSources();
public:
Animation(const MWWorld::Ptr &ptr);
Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node);
virtual ~Animation();
void updatePtr(const MWWorld::Ptr &ptr);

@ -12,7 +12,7 @@ CreatureAnimation::~CreatureAnimation()
}
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr)
: Animation(ptr)
: Animation(ptr, ptr.getRefData().getBaseNode())
{
MWWorld::LiveCellRef<ESM::Creature> *ref = mPtr.get<ESM::Creature>();
@ -21,7 +21,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr)
{
std::string model = "meshes\\"+ref->mBase->mModel;
setObjectRoot(mPtr.getRefData().getBaseNode(), model, false);
setObjectRoot(model, false);
setRenderProperties(mObjectRoot, RV_Actors, RQG_Main, RQG_Alpha);
if((ref->mBase->mFlags&ESM::Creature::Biped))

@ -63,7 +63,7 @@ NpcAnimation::~NpcAnimation()
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags, ViewMode viewMode)
: Animation(ptr),
: Animation(ptr, node),
mStateID(-1),
mTimeToChange(0),
mVisibilityFlags(visibilityFlags),
@ -106,7 +106,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
std::string smodel = (viewMode != VM_FirstPerson) ?
(!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif") :
(!isBeast ? "meshes\\base_anim.1st.nif" : "meshes\\base_animkna.1st.nif") ;
setObjectRoot(node, smodel, true);
setObjectRoot(smodel, true);
if(mViewMode != VM_FirstPerson)
{
@ -147,7 +147,7 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
std::string smodel = (viewMode != VM_FirstPerson) ?
(!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif") :
(!isBeast ? "meshes\\base_anim.1st.nif" : "meshes\\base_animkna.1st.nif") ;
setObjectRoot(mInsert->getParentSceneNode(), smodel, true);
setObjectRoot(smodel, true);
if(mViewMode != VM_FirstPerson)
{

Loading…
Cancel
Save