1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-29 08:45:36 +00:00

Create entities when loading NIFs for creatures

This commit is contained in:
Chris Robinson 2012-07-17 14:11:07 -07:00
parent 3dedac5cb1
commit 3efd2030e2
2 changed files with 10 additions and 10 deletions

View file

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

View file

@ -896,7 +896,10 @@ EntityList NIFLoader::createEntities(Ogre::SceneNode *parent, const std::string
{
Ogre::Entity *entity = entitylist.mEntities[i];
if(entity != entitylist.mSkelBase && entity->hasSkeleton())
{
entity->shareSkeletonInstanceWith(entitylist.mSkelBase);
parent->attachObject(entity);
}
else if(entity != entitylist.mSkelBase)
entitylist.mSkelBase->attachObjectToBone(meshes[i].second, entity);
}