Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
animation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <map>
5#include <glm/glm.hpp>
6#include <assimp/scene.h>
7#include <functional>
8#include "client/bone.hpp"
9#include "client/model.hpp"
10#include "client/util.hpp"
11
13 glm::mat4 transformation;
14 std::string name;
16 std::vector<AssimpNodeData> children;
17};
18
19class Animation {
20public:
21 Animation() = default;
22
23 Animation(const std::string& animationPath, Model* model);
24
25 Animation(const std::string& animationDirPath, const std::string& animName, int frames);
26
28
29 Bone* findBone(const std::string& name);
30
31 inline float getTicksPerSecond() { return m_ticksPerSecond; }
32 inline float getDuration() { return m_duration;}
33 inline const AssimpNodeData& getRootNode() { return m_rootNode; }
34 inline const std::map<std::string,BoneInfo>& getBoneIDMap() { return m_boneInfoMap; }
35 inline Model* getFrame(int frame) { return model_keyframes[(frame % model_keyframes.size())]; }
36 inline int getKeyframeSize() { return model_keyframes.size(); }
37
38private:
39 void readMissingBones(const aiAnimation* animation, Model& model);
40
41 void readHierarchyData(AssimpNodeData& dest, const aiNode* src);
42
43 float m_duration;
44 int m_ticksPerSecond;
45 std::vector<Bone> m_bones;
46 AssimpNodeData m_rootNode;
47 std::map<std::string, BoneInfo> m_boneInfoMap;
48 std::vector<Model*> model_keyframes;
49};
Definition: animation.hpp:19
float getTicksPerSecond()
Definition: animation.hpp:31
const AssimpNodeData & getRootNode()
Definition: animation.hpp:33
int getKeyframeSize()
Definition: animation.hpp:36
~Animation()
Definition: animation.hpp:27
Animation()=default
Model * getFrame(int frame)
Definition: animation.hpp:35
Bone * findBone(const std::string &name)
Definition: animation.cpp:31
const std::map< std::string, BoneInfo > & getBoneIDMap()
Definition: animation.hpp:34
float getDuration()
Definition: animation.hpp:32
Definition: bone.hpp:33
Definition: model.hpp:124
GLenum src
Definition: glad.h:2677
GLuint const GLchar * name
Definition: glad.h:1846
Definition: animation.hpp:12
std::string name
Definition: animation.hpp:14
std::vector< AssimpNodeData > children
Definition: animation.hpp:16
glm::mat4 transformation
Definition: animation.hpp:13
int numChildren
Definition: animation.hpp:15