Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "ShaderProgram.h"
- #include "AnimationData.h"
- #include "SceneNode.h"
- #include "Timer.h"
- #include <unordered_map>
- #include <cstdint> //for intptr_t
- struct AnimationSet {
- const AnimationData *animationData;
- SceneNode *sceneNode;
- bool operator==(const AnimationSet &other) const {
- return ( this->animationData == other.animationData &&
- this->sceneNode == other.sceneNode );
- }
- };
- //hash for AnimationSet
- namespace std {
- template<>
- struct hash<AnimationSet> {
- size_t operator()(const AnimationSet &set) const {
- hash<intptr_t> h;
- return h((intptr_t)set.animationData) ^ h((intptr_t)set.sceneNode);
- }
- };
- }
- class AnimationController
- {
- public:
- AnimationController() : _shaderProgram(nullptr) {}
- void playAnimation (const AnimationData *animationData, SceneNode *sceneNode);
- void pauseAnimation (const AnimationData *animationData, SceneNode *sceneNode);
- void resumeAnimation (const AnimationData *animationData, SceneNode *sceneNode);
- void stopAnimation (const AnimationData *animationData, SceneNode *sceneNode);
- void updateAnimation (const AnimationData *animationData, SceneNode *sceneNode);
- void setShaderProgram(ShaderProgram *shaderProgram) { _shaderProgram = shaderProgram; }
- private:
- std::unordered_map<AnimationSet, Timer> _animations;
- ShaderProgram *_shaderProgram;
- Timer* _getTimer(const AnimationData *animationData, SceneNode *sceneNode);
- void _updateSceneNode(SceneNode *sceneNode, double time, std::unordered_map<std::string, NodeAnimationData*> *nodeAnimations);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement