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

63 lines
2.0 KiB
C++
Raw Normal View History

#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(){
}
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
assert(insert);
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();
assert (ref->base != NULL);
if(!ref->base->model.empty()){
const std::string &mesh = "meshes\\" + ref->base->model;
std::string meshNumbered = mesh + getUniqueID(mesh) + ">|";
NifOgre::NIFLoader::load(meshNumbered);
base = mRend.getScene()->createEntity(meshNumbered);
std::string meshZero = mesh + "0000>|";
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero)){
2011-12-15 00:33:10 -05:00
for(int init = 0; init < transformations->size(); init++){
rindexI.push_back(0);
//a.rindexJ.push_back(0);
tindexI.push_back(0);
//a.tindexJ.push_back(0);
}
loop = false;
stopTime = transformations->begin()->getStopTime();
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
startTime = transformations->begin()->getStartTime();
shapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero);
2011-12-15 00:33:10 -05:00
}
insert->attachObject(base);
}
}
void CreatureAnimation::runAnimation(float timepassed){
if(animate){
//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;
2011-12-28 17:34:47 -05:00
if(time > transformations->begin()->getStopTime()){
animate = false;
std::cout << "Stopping the animation\n";
return;
}
2011-12-27 22:35:22 -05:00
handleAnimationTransforms();
2011-12-27 00:20:14 -05:00
handleShapes(shapes, base, base->getSkeleton());
}
}
}