1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00
OpenMW/apps/openmw/mwrender/creatureanimation.cpp

78 lines
2.3 KiB
C++
Raw Normal View History

#include "creatureanimation.hpp"
#include <OgreEntity.h>
#include <OgreSceneManager.h>
#include <OgreSubEntity.h>
2012-04-03 15:13:47 +02:00
#include "renderconst.hpp"
#include "../mwbase/world.hpp"
using namespace Ogre;
using namespace NifOgre;
namespace MWRender{
2011-12-11 23:42:39 -05:00
CreatureAnimation::~CreatureAnimation()
{
2011-12-11 23:42:39 -05:00
}
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
{
mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
2012-11-05 16:07:59 +04:00
assert (ref->mBase != NULL);
if(!ref->mBase->mModel.empty())
{
2012-11-05 16:07:59 +04:00
std::string mesh = "meshes\\" + ref->mBase->mModel;
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh);
2012-07-17 16:00:03 -07:00
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
2012-04-04 18:53:40 +02:00
{
2012-07-17 16:00:03 -07:00
Ogre::Entity *ent = mEntityList.mEntities[i];
ent->setVisibilityFlags(RV_Actors);
2012-07-17 11:23:34 -07:00
bool transparent = false;
2012-07-17 16:00:03 -07:00
for (unsigned int j=0;j < ent->getNumSubEntities() && !transparent; ++j)
2012-04-04 18:53:40 +02:00
{
2012-07-17 16:00:03 -07:00
Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
2012-07-17 11:23:34 -07:00
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements() && !transparent)
2012-04-04 18:53:40 +02:00
{
2012-07-17 11:23:34 -07:00
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;
}
2012-04-04 18:53:40 +02:00
}
}
2012-07-17 16:00:03 -07:00
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
2012-07-17 11:23:34 -07:00
}
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);
}
}
}
}
void CreatureAnimation::runAnimation(float timepassed)
{
// Placeholder
Animation::runAnimation(timepassed);
}
2012-01-17 15:10:53 +01:00
}