forked from teamnwah/openmw-tes3coop
Merge branch 'nif-cleanup' of https://github.com/ChrisKCat/openmw into nif-cleanup
This commit is contained in:
commit
1dbfd60305
6 changed files with 72 additions and 64 deletions
|
@ -16,6 +16,7 @@ Animation::Animation(OEngine::Render::OgreRenderer& _rend)
|
||||||
, mRend(_rend)
|
, mRend(_rend)
|
||||||
, mTime(0.0f)
|
, mTime(0.0f)
|
||||||
, mAnimate(0)
|
, mAnimate(0)
|
||||||
|
, mSkipFrame(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +40,37 @@ void Animation::playGroup(std::string groupname, int mode, int loops)
|
||||||
|
|
||||||
void Animation::skipAnim()
|
void Animation::skipAnim()
|
||||||
{
|
{
|
||||||
mAnimate = 0;
|
mSkipFrame = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animation::runAnimation(float timepassed)
|
||||||
|
{
|
||||||
|
if(mAnimate != 0 && !mSkipFrame)
|
||||||
|
{
|
||||||
|
mTime += timepassed;
|
||||||
|
|
||||||
|
if(mEntityList.mSkelBase)
|
||||||
|
{
|
||||||
|
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||||
|
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||||
|
while(as.hasMoreElements())
|
||||||
|
{
|
||||||
|
Ogre::AnimationState *state = as.getNext();
|
||||||
|
state->setTimePosition(mTime);
|
||||||
|
if(mTime >= state->getLength())
|
||||||
|
{
|
||||||
|
if(mAnimate != -1)
|
||||||
|
mAnimate--;
|
||||||
|
//std::cout << "Stopping the animation\n";
|
||||||
|
if(mAnimate == 0)
|
||||||
|
mTime = state->getLength();
|
||||||
|
else
|
||||||
|
mTime = mTime - state->getLength();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mSkipFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ protected:
|
||||||
|
|
||||||
float mTime;
|
float mTime;
|
||||||
int mAnimate;
|
int mAnimate;
|
||||||
|
bool mSkipFrame;
|
||||||
|
|
||||||
NifOgre::EntityList mEntityList;
|
NifOgre::EntityList mEntityList;
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ public:
|
||||||
|
|
||||||
void playGroup(std::string groupname, int mode, int loops);
|
void playGroup(std::string groupname, int mode, int loops);
|
||||||
void skipAnim();
|
void skipAnim();
|
||||||
virtual void runAnimation(float timepassed) = 0;
|
virtual void runAnimation(float timepassed);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,30 +69,9 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O
|
||||||
|
|
||||||
void CreatureAnimation::runAnimation(float timepassed)
|
void CreatureAnimation::runAnimation(float timepassed)
|
||||||
{
|
{
|
||||||
if(mAnimate > 0)
|
// Placeholder
|
||||||
{
|
|
||||||
mTime += timepassed;
|
|
||||||
|
|
||||||
if(mEntityList.mSkelBase)
|
Animation::runAnimation(timepassed);
|
||||||
{
|
|
||||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
|
||||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
|
||||||
while(as.hasMoreElements())
|
|
||||||
{
|
|
||||||
Ogre::AnimationState *state = as.getNext();
|
|
||||||
state->setTimePosition(mTime);
|
|
||||||
if(state->getTimePosition() >= state->getLength())
|
|
||||||
{
|
|
||||||
mAnimate--;
|
|
||||||
//std::cout << "Stopping the animation\n";
|
|
||||||
if(mAnimate == 0)
|
|
||||||
mTime = state->getLength();
|
|
||||||
else
|
|
||||||
mTime = mTime - state->getLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ void NpcAnimation::updateParts()
|
||||||
{ &greaves, MWWorld::InventoryStore::Slot_Greaves },
|
{ &greaves, MWWorld::InventoryStore::Slot_Greaves },
|
||||||
{ &leftpauldron, MWWorld::InventoryStore::Slot_LeftPauldron },
|
{ &leftpauldron, MWWorld::InventoryStore::Slot_LeftPauldron },
|
||||||
{ &rightpauldron, MWWorld::InventoryStore::Slot_RightPauldron },
|
{ &rightpauldron, MWWorld::InventoryStore::Slot_RightPauldron },
|
||||||
{ &boots, MWWorld::InventoryStore::Slot_Boots }, // !isBeast
|
{ &boots, MWWorld::InventoryStore::Slot_Boots },
|
||||||
{ &leftglove, MWWorld::InventoryStore::Slot_LeftGauntlet },
|
{ &leftglove, MWWorld::InventoryStore::Slot_LeftGauntlet },
|
||||||
{ &rightglove, MWWorld::InventoryStore::Slot_RightGauntlet },
|
{ &rightglove, MWWorld::InventoryStore::Slot_RightGauntlet },
|
||||||
{ &shirt, MWWorld::InventoryStore::Slot_Shirt },
|
{ &shirt, MWWorld::InventoryStore::Slot_Shirt },
|
||||||
|
@ -157,9 +157,6 @@ void NpcAnimation::updateParts()
|
||||||
};
|
};
|
||||||
for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++)
|
for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++)
|
||||||
{
|
{
|
||||||
if(slotlist[i].iter == &boots && isBeast)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator iter = mInv.getSlot(slotlist[i].slot);
|
MWWorld::ContainerStoreIterator iter = mInv.getSlot(slotlist[i].slot);
|
||||||
if(*slotlist[i].iter != iter)
|
if(*slotlist[i].iter != iter)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +232,7 @@ void NpcAnimation::updateParts()
|
||||||
std::vector<ESM::PartReference> parts = armor->parts.parts;
|
std::vector<ESM::PartReference> parts = armor->parts.parts;
|
||||||
addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts);
|
addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts);
|
||||||
}
|
}
|
||||||
if(!isBeast && boots != mInv.end())
|
if(boots != mInv.end())
|
||||||
{
|
{
|
||||||
if(boots->getTypeName() == typeid(ESM::Clothing).name())
|
if(boots->getTypeName() == typeid(ESM::Clothing).name())
|
||||||
{
|
{
|
||||||
|
@ -373,30 +370,7 @@ void NpcAnimation::runAnimation(float timepassed)
|
||||||
}
|
}
|
||||||
timeToChange += timepassed;
|
timeToChange += timepassed;
|
||||||
|
|
||||||
if(mAnimate > 0)
|
Animation::runAnimation(timepassed);
|
||||||
{
|
|
||||||
mTime += timepassed;
|
|
||||||
|
|
||||||
if(mEntityList.mSkelBase)
|
|
||||||
{
|
|
||||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
|
||||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
|
||||||
while(as.hasMoreElements())
|
|
||||||
{
|
|
||||||
Ogre::AnimationState *state = as.getNext();
|
|
||||||
state->setTimePosition(mTime);
|
|
||||||
if(state->getTimePosition() >= state->getLength())
|
|
||||||
{
|
|
||||||
mAnimate--;
|
|
||||||
//std::cout << "Stopping the animation\n";
|
|
||||||
if(mAnimate == 0)
|
|
||||||
mTime = state->getLength();
|
|
||||||
else
|
|
||||||
mTime = mTime - state->getLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
||||||
|
@ -411,7 +385,6 @@ void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
||||||
}
|
}
|
||||||
entities.mEntities.clear();
|
entities.mEntities.clear();
|
||||||
entities.mSkelBase = NULL;
|
entities.mSkelBase = NULL;
|
||||||
entities.mRootNode = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::removeIndividualPart(int type)
|
void NpcAnimation::removeIndividualPart(int type)
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#include "ogre_nif_loader.hpp"
|
#include "ogre_nif_loader.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <OgreMaterialManager.h>
|
#include <OgreMaterialManager.h>
|
||||||
#include <OgreMeshManager.h>
|
#include <OgreMeshManager.h>
|
||||||
#include <OgreHardwareBufferManager.h>
|
#include <OgreHardwareBufferManager.h>
|
||||||
|
@ -306,10 +308,30 @@ void loadResource(Ogre::Resource *resource)
|
||||||
|
|
||||||
Ogre::TransformKeyFrame *kframe;
|
Ogre::TransformKeyFrame *kframe;
|
||||||
kframe = nodetrack->createNodeKeyFrame(curtime);
|
kframe = nodetrack->createNodeKeyFrame(curtime);
|
||||||
// FIXME: These should be interpolated since they don't all fall on the same time
|
if(quatiter == quatkeys.mKeys.end() || quatiter == quatkeys.mKeys.begin())
|
||||||
kframe->setRotation(curquat);
|
kframe->setRotation(curquat);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QuaternionKeyList::VecType::const_iterator last = quatiter-1;
|
||||||
|
float diff = (curtime-last->mTime) / (quatiter->mTime-last->mTime);
|
||||||
|
kframe->setRotation(Ogre::Quaternion::nlerp(diff, lastquat, curquat));
|
||||||
|
}
|
||||||
|
if(traniter == trankeys.mKeys.end() || traniter == trankeys.mKeys.begin())
|
||||||
kframe->setTranslate(curtrans);
|
kframe->setTranslate(curtrans);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Vector3KeyList::VecType::const_iterator last = traniter-1;
|
||||||
|
float diff = (curtime-last->mTime) / (traniter->mTime-last->mTime);
|
||||||
|
kframe->setTranslate(lasttrans + ((curtrans-lasttrans)*diff));
|
||||||
|
}
|
||||||
|
if(scaleiter == scalekeys.mKeys.end() || scaleiter == scalekeys.mKeys.begin())
|
||||||
kframe->setScale(curscale);
|
kframe->setScale(curscale);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FloatKeyList::VecType::const_iterator last = scaleiter-1;
|
||||||
|
float diff = (curtime-last->mTime) / (scaleiter->mTime-last->mTime);
|
||||||
|
kframe->setScale(lastscale + ((curscale-lastscale)*diff));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
anim->optimise();
|
anim->optimise();
|
||||||
|
@ -1027,7 +1049,6 @@ EntityList NIFLoader::createEntities(Ogre::SceneNode *parent, const std::string
|
||||||
if(meshes.size() == 0)
|
if(meshes.size() == 0)
|
||||||
return entitylist;
|
return entitylist;
|
||||||
|
|
||||||
entitylist.mRootNode = parent;
|
|
||||||
Ogre::SceneManager *sceneMgr = parent->getCreator();
|
Ogre::SceneManager *sceneMgr = parent->getCreator();
|
||||||
for(size_t i = 0;i < meshes.size();i++)
|
for(size_t i = 0;i < meshes.size();i++)
|
||||||
{
|
{
|
||||||
|
@ -1061,6 +1082,11 @@ EntityList NIFLoader::createEntities(Ogre::SceneNode *parent, const std::string
|
||||||
return entitylist;
|
return entitylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool checklow(const char &a, const char &b)
|
||||||
|
{
|
||||||
|
return ::tolower(a) == ::tolower(b);
|
||||||
|
}
|
||||||
|
|
||||||
EntityList NIFLoader::createEntities(Ogre::Entity *parent, const std::string &bonename,
|
EntityList NIFLoader::createEntities(Ogre::Entity *parent, const std::string &bonename,
|
||||||
Ogre::SceneNode *parentNode,
|
Ogre::SceneNode *parentNode,
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
|
@ -1080,8 +1106,7 @@ EntityList NIFLoader::createEntities(Ogre::Entity *parent, const std::string &bo
|
||||||
if(ent->hasSkeleton())
|
if(ent->hasSkeleton())
|
||||||
{
|
{
|
||||||
if(meshes[i].second.length() < filter.length() ||
|
if(meshes[i].second.length() < filter.length() ||
|
||||||
!boost::algorithm::lexicographical_compare(meshes[i].second.substr(0, filter.length()),
|
std::mismatch(filter.begin(), filter.end(), meshes[i].second.begin(), checklow).first != filter.end())
|
||||||
filter, boost::algorithm::is_iequal()))
|
|
||||||
{
|
{
|
||||||
sceneMgr->destroyEntity(ent);
|
sceneMgr->destroyEntity(ent);
|
||||||
meshes.erase(meshes.begin()+i);
|
meshes.erase(meshes.begin()+i);
|
||||||
|
|
|
@ -62,9 +62,8 @@ namespace NifOgre
|
||||||
struct EntityList {
|
struct EntityList {
|
||||||
std::vector<Ogre::Entity*> mEntities;
|
std::vector<Ogre::Entity*> mEntities;
|
||||||
Ogre::Entity *mSkelBase;
|
Ogre::Entity *mSkelBase;
|
||||||
Ogre::SceneNode *mRootNode;
|
|
||||||
|
|
||||||
EntityList() : mSkelBase(0), mRootNode(0)
|
EntityList() : mSkelBase(0)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue