Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
AnimationClipAsset.hpp
1#pragma once
2
3#include <vector>
4#include "Common/Math.hpp"
5#include "EngineCore/Assets/Asset.hpp"
6
7namespace Grindstone {
8 struct AnimationClipAsset : public Asset {
9 enum class KeyframeInterpolation {
10 Step,
11 Linear,
12 Cubic
13 };
14
15 struct BoneChannel {
16 std::string boneName;
17 uint16_t positionCount = 0;
18 uint16_t scaleCount = 0;
19 uint16_t rotationCount = 0;
20 uint32_t positionKeyOffset = 0;
21 uint32_t rotationKeyOffset = 0;
22 uint32_t scaleKeyOffset = 0;
23 KeyframeInterpolation interpolation = KeyframeInterpolation::Linear;
24 };
25
26
27 template<typename T>
28 struct Keyframe {
29 double time;
30 T value;
31
32 Keyframe() = default;
33 Keyframe(const Keyframe& other) = default;
34 Keyframe(Keyframe&& other) noexcept = default;
35 Keyframe& operator=(const Keyframe& other) = default;
36 Keyframe& operator=(Keyframe&& other) noexcept = default;
37 Keyframe(double time, T value) : time(time), value(value) {}
38 };
39
40 using PositionKeyframe = Keyframe<Grindstone::Math::Float3>;
41 using RotationKeyframe = Keyframe<Grindstone::Math::Quaternion>;
42 using ScaleKeyframe = Keyframe<Grindstone::Math::Float3>;
43
44 std::vector<BoneChannel> boneChannels;
45 std::vector<PositionKeyframe> positions;
46 std::vector<RotationKeyframe> rotations;
47 std::vector<ScaleKeyframe> scales;
48
49 double ticksPerSecond = 0.0;
50 double duration = 0.0;
51
52 AnimationClipAsset(Uuid uuid, std::string_view name) : Asset(uuid, name) {}
53
54 DEFINE_ASSET_TYPE("AnimationClip", AssetType::AnimationClip)
55 };
56}
Definition Uuid.hpp:7
Definition ArchiveContentFile.hpp:8
Definition AnimationClipAsset.hpp:15
Definition AnimationClipAsset.hpp:28