diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index dc99d8809..38ed3a2b3 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -71,6 +71,7 @@ void Actors::insertCreature (const MWWorld::Ptr& ptr){ bool Actors::deleteObject (const MWWorld::Ptr& ptr) { + delete mAllActors[ptr]; mAllActors.erase(ptr); if (Ogre::SceneNode *base = ptr.getRefData().getBaseNode()) { @@ -105,6 +106,7 @@ void Actors::removeCell(MWWorld::Ptr::CellStore* store){ for(std::map::iterator iter = mAllActors.begin(); iter != mAllActors.end(); iter++) { if(iter->first.getCell() == store){ + delete iter->second; mAllActors.erase(iter); } } diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 1c8ceffd7..3b5b58e7f 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -23,6 +23,11 @@ namespace MWRender{ out << counter; return out.str(); } + void Animation::startScript(std::string groupname, int mode, int loops){ + //If groupname is recognized set animate to true + //Set the start time and stop time + //How many times to loop + } void Animation::handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){ shapeNumber = 0; diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index acead8c07..57673061d 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -23,6 +23,7 @@ class Animation{ float startTime; float stopTime; bool loop; + bool animate; //Represents a rotation index for each bone std::vectorrindexI; //Represents a translation index for each bone @@ -43,8 +44,11 @@ class Animation{ void handleAnimationTransforms(); bool timeIndex( float time, std::vector times, int & i, int & j, float & x ); std::string getUniqueID(std::string mesh); + public: - Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env){}; + Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), loop(false), animate(false){}; + virtual void runAnimation(float timepassed) = 0; + void startScript(std::string groupname, int mode, int loops); ~Animation(); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index b2be18993..c9c4d7d16 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -35,9 +35,21 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme skel = base->getSkeleton(); stopTime = transformations->begin()->getStopTime(); //a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start"); - startTime = transformations->end()->getStartTime(); + startTime = transformations->begin()->getStartTime(); + shapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero); } 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 + + } +} } \ No newline at end of file diff --git a/apps/openmw/mwrender/creatureanimation.hpp b/apps/openmw/mwrender/creatureanimation.hpp index 9bbd149ce..4c2b2ec77 100644 --- a/apps/openmw/mwrender/creatureanimation.hpp +++ b/apps/openmw/mwrender/creatureanimation.hpp @@ -14,10 +14,13 @@ namespace MWRender{ class CreatureAnimation: public Animation{ - std::vector shapes; //All the NiTriShapeData for this creature + std::vector* shapes; //All the NiTriShapeData for this creature public: ~CreatureAnimation(); CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); + virtual void runAnimation(float timepassed); + + }; } #endif \ No newline at end of file diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 4a8bac655..405a60c4e 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -9,6 +9,7 @@ NpcAnimation::~NpcAnimation(){ } + NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){ ESMS::LiveCellRef *ref = ptr.get(); @@ -69,7 +70,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O skel = base->getSkeleton(); stopTime = transformations->begin()->getStopTime(); //a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start"); - startTime = transformations->end()->getStartTime(); + startTime = transformations->begin()->getStartTime(); } insert->attachObject(base); @@ -217,4 +218,14 @@ void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suf } + +void NpcAnimation::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 + } +} } \ No newline at end of file diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 9ecabd254..1ce949f3a 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -23,6 +23,8 @@ class NpcAnimation: public Animation{ ~NpcAnimation(); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert); + virtual void runAnimation(float timepassed); + }; } #endif \ No newline at end of file diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 6f21db2b3..fd74c282f 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -240,5 +240,8 @@ void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr) { std::cout<<"skip animation"<