123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #ifndef __CCANIMATION3D_H__
- #define __CCANIMATION3D_H__
- #include <unordered_map>
- #include "3d/CCAnimationCurve.h"
- #include "base/ccMacros.h"
- #include "base/CCRef.h"
- #include "3d/CCBundle3DData.h"
- NS_CC_BEGIN
- class CC_DLL Animation3D: public Ref
- {
- friend class Bundle3D;
- public:
-
- class Curve
- {
- public:
- typedef AnimationCurve<3> AnimationCurveVec3;
- typedef AnimationCurve<4> AnimationCurveQuat;
-
- AnimationCurveVec3* translateCurve;
-
- AnimationCurveQuat* rotCurve;
-
- AnimationCurveVec3* scaleCurve;
-
- Curve();
-
- ~Curve();
- };
-
-
- static Animation3D* create(const std::string& filename, const std::string& animationName = "");
-
-
- CC_DEPRECATED_ATTRIBUTE static Animation3D* getOrCreate(const std::string& filename, const std::string& animationName = ""){ return create(filename, animationName); }
-
-
- float getDuration() const { return _duration; }
-
-
- Curve* getBoneCurveByName(const std::string& name) const;
-
-
- const std::unordered_map<std::string, Curve*>& getBoneCurves() const {return _boneCurves;}
-
- CC_CONSTRUCTOR_ACCESS:
- Animation3D();
- virtual ~Animation3D();
-
- bool init(const Animation3DData& data);
-
-
- bool initWithFile(const std::string& filename, const std::string& animationName);
-
- protected:
- std::unordered_map<std::string, Curve*> _boneCurves;
- float _duration;
- };
- class Animation3DCache
- {
- public:
-
- static Animation3DCache* getInstance();
- static void destroyInstance();
-
-
- Animation3D* getAnimation(const std::string& key);
-
-
- void addAnimation(const std::string& key, Animation3D* animation);
-
-
- void removeAllAnimations();
-
- void removeUnusedAnimation();
- protected:
- Animation3DCache();
- ~Animation3DCache();
-
- static Animation3DCache* _cacheInstance;
-
- std::unordered_map<std::string, Animation3D*> _animations;
- };
- NS_CC_END
- #endif
|