-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathAnimationLoader.cpp
More file actions
37 lines (31 loc) · 858 Bytes
/
AnimationLoader.cpp
File metadata and controls
37 lines (31 loc) · 858 Bytes
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
#include "stdafx.h"
#include "AssetLoaders.h"
namespace happy
{
template <typename T> T read(istream &s)
{
T val;
s.read(reinterpret_cast<char*>(&val), sizeof(T));
return val;
}
Animation loadAnimationFromDanceFile(RenderingContext *pRenderContext, fs::path animPath)
{
std::ifstream fin(animPath.c_str(), std::ios::in | std::ios::binary);
float framerate = read<float>(fin);
uint32_t frameCount = read<uint32_t>(fin);
uint32_t boneCount = read<uint32_t>(fin);
vector<bb::mat4> animation;
animation.reserve(frameCount * boneCount);
for (unsigned f = 0; f < frameCount; ++f)
{
for (unsigned b = 0; b < boneCount; ++b)
{
bb::mat4 pose = read<bb::mat4>(fin);
animation.push_back(pose);
}
}
Animation anim;
anim.setAnimation(pRenderContext, animation, boneCount, frameCount, framerate);
return anim;
}
}