mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 10:53:51 +00:00
Add a helper method to load entity objects
This commit is contained in:
parent
8a086e3afb
commit
6e84d4bcdd
4 changed files with 31 additions and 33 deletions
|
@ -19,10 +19,34 @@ Animation::Animation()
|
|||
|
||||
Animation::~Animation()
|
||||
{
|
||||
Ogre::SceneManager *sceneMgr = mInsert->getCreator();
|
||||
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
|
||||
sceneMgr->destroyEntity(mEntityList.mEntities[i]);
|
||||
if(mInsert)
|
||||
{
|
||||
Ogre::SceneManager *sceneMgr = mInsert->getCreator();
|
||||
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
|
||||
sceneMgr->destroyEntity(mEntityList.mEntities[i]);
|
||||
}
|
||||
mEntityList.mEntities.clear();
|
||||
mEntityList.mSkelBase = NULL;
|
||||
}
|
||||
|
||||
|
||||
void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model)
|
||||
{
|
||||
mInsert = node;
|
||||
assert(mInsert);
|
||||
|
||||
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, model);
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setEnabled(true);
|
||||
state->setLoop(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ protected:
|
|||
|
||||
bool findGroupTimes(const std::string &groupname, GroupTimes *times);
|
||||
|
||||
void createEntityList(Ogre::SceneNode *node, const std::string &model);
|
||||
|
||||
public:
|
||||
Animation();
|
||||
virtual ~Animation();
|
||||
|
|
|
@ -18,7 +18,6 @@ CreatureAnimation::~CreatureAnimation()
|
|||
|
||||
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
|
||||
{
|
||||
mInsert = ptr.getRefData().getBaseNode();
|
||||
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
||||
|
||||
assert (ref->mBase != NULL);
|
||||
|
@ -26,7 +25,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
|
|||
{
|
||||
std::string mesh = "meshes\\" + ref->mBase->mModel;
|
||||
|
||||
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh);
|
||||
createEntityList(ptr.getRefData().getBaseNode(), mesh);
|
||||
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
|
||||
{
|
||||
Ogre::Entity *ent = mEntityList.mEntities[i];
|
||||
|
@ -52,18 +51,6 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
|
|||
}
|
||||
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
|
||||
}
|
||||
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setEnabled(true);
|
||||
state->setLoop(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,13 +82,10 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
|
|||
mBodyPrefix = "b_n_" + mNpc->mRace;
|
||||
std::transform(mBodyPrefix.begin(), mBodyPrefix.end(), mBodyPrefix.begin(), ::tolower);
|
||||
|
||||
mInsert = node;
|
||||
assert(mInsert);
|
||||
|
||||
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
|
||||
std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");
|
||||
|
||||
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, smodel);
|
||||
createEntityList(node, smodel);
|
||||
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
|
||||
{
|
||||
Ogre::Entity *base = mEntityList.mEntities[i];
|
||||
|
@ -116,18 +113,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
|
|||
base->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
|
||||
}
|
||||
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setEnabled(true);
|
||||
state->setLoop(false);
|
||||
}
|
||||
}
|
||||
|
||||
float scale = race->mData.mHeight.mMale;
|
||||
if (!mNpc->isMale()) {
|
||||
scale = race->mData.mHeight.mFemale;
|
||||
|
|
Loading…
Reference in a new issue