From 0a4a141f2e94925f24f60b09e85e4a365ef336d5 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 17 Jul 2012 11:23:34 -0700 Subject: [PATCH] Support multiple meshes for creatures --- apps/openmw/mwrender/animation.cpp | 1 - apps/openmw/mwrender/animation.hpp | 4 +- apps/openmw/mwrender/creatureanimation.cpp | 43 ++++++++++++---------- apps/openmw/mwrender/npcanimation.hpp | 1 + 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 08176077c7..17c3f62ac9 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -23,7 +23,6 @@ Animation::Animation(OEngine::Render::OgreRenderer& _rend) , mShapeIndexI() , mTransformations(NULL) , mTextmappings(NULL) - , mBase(NULL) { } diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 0e96b4d4df..ea18865da0 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -1,6 +1,8 @@ #ifndef _GAME_RENDER_ANIMATION_H #define _GAME_RENDER_ANIMATION_H +#include + #include #include "../mwworld/actiontalk.hpp" #include @@ -37,7 +39,7 @@ protected: std::vector* mTransformations; std::map* mTextmappings; - Ogre::Entity* mBase; + std::vector mBase; void handleAnimationTransforms(); bool timeIndex( float time, const std::vector & times, int & i, int & j, float & x ); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 99800f06c6..b42feec68e 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -26,32 +26,35 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O { std::string mesh = "meshes\\" + ref->base->model; - // FIXME: There can be more than one! NifOgre::MeshPairList meshes = NifOgre::NIFLoader::load(mesh); - mBase = mRend.getScene()->createEntity(meshes[0].first->getName()); - mBase->setVisibilityFlags(RV_Actors); - - bool transparent = false; - for (unsigned int i=0; i < mBase->getNumSubEntities(); ++i) + for(size_t i = 0;i < meshes.size();i++) { - Ogre::MaterialPtr mat = mBase->getSubEntity(i)->getMaterial(); - Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); - while (techIt.hasMoreElements()) - { - Ogre::Technique* tech = techIt.getNext(); - Ogre::Technique::PassIterator passIt = tech->getPassIterator(); - while (passIt.hasMoreElements()) - { - Ogre::Pass* pass = passIt.getNext(); + mBase.push_back(mRend.getScene()->createEntity(meshes[i].first->getName())); + Ogre::Entity *base = mBase.back(); + base->setVisibilityFlags(RV_Actors); - if (pass->getDepthWriteEnabled() == false) - transparent = true; + bool transparent = false; + for (unsigned int j=0;j < base->getNumSubEntities() && !transparent; ++j) + { + Ogre::MaterialPtr mat = base->getSubEntity(j)->getMaterial(); + Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); + while (techIt.hasMoreElements() && !transparent) + { + Ogre::Technique* tech = techIt.getNext(); + Ogre::Technique::PassIterator passIt = tech->getPassIterator(); + while (passIt.hasMoreElements() && !transparent) + { + Ogre::Pass* pass = passIt.getNext(); + + if (pass->getDepthWriteEnabled() == false) + transparent = true; + } } } - } - mBase->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); + base->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); - mInsert->attachObject(mBase); + mInsert->attachObject(base); + } } } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 82d8470918..651f0ffe27 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -41,6 +41,7 @@ private: Ogre::Entity* head; Ogre::SceneNode* mInsert; + Ogre::Entity *mBase; // FIXME: Temporary! bool isBeast; bool isFemale; std::string headModel;