-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBoneAnimation.hpp
More file actions
62 lines (47 loc) · 1.25 KB
/
Copy pathBoneAnimation.hpp
File metadata and controls
62 lines (47 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "GLBuffer.hpp"
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <map>
#include <string>
//"BoneAnimation" holds a mesh loaded from a file along with skin weights,
// a heirarchy of bones and their bind info,
// and a collection of animations defined on those bones
namespace kit {
struct BoneAnimation {
GLAttribPointer Position;
GLAttribPointer Normal;
GLAttribPointer Color;
GLAttribPointer TexCoord;
GLAttribPointer BoneWeights;
GLAttribPointer BoneIndices;
GLBuffer buffer;
uint32_t vertex_count = 0;
struct Bone {
std::string name;
uint32_t parent = -1U;
glm::mat4x3 inverse_bind_matrix;
};
std::vector< Bone > bones;
struct PoseBone {
glm::vec3 position;
glm::quat rotation;
glm::vec3 scale;
};
std::vector< PoseBone > frame_bones;
PoseBone const *get_frame(uint32_t frame) const {
return &frame_bones[frame * bones.size()];
}
struct Animation {
std::string name;
uint32_t begin = 0;
uint32_t end = 0;
};
std::vector< Animation > animations;
//look up a particular animation, will throw if not found:
const Animation &lookup(std::string const &name) const;
//construct from a file:
// note: will throw if file fails to read.
BoneAnimation(std::string const &filename);
};
}