Add a method to get the Animation from a Ptr

This commit is contained in:
Chris Robinson 2013-01-16 09:59:19 -08:00
parent c1b32d6006
commit 63e685ea39
7 changed files with 34 additions and 0 deletions

View file

@ -36,6 +36,7 @@ namespace ESM
namespace MWRender
{
class ExternalRendering;
class Animation;
}
namespace MWWorld
@ -308,6 +309,9 @@ namespace MWBase
/// 3 - enemies are nearby (not implemented)
/// \todo Probably shouldn't be here
virtual MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr) = 0;
/// \todo this does not belong here
virtual void playVideo(const std::string& name, bool allowSkipping) = 0;
virtual void stopVideo() = 0;

View file

@ -145,6 +145,14 @@ void Actors::update (float duration)
iter->second->runAnimation(duration);
}
Animation* Actors::getAnimation(const MWWorld::Ptr &ptr)
{
PtrAnimationMap::const_iterator iter = mAllActors.find(ptr);
if(iter != mAllActors.end())
return iter->second;
return NULL;
}
void Actors::updateObjectCell(const MWWorld::Ptr &ptr)
{
Ogre::SceneNode *node;

View file

@ -54,6 +54,8 @@ namespace MWRender
/// Updates containing cell for object rendering data
void updateObjectCell(const MWWorld::Ptr &ptr);
Animation* getAnimation(const MWWorld::Ptr &ptr);
};
}
#endif

View file

@ -929,6 +929,14 @@ void RenderingManager::setupExternalRendering (MWRender::ExternalRendering& rend
rendering.setup (mRendering.getScene());
}
Animation* RenderingManager::getAnimation(const MWWorld::Ptr &ptr)
{
Animation *anim = mActors.getAnimation(ptr);
// TODO: Check mObjects too.
return anim;
}
void RenderingManager::playVideo(const std::string& name, bool allowSkipping)
{
mVideoPlayer->playVideo ("video/" + name, allowSkipping);

View file

@ -46,6 +46,7 @@ namespace MWRender
class ExternalRendering;
class GlobalMap;
class VideoPlayer;
class Animation;
class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener {
@ -196,6 +197,8 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
void setupExternalRendering (MWRender::ExternalRendering& rendering);
Animation* getAnimation(const MWWorld::Ptr &ptr);
void playVideo(const std::string& name, bool allowSkipping);
void stopVideo();

View file

@ -1374,6 +1374,11 @@ namespace MWWorld
}
MWRender::Animation* World::getAnimation(const MWWorld::Ptr &ptr)
{
return mRendering->getAnimation(ptr);
}
void World::playVideo (const std::string &name, bool allowSkipping)
{
mRendering->playVideo(name, allowSkipping);

View file

@ -37,6 +37,7 @@ namespace MWRender
{
class SkyManager;
class CellRender;
class Animation;
}
namespace MWWorld
@ -352,6 +353,9 @@ namespace MWWorld
/// 2 - player is underwater \n
/// 3 - enemies are nearby (not implemented)
/// \todo Probably shouldn't be here
virtual MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr);
/// \todo this does not belong here
virtual void playVideo(const std::string& name, bool allowSkipping);
virtual void stopVideo();