1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-16 11:09:43 +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
apps/openmw/mwrender
components/nifogre

View file

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

View file

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