mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 07:15:32 +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()
|
Animation::~Animation()
|
||||||
{
|
{
|
||||||
Ogre::SceneManager *sceneMgr = mInsert->getCreator();
|
if(mInsert)
|
||||||
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
|
{
|
||||||
sceneMgr->destroyEntity(mEntityList.mEntities[i]);
|
Ogre::SceneManager *sceneMgr = mInsert->getCreator();
|
||||||
|
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
|
||||||
|
sceneMgr->destroyEntity(mEntityList.mEntities[i]);
|
||||||
|
}
|
||||||
mEntityList.mEntities.clear();
|
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);
|
bool findGroupTimes(const std::string &groupname, GroupTimes *times);
|
||||||
|
|
||||||
|
void createEntityList(Ogre::SceneNode *node, const std::string &model);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Animation();
|
Animation();
|
||||||
virtual ~Animation();
|
virtual ~Animation();
|
||||||
|
|
|
@ -18,7 +18,6 @@ CreatureAnimation::~CreatureAnimation()
|
||||||
|
|
||||||
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
|
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
|
||||||
{
|
{
|
||||||
mInsert = ptr.getRefData().getBaseNode();
|
|
||||||
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
assert (ref->mBase != NULL);
|
assert (ref->mBase != NULL);
|
||||||
|
@ -26,7 +25,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
|
||||||
{
|
{
|
||||||
std::string mesh = "meshes\\" + ref->mBase->mModel;
|
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++)
|
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
|
||||||
{
|
{
|
||||||
Ogre::Entity *ent = mEntityList.mEntities[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);
|
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;
|
mBodyPrefix = "b_n_" + mNpc->mRace;
|
||||||
std::transform(mBodyPrefix.begin(), mBodyPrefix.end(), mBodyPrefix.begin(), ::tolower);
|
std::transform(mBodyPrefix.begin(), mBodyPrefix.end(), mBodyPrefix.begin(), ::tolower);
|
||||||
|
|
||||||
mInsert = node;
|
|
||||||
assert(mInsert);
|
|
||||||
|
|
||||||
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
|
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
|
||||||
std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");
|
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++)
|
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
|
||||||
{
|
{
|
||||||
Ogre::Entity *base = mEntityList.mEntities[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);
|
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;
|
float scale = race->mData.mHeight.mMale;
|
||||||
if (!mNpc->isMale()) {
|
if (!mNpc->isMale()) {
|
||||||
scale = race->mData.mHeight.mFemale;
|
scale = race->mData.mHeight.mFemale;
|
||||||
|
|
Loading…
Reference in a new issue