2011-12-11 22:40:00 -05:00
|
|
|
#include "creatureanimation.hpp"
|
|
|
|
|
|
|
|
#include "../mwworld/world.hpp"
|
|
|
|
|
|
|
|
using namespace Ogre;
|
|
|
|
using namespace NifOgre;
|
|
|
|
namespace MWRender{
|
2011-12-11 23:42:39 -05:00
|
|
|
|
|
|
|
CreatureAnimation::~CreatureAnimation(){
|
|
|
|
|
|
|
|
}
|
2011-12-11 22:40:00 -05:00
|
|
|
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){
|
2012-01-05 21:45:17 -05:00
|
|
|
insert = ptr.getRefData().getBaseNode();
|
2011-12-11 22:40:00 -05:00
|
|
|
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
|
|
|
ptr.get<ESM::Creature>();
|
|
|
|
|
2012-01-17 15:10:53 +01:00
|
|
|
assert (ref->base != NULL);
|
2011-12-11 22:40:00 -05:00
|
|
|
if(!ref->base->model.empty()){
|
|
|
|
const std::string &mesh = "meshes\\" + ref->base->model;
|
2011-12-17 01:29:08 -05:00
|
|
|
std::string meshNumbered = mesh + getUniqueID(mesh) + ">|";
|
|
|
|
NifOgre::NIFLoader::load(meshNumbered);
|
|
|
|
base = mRend.getScene()->createEntity(meshNumbered);
|
|
|
|
std::string meshZero = mesh + "0000>|";
|
2011-12-11 22:40:00 -05:00
|
|
|
|
2012-01-17 15:10:53 +01:00
|
|
|
if((transformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero))){
|
2011-12-15 00:33:10 -05:00
|
|
|
|
2012-01-17 15:10:53 +01:00
|
|
|
for(std::size_t init = 0; init < transformations->size(); init++){
|
2011-12-15 00:33:10 -05:00
|
|
|
rindexI.push_back(0);
|
|
|
|
tindexI.push_back(0);
|
|
|
|
}
|
|
|
|
stopTime = transformations->begin()->getStopTime();
|
2012-01-05 21:45:17 -05:00
|
|
|
startTime = transformations->begin()->getStartTime();
|
2011-12-25 22:37:26 -05:00
|
|
|
shapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero);
|
2012-01-06 00:55:02 -05:00
|
|
|
}
|
|
|
|
textmappings = NIFLoader::getSingletonPtr()->getTextIndices(meshZero);
|
2011-12-11 22:40:00 -05:00
|
|
|
insert->attachObject(base);
|
|
|
|
}
|
|
|
|
}
|
2011-12-25 22:37:26 -05:00
|
|
|
|
|
|
|
void CreatureAnimation::runAnimation(float timepassed){
|
2012-01-25 01:21:30 -05:00
|
|
|
vecRotPos.clear();
|
2011-12-28 21:52:05 -05:00
|
|
|
if(animate > 0){
|
2011-12-25 22:37:26 -05:00
|
|
|
//Add the amount of time passed to time
|
|
|
|
|
|
|
|
//Handle the animation transforms dependent on time
|
|
|
|
|
|
|
|
//Handle the shapes dependent on animation transforms
|
2011-12-26 19:23:46 -05:00
|
|
|
time += timepassed;
|
2012-01-10 02:00:04 -05:00
|
|
|
if(time >= stopTime){
|
2011-12-28 21:52:05 -05:00
|
|
|
animate--;
|
|
|
|
//std::cout << "Stopping the animation\n";
|
|
|
|
if(animate == 0)
|
|
|
|
time = stopTime;
|
|
|
|
else
|
|
|
|
time = startTime + (time - stopTime);
|
2011-12-28 17:34:47 -05:00
|
|
|
}
|
2012-01-17 15:10:53 +01:00
|
|
|
|
2011-12-27 22:35:22 -05:00
|
|
|
handleAnimationTransforms();
|
2011-12-27 00:20:14 -05:00
|
|
|
handleShapes(shapes, base, base->getSkeleton());
|
2011-12-25 22:37:26 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-01-17 15:10:53 +01:00
|
|
|
}
|