OSDN Git Service

0daa67782c244c25fd585fceb69026a9011a42fc
[moflib/moflib.git] / moflib-1.0 / moflib / moflib / mof / GraphicsSchedule.cpp
1 #include "mof/GraphicsSchedule.h"
2 #include "mof/ConsoleIO.h"
3
4
5
6
7
8 mof::GraphicsSchedule::GraphicsSchedule(){
9         m_key = 0;
10
11 }
12
13 mof::GraphicsSchedule::~GraphicsSchedule(){
14         
15 }
16
17 void mof::GraphicsSchedule::update(){
18         
19         std::pair<MapItr , MapItr> range = m_map.equal_range(m_key);
20         for(MapItr itr = range.first ; itr != range.second ; ++itr){
21                 if((*itr).second.pAnimation.get() != NULL){
22                         (*itr).second.pObject->setAnimation(0 , (*itr).second.pAnimation);
23                         (*itr).second.pAnimation->start();
24                 }
25         }
26         
27         m_key++;
28 }
29
30 void mof::GraphicsSchedule::add(int index , mof::GraphicsModelPtr& pObject , mof::AnimationResource& pAnimation){
31         if(pObject.get() == NULL)return;
32         if(pAnimation.get() != NULL)pAnimation->stop();
33         mof::GraphicsSchedule::Element element = {pObject , pAnimation };
34         m_modelList.push_back(pObject);
35         m_map.insert(std::multimap<mof::AnimationKey , mof::GraphicsSchedule::Element>::value_type(index , element));
36 }
37                 
38 std::list<mof::GraphicsModelPtr>& mof::GraphicsSchedule::appendModelList( std::list<mof::GraphicsModelPtr>& modelList){
39         modelList.insert(modelList.end() , m_modelList.begin() , m_modelList.end());
40         return modelList;
41 }
42                 
43
44
45                 
46 bool mof::GraphicsSchedule::isFinalized(){
47         if(m_map.size() == 0)return true;
48         for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){
49                 if(!itr->second.pAnimation->isFinalized() )return false;
50         }
51         return true;
52 }
53
54                 
55 bool mof::GraphicsSchedule::isPlaying(){
56         for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){
57                 if(itr->second.pAnimation->isPlaying() || itr->second.pAnimation->isFinalized())return true;
58         }
59         return false;
60 }
61
62
63 void mof::GraphicsSchedule::clear(){
64         m_key = 0;
65         m_map.clear();
66 }