1 #include "AnimationNodeFactory.h" 2 #include "FadeController.h" 3 #include "LoopController.h" 4 #include "Group2Controller.h" 5 #include "EventController.h" 6 #include "WeightController.h" 7 #include "PositionController.h" 8 #include "SkeletonState.h" 9 //#include "SoundState.h" 10 11 namespace animation 12 { 13 AnimationNodeFactory()14 AnimationNodeFactory::AnimationNodeFactory() 15 { 16 addConstruct("FadeController", new AnimationNodeConstruct<FadeController>()); 17 addConstruct("LoopController", new AnimationNodeConstruct<LoopController>()); 18 addConstruct("Group2Controller", new AnimationNodeConstruct<Group2Controller>()); 19 addConstruct("EventController", new AnimationNodeConstruct<EventController>()); 20 addConstruct("WeightController", new AnimationNodeConstruct<WeightController>()); 21 addConstruct("PositionController", new AnimationNodeConstruct<PositionController>()); 22 addConstruct("SkeletonState", new AnimationNodeConstruct<SkeletonState>()); 23 //addConstruct("SoundState", new AnimationNodeConstruct<SoundState>()); 24 } 25 ~AnimationNodeFactory()26 AnimationNodeFactory::~AnimationNodeFactory() 27 { 28 for (MapConstruct::iterator item = mConstructs.begin(); item != mConstructs.end(); ++item) 29 delete (*item).second; 30 mConstructs.clear(); 31 } 32 createNode(const std::string & _type,const std::string & _name,IAnimationGraph * _holder)33 IAnimationNode* AnimationNodeFactory::createNode(const std::string& _type, const std::string& _name, IAnimationGraph* _holder) 34 { 35 MapConstruct::iterator item = mConstructs.find(_type); 36 if (item == mConstructs.end()) return 0; 37 return (*item).second->create(_name, _holder); 38 } 39 addConstruct(const std::string & _type,IAnimationNodeConstruct * _construct)40 void AnimationNodeFactory::addConstruct(const std::string& _type, IAnimationNodeConstruct* _construct) 41 { 42 mConstructs[_type] = _construct; 43 } 44 45 } // namespace animation 46