Tramway SDK
animation.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_ARMATURE_H
5#define TRAM_SDK_ARMATURE_H
6
7#include <unordered_map>
8
9#include <framework/core.h>
10#include <framework/uid.h>
11#include <framework/resource.h>
12
13#include <framework/math.h>
14
15namespace tram::Render {
16
17typedef std::pair<name_t, uint64_t> NameCount; // animation header
18const size_t BONE_COUNT = 30; // bone count in a pose
19
20struct Bone {
22 int32_t parent = -1;
23 vec3 head = {0.0f, 0.0f, 0.0f};
24 vec3 tail = {1.0f, 1.0f, 1.0f};
25 float roll = 0.0f;
26};
27
28struct Keyframe {
29 float frame = 0.0f;
30 vec3 location = {0.0f, 0.0f, 0.0f};
31 quat rotation = {1.0f, 0.0f, 0.0f, 0.0f};
32 vec3 scale = {1.0f, 1.0f, 1.0f};
33 char padding[4]; // for emscripten ??
34};
35
36struct Pose {
38};
39
40class Animation : public Resource {
41public:
43
44 NameCount* GetPointer() { return animation_pointer; }
45
46 void LoadFromDisk();
48
49 void Unload() {}
50
51 static Animation* Find(name_t name);
52 static void LoadAll();
53private:
54 NameCount* animation_pointer = nullptr;
55};
56
57}
58
59#endif // TRAM_SDK_ARMATURE_H
Definition: animation.h:40
void LoadFromMemory()
Definition: animation.h:47
void LoadFromDisk()
Definition: animation.cpp:24
static Animation * Find(name_t name)
Definition: animation.cpp:71
void Unload()
Definition: animation.h:49
NameCount * GetPointer()
Definition: animation.h:44
Animation(name_t name)
Definition: animation.h:42
Definition: resource.h:12
name_t name
Definition: resource.h:38
Definition: gui.h:9
std::pair< name_t, uint64_t > NameCount
Definition: animation.h:17
const size_t BONE_COUNT
Definition: animation.h:18
glm::vec3 vec3
Definition: math.h:12
glm::quat quat
Definition: math.h:13
glm::mat4 mat4
Definition: math.h:15
Definition: animation.h:20
name_t name
Definition: animation.h:21
int32_t parent
Definition: animation.h:22
float roll
Definition: animation.h:25
vec3 tail
Definition: animation.h:24
vec3 head
Definition: animation.h:23
Definition: animation.h:28
float frame
Definition: animation.h:29
char padding[4]
Definition: animation.h:33
vec3 location
Definition: animation.h:30
vec3 scale
Definition: animation.h:32
quat rotation
Definition: animation.h:31
Definition: animation.h:36
mat4 pose[BONE_COUNT]
Definition: animation.h:37
Definition: uid.h:11