1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 10:23:51 +00:00

Deleting animations; Empty Functions/Planning

This commit is contained in:
Jason Hooks 2011-12-25 22:37:26 -05:00
parent 7eee54bcd7
commit 88c427543b
9 changed files with 48 additions and 4 deletions

View file

@ -71,6 +71,7 @@ void Actors::insertCreature (const MWWorld::Ptr& ptr){
bool Actors::deleteObject (const MWWorld::Ptr& ptr) bool Actors::deleteObject (const MWWorld::Ptr& ptr)
{ {
delete mAllActors[ptr];
mAllActors.erase(ptr); mAllActors.erase(ptr);
if (Ogre::SceneNode *base = ptr.getRefData().getBaseNode()) if (Ogre::SceneNode *base = ptr.getRefData().getBaseNode())
{ {
@ -105,6 +106,7 @@ void Actors::removeCell(MWWorld::Ptr::CellStore* store){
for(std::map<MWWorld::Ptr, Animation*>::iterator iter = mAllActors.begin(); iter != mAllActors.end(); iter++) for(std::map<MWWorld::Ptr, Animation*>::iterator iter = mAllActors.begin(); iter != mAllActors.end(); iter++)
{ {
if(iter->first.getCell() == store){ if(iter->first.getCell() == store){
delete iter->second;
mAllActors.erase(iter); mAllActors.erase(iter);
} }
} }

View file

@ -22,6 +22,11 @@ namespace MWRender{
out << "000"; out << "000";
out << counter; out << counter;
return out.str(); 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<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){ void Animation::handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){

View file

@ -23,6 +23,7 @@ class Animation{
float startTime; float startTime;
float stopTime; float stopTime;
bool loop; bool loop;
bool 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
@ -43,8 +44,11 @@ class Animation{
void handleAnimationTransforms(); void handleAnimationTransforms();
bool timeIndex( float time, std::vector<float> times, int & i, int & j, float & x ); bool timeIndex( float time, std::vector<float> times, int & i, int & j, float & x );
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){}; 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(); ~Animation();

View file

@ -35,9 +35,21 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
skel = base->getSkeleton(); skel = base->getSkeleton();
stopTime = transformations->begin()->getStopTime(); stopTime = transformations->begin()->getStopTime();
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start"); //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); 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
}
}
} }

View file

@ -14,10 +14,13 @@
namespace MWRender{ namespace MWRender{
class CreatureAnimation: public Animation{ class CreatureAnimation: public Animation{
std::vector<Nif::NiTriShapeCopy> shapes; //All the NiTriShapeData for this creature std::vector<Nif::NiTriShapeCopy>* shapes; //All the NiTriShapeData for this creature
public: public:
~CreatureAnimation(); ~CreatureAnimation();
CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
virtual void runAnimation(float timepassed);
}; };
} }
#endif #endif

View file

@ -9,6 +9,7 @@ NpcAnimation::~NpcAnimation(){
} }
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
@ -69,7 +70,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
skel = base->getSkeleton(); skel = base->getSkeleton();
stopTime = transformations->begin()->getStopTime(); stopTime = transformations->begin()->getStopTime();
//a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start"); //a.startTime = NIFLoader::getSingletonPtr()->getTime(item.smodel, "IdleSneak: Start");
startTime = transformations->end()->getStartTime(); startTime = transformations->begin()->getStartTime();
} }
insert->attachObject(base); 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
}
}
} }

View file

@ -23,6 +23,8 @@ class NpcAnimation: public Animation{
~NpcAnimation(); ~NpcAnimation();
Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename);
void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert); void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert);
virtual void runAnimation(float timepassed);
}; };
} }
#endif #endif

View file

@ -240,5 +240,8 @@ void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr)
{ {
std::cout<<"skip animation"<<std::endl; std::cout<<"skip animation"<<std::endl;
} }
void RenderingManager::addTime(float timepassed){
//Notify each animation that time has passed
}
} }

View file

@ -105,6 +105,8 @@ class RenderingManager: private RenderingInterface {
///< Skip the animation for the given MW-reference for one frame. Calls to this function for ///< Skip the animation for the given MW-reference for one frame. Calls to this function for
/// references that are currently not in the rendered scene should be ignored. /// references that are currently not in the rendered scene should be ignored.
void addTime(float timepassed);
private: private:
void setAmbientMode(); void setAmbientMode();