1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 10:53:54 +00:00

Store the entity list in the object

This commit is contained in:
Chris Robinson 2012-07-17 16:00:03 -07:00
parent a590db2cf4
commit 94f3e7a6c0
4 changed files with 15 additions and 18 deletions

View file

@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <components/nifogre/ogre_nif_loader.hpp>
#include <openengine/ogre/renderer.hpp> #include <openengine/ogre/renderer.hpp>
#include "../mwworld/actiontalk.hpp" #include "../mwworld/actiontalk.hpp"
#include <components/nif/node.hpp> #include <components/nif/node.hpp>
@ -39,7 +40,7 @@ protected:
std::vector<Nif::NiKeyframeData>* mTransformations; std::vector<Nif::NiKeyframeData>* mTransformations;
std::map<std::string,float>* mTextmappings; std::map<std::string,float>* mTextmappings;
std::vector<Ogre::Entity*> mBase; NifOgre::EntityList mEntityList;
void handleAnimationTransforms(); void handleAnimationTransforms();
bool timeIndex( float time, const std::vector<float> & times, int & i, int & j, float & x ); bool timeIndex( float time, const std::vector<float> & times, int & i, int & j, float & x );

View file

@ -26,16 +26,16 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O
{ {
std::string mesh = "meshes\\" + ref->base->model; std::string mesh = "meshes\\" + ref->base->model;
NifOgre::EntityList entities = NifOgre::NIFLoader::createEntities(mInsert, mesh); mEntityList = NifOgre::NIFLoader::createEntities(mInsert, mesh);
mBase = entities.mEntities; for(size_t i = 0;i < mEntityList.mEntities.size();i++)
for(size_t i = 0;i < mBase.size();i++)
{ {
mBase[i]->setVisibilityFlags(RV_Actors); Ogre::Entity *ent = mEntityList.mEntities[i];
ent->setVisibilityFlags(RV_Actors);
bool transparent = false; bool transparent = false;
for (unsigned int j=0;j < mBase[i]->getNumSubEntities() && !transparent; ++j) for (unsigned int j=0;j < ent->getNumSubEntities() && !transparent; ++j)
{ {
Ogre::MaterialPtr mat = mBase[i]->getSubEntity(j)->getMaterial(); Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements() && !transparent) while (techIt.hasMoreElements() && !transparent)
{ {
@ -50,7 +50,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O
} }
} }
} }
mBase[i]->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
} }
} }
} }

View file

@ -27,8 +27,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRendere
leftpauldron(mInv.end()), rightpauldron(mInv.end()), leftpauldron(mInv.end()), rightpauldron(mInv.end()),
boots(mInv.end()), boots(mInv.end()),
leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()), leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()),
pants(mInv.end()), pants(mInv.end())
mSkelBase(0)
{ {
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
@ -65,12 +64,10 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRendere
std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif"); std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");
NifOgre::EntityList entities = NifOgre::NIFLoader::createEntities(mInsert, smodel); mEntityList = NifOgre::NIFLoader::createEntities(mInsert, smodel);
mBase = entities.mEntities; for(size_t i = 0;i < mEntityList.mEntities.size();i++)
mSkelBase = entities.mSkelBase;
for(size_t i = 0;i < mBase.size();i++)
{ {
Ogre::Entity *base = mBase[i]; Ogre::Entity *base = mEntityList.mEntities[i];
base->setVisibilityFlags(RV_Actors); base->setVisibilityFlags(RV_Actors);
bool transparent = false; bool transparent = false;
@ -376,7 +373,7 @@ std::vector<Ogre::Entity*> NpcAnimation::insertBoundedPart(const std::string &me
Ogre::Entity *part = parts.back(); Ogre::Entity *part = parts.back();
part->setVisibilityFlags(RV_Actors); part->setVisibilityFlags(RV_Actors);
mSkelBase->attachObjectToBone(bonename, part); mEntityList.mSkelBase->attachObjectToBone(bonename, part);
} }
return parts; return parts;
} }
@ -415,7 +412,7 @@ void NpcAnimation::runAnimation(float timepassed)
void NpcAnimation::removeEntities(std::vector<Ogre::Entity*> &entities) void NpcAnimation::removeEntities(std::vector<Ogre::Entity*> &entities)
{ {
for(size_t i = 0;i < entities.size();i++) for(size_t i = 0;i < entities.size();i++)
mSkelBase->detachObjectFromBone(entities[i]); mEntityList.mSkelBase->detachObjectFromBone(entities[i]);
entities.clear(); entities.clear();
} }

View file

@ -41,7 +41,6 @@ private:
std::vector<Ogre::Entity*> head; std::vector<Ogre::Entity*> head;
Ogre::SceneNode* mInsert; Ogre::SceneNode* mInsert;
Ogre::Entity *mSkelBase; // Entity with the base skeleton (temporary)
bool isBeast; bool isBeast;
bool isFemale; bool isFemale;
std::string headModel; std::string headModel;