Introducing loops; SkipAnim; Skeleton reset bug fixed

actorid
Jason Hooks 13 years ago
parent c8cca06b40
commit 42e7ff9b13

@ -118,7 +118,8 @@ void Actors::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& gro
mAllActors[ptr]->startScript(groupName, mode, number);
}
void Actors::skipAnimation (const MWWorld::Ptr& ptr){
if(mAllActors.find(ptr) != mAllActors.end())
mAllActors[ptr]->stopScript();
}
void Actors::addTime(){
//std::cout << "Adding time in actors\n";

@ -30,11 +30,14 @@ namespace MWRender{
//Set the start time and stop time
//How many times to loop
if(groupname == "all"){
animate = true;
animate = loops;
time = startTime;
}
}
void Animation::stopScript(){
animate = 0;
}
void Animation::handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){
shapeNumber = 0;

@ -18,12 +18,13 @@ class Animation{
OEngine::Render::OgreRenderer &mRend;
MWWorld::Environment& mEnvironment;
static std::map<std::string, int> mUniqueIDs;
std::vector<std::vector<Nif::NiTriShapeCopy>* > shapeparts; //All the NiTriShape data that we need for animating an npc
float time;
float startTime;
float stopTime;
bool loop;
bool animate;
int animate;
//Represents a rotation index for each bone
std::vector<int>rindexI;
//Represents a translation index for each bone
@ -49,9 +50,10 @@ class Animation{
std::string getUniqueID(std::string mesh);
public:
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), loop(false), animate(false){};
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), loop(false), animate(0){};
virtual void runAnimation(float timepassed) = 0;
void startScript(std::string groupname, int mode, int loops);
void stopScript();
~Animation();

@ -42,17 +42,20 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
}
void CreatureAnimation::runAnimation(float timepassed){
if(animate){
if(animate > 0){
//Add the amount of time passed to time
//Handle the animation transforms dependent on time
//Handle the shapes dependent on animation transforms
time += timepassed;
if(time > transformations->begin()->getStopTime()){
animate = false;
std::cout << "Stopping the animation\n";
return;
if(time > stopTime){
animate--;
//std::cout << "Stopping the animation\n";
if(animate == 0)
time = stopTime;
else
time = startTime + (time - stopTime);
}
handleAnimationTransforms();

@ -56,6 +56,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
NifOgre::NIFLoader::load(smodel);
base = mRend.getScene()->createEntity(smodel);
base->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones
//stay in the same place when we skipanim, or open a gui window
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel)){
@ -226,10 +228,17 @@ void NpcAnimation::runAnimation(float timepassed){
//Handle the animation transforms dependent on time
//Handle the shapes dependent on animation transforms
if(animate){
if(animate > 0){
time += timepassed;
if(time > stopTime){
animate--;
//std::cout << "Stopping the animation\n";
if(animate == 0)
time = stopTime;
else
time = startTime + (time - stopTime);
}
handleAnimationTransforms();
// handleAnimationTransforms(base);
@ -252,5 +261,6 @@ void NpcAnimation::runAnimation(float timepassed){
entitypartsiter++;
}
}
}
}

@ -17,7 +17,7 @@ namespace MWRender{
class NpcAnimation: public Animation{
Ogre::SceneNode* insert;
std::vector<std::vector<Nif::NiTriShapeCopy>* > shapeparts; //All the NiTriShape data that we need for animating this particular npc
public:
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
~NpcAnimation();

@ -240,6 +240,7 @@ std::cout<<"play animation " << groupName << ", " << mode << ", " << number << s
void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr)
{
std::cout<<"skip animation"<<std::endl;
mActors.skipAnimation(ptr);
}
void RenderingManager::addTime(){
mActors.addTime();

Loading…
Cancel
Save