1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-01 11:36:41 +00:00

Create the Animation SceneNode in the constructor

This commit is contained in:
Chris Robinson 2013-08-06 01:41:47 -07:00
parent 48784c7e2f
commit a9dca21d05
5 changed files with 14 additions and 14 deletions

View file

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

View file

@ -58,7 +58,7 @@ void Animation::destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectL
objects.mSkelBase = NULL; objects.mSkelBase = NULL;
} }
Animation::Animation(const MWWorld::Ptr &ptr) Animation::Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node)
: mPtr(ptr) : mPtr(ptr)
, mCamera(NULL) , mCamera(NULL)
, mInsert(NULL) , mInsert(NULL)
@ -71,6 +71,8 @@ Animation::Animation(const MWWorld::Ptr &ptr)
{ {
for(size_t i = 0;i < sNumGroups;i++) for(size_t i = 0;i < sNumGroups;i++)
mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this)); mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this));
mInsert = node ? node->createChildSceneNode() :
mPtr.getRefData().getBaseNode()->createChildSceneNode();
} }
Animation::~Animation() 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!"); 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 mdlname = Misc::StringUtils::lowerCase(model);
std::string::size_type p = mdlname.rfind('\\'); std::string::size_type p = mdlname.rfind('\\');

View file

@ -153,7 +153,7 @@ protected:
* Note that you must make sure all animation sources are cleared before reseting the object * 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. * 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 /* 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 * the filename portion of the provided model name will be prepended with 'x', and the .nif
@ -170,7 +170,7 @@ protected:
void clearAnimSources(); void clearAnimSources();
public: public:
Animation(const MWWorld::Ptr &ptr); Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node);
virtual ~Animation(); virtual ~Animation();
void updatePtr(const MWWorld::Ptr &ptr); void updatePtr(const MWWorld::Ptr &ptr);

View file

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

View file

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