mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Introducing loops; SkipAnim; Skeleton reset bug fixed
This commit is contained in:
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);
|
mAllActors[ptr]->startScript(groupName, mode, number);
|
||||||
}
|
}
|
||||||
void Actors::skipAnimation (const MWWorld::Ptr& ptr){
|
void Actors::skipAnimation (const MWWorld::Ptr& ptr){
|
||||||
|
if(mAllActors.find(ptr) != mAllActors.end())
|
||||||
|
mAllActors[ptr]->stopScript();
|
||||||
}
|
}
|
||||||
void Actors::addTime(){
|
void Actors::addTime(){
|
||||||
//std::cout << "Adding time in actors\n";
|
//std::cout << "Adding time in actors\n";
|
||||||
|
@ -30,11 +30,14 @@ namespace MWRender{
|
|||||||
//Set the start time and stop time
|
//Set the start time and stop time
|
||||||
//How many times to loop
|
//How many times to loop
|
||||||
if(groupname == "all"){
|
if(groupname == "all"){
|
||||||
animate = true;
|
animate = loops;
|
||||||
time = startTime;
|
time = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void Animation::stopScript(){
|
||||||
|
animate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Animation::handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){
|
void Animation::handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){
|
||||||
shapeNumber = 0;
|
shapeNumber = 0;
|
||||||
|
@ -18,12 +18,13 @@ class Animation{
|
|||||||
OEngine::Render::OgreRenderer &mRend;
|
OEngine::Render::OgreRenderer &mRend;
|
||||||
MWWorld::Environment& mEnvironment;
|
MWWorld::Environment& mEnvironment;
|
||||||
static std::map<std::string, int> mUniqueIDs;
|
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 time;
|
||||||
float startTime;
|
float startTime;
|
||||||
float stopTime;
|
float stopTime;
|
||||||
bool loop;
|
bool loop;
|
||||||
bool animate;
|
int animate;
|
||||||
//Represents a rotation index for each bone
|
//Represents a rotation index for each bone
|
||||||
std::vector<int>rindexI;
|
std::vector<int>rindexI;
|
||||||
//Represents a translation index for each bone
|
//Represents a translation index for each bone
|
||||||
@ -49,9 +50,10 @@ class Animation{
|
|||||||
std::string getUniqueID(std::string mesh);
|
std::string getUniqueID(std::string mesh);
|
||||||
|
|
||||||
public:
|
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;
|
virtual void runAnimation(float timepassed) = 0;
|
||||||
void startScript(std::string groupname, int mode, int loops);
|
void startScript(std::string groupname, int mode, int loops);
|
||||||
|
void stopScript();
|
||||||
|
|
||||||
|
|
||||||
~Animation();
|
~Animation();
|
||||||
|
@ -42,17 +42,20 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CreatureAnimation::runAnimation(float timepassed){
|
void CreatureAnimation::runAnimation(float timepassed){
|
||||||
if(animate){
|
if(animate > 0){
|
||||||
//Add the amount of time passed to time
|
//Add the amount of time passed to time
|
||||||
|
|
||||||
//Handle the animation transforms dependent on time
|
//Handle the animation transforms dependent on time
|
||||||
|
|
||||||
//Handle the shapes dependent on animation transforms
|
//Handle the shapes dependent on animation transforms
|
||||||
time += timepassed;
|
time += timepassed;
|
||||||
if(time > transformations->begin()->getStopTime()){
|
if(time > stopTime){
|
||||||
animate = false;
|
animate--;
|
||||||
std::cout << "Stopping the animation\n";
|
//std::cout << "Stopping the animation\n";
|
||||||
return;
|
if(animate == 0)
|
||||||
|
time = stopTime;
|
||||||
|
else
|
||||||
|
time = startTime + (time - stopTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAnimationTransforms();
|
handleAnimationTransforms();
|
||||||
|
@ -56,6 +56,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||||||
NifOgre::NIFLoader::load(smodel);
|
NifOgre::NIFLoader::load(smodel);
|
||||||
|
|
||||||
base = mRend.getScene()->createEntity(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)){
|
if(transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel)){
|
||||||
@ -226,10 +228,17 @@ void NpcAnimation::runAnimation(float timepassed){
|
|||||||
//Handle the animation transforms dependent on time
|
//Handle the animation transforms dependent on time
|
||||||
|
|
||||||
//Handle the shapes dependent on animation transforms
|
//Handle the shapes dependent on animation transforms
|
||||||
if(animate){
|
if(animate > 0){
|
||||||
time += timepassed;
|
time += timepassed;
|
||||||
|
|
||||||
|
if(time > stopTime){
|
||||||
|
animate--;
|
||||||
|
//std::cout << "Stopping the animation\n";
|
||||||
|
if(animate == 0)
|
||||||
|
time = stopTime;
|
||||||
|
else
|
||||||
|
time = startTime + (time - stopTime);
|
||||||
|
}
|
||||||
|
|
||||||
handleAnimationTransforms();
|
handleAnimationTransforms();
|
||||||
// handleAnimationTransforms(base);
|
// handleAnimationTransforms(base);
|
||||||
@ -252,5 +261,6 @@ void NpcAnimation::runAnimation(float timepassed){
|
|||||||
entitypartsiter++;
|
entitypartsiter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ namespace MWRender{
|
|||||||
class NpcAnimation: public Animation{
|
class NpcAnimation: public Animation{
|
||||||
|
|
||||||
Ogre::SceneNode* insert;
|
Ogre::SceneNode* insert;
|
||||||
std::vector<std::vector<Nif::NiTriShapeCopy>* > shapeparts; //All the NiTriShape data that we need for animating this particular npc
|
|
||||||
public:
|
public:
|
||||||
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
||||||
~NpcAnimation();
|
~NpcAnimation();
|
||||||
|
@ -240,6 +240,7 @@ std::cout<<"play animation " << groupName << ", " << mode << ", " << number << s
|
|||||||
void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr)
|
void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
std::cout<<"skip animation"<<std::endl;
|
std::cout<<"skip animation"<<std::endl;
|
||||||
|
mActors.skipAnimation(ptr);
|
||||||
}
|
}
|
||||||
void RenderingManager::addTime(){
|
void RenderingManager::addTime(){
|
||||||
mActors.addTime();
|
mActors.addTime();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user