-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathAnimationSequencer.h
More file actions
113 lines (92 loc) · 3.59 KB
/
Copy pathAnimationSequencer.h
File metadata and controls
113 lines (92 loc) · 3.59 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// Created by engin on 8.06.2018.
//
#ifndef LIMONENGINE_ANIMATIONSEQUENCE_H
#define LIMONENGINE_ANIMATIONSEQUENCE_H
#include <vector>
#include <memory>
#include "../libs/ImGuizmo/ImSequencer.h"
#include "Transformation.h"
class Renderable;
class AnimationCustom;
class AnimationNode;
class AnimationSequenceInterface : public ImSequencer::SequenceInterface {
int startTime = 0;
Transformation originalTransformation;
struct AnimationSequenceItem {
int mFrameEnd;
//it should save a transformation, that is the difference from start. We can safely assume point 0 is ineffective transform
Transformation transformation;
};
std::vector<AnimationSequenceItem> sections;
Renderable* animatingObject;
AnimationCustom* animationInProgress = nullptr;
/********************IMGUI variables *************************/
char animationNameBuffer[32] {0};
int selectedEntry = 0;//to show this, we must have created 1 element. that one is selected
int firstFrame = 0;
bool expanded = true;
/********************IMGUI variables *************************/
/**
* Animation to fill should be created(not null, and its animation node set to not null too), and empty.
*
* @param item
* @param animationToFill
*/
void fillAnimationFromItem(uint32_t itemIndex, AnimationCustom *animationToFill, const Transformation& sourceTransform, bool useStacked) const;
void pushTransformToAnimationTime(std::shared_ptr<AnimationNode> animationNode, float time, const Transformation &transformation) const;
void pushIdentityToAnimationTime(std::shared_ptr<AnimationNode> animationNode, float time) const;
public:
int mFrameCount = 120;
int GetFrameCount() const { return mFrameCount; }
int GetItemCount() const override { return (int)sections.size(); }
int GetItemTypeCount() const override { return 1; }
const char *GetItemTypeName(int typeIndex [[gnu::unused]]) const override { return "Section"; }
const char *GetItemLabel(int index) const override {
static char tmps[512];
sprintf(tmps, "[%02d] %s", index, "Section");
return tmps;
}
void Get(int index, int** start, int** end, int *type, unsigned int *color) override {
AnimationSequenceItem &item = sections[index];
if (color) {
*color = 0xFFAA8080; // same color for everyone, return color based on type
}
if (start) {
if(index == 0) {
*start = &startTime;
} else {
*start = §ions[index-1].mFrameEnd;
}
}
if (end) {
*end = &item.mFrameEnd;
}
if (type) {
*type = 0;//we don't have multiple types
}
}
void Add(int type [[gnu::unused]]) override;
void setTransform(int32_t indexToSet);
void Del(int index) override {
//don't allow deleting last element
if(sections.size()>1) {
sections.erase(sections.begin() + index);
}
}
void Duplicate(int index) override;
const Renderable *getAnimatingObject() const {
return animatingObject;
}
explicit AnimationSequenceInterface(Renderable* animatingObject);
~AnimationSequenceInterface() override;
AnimationCustom* buildAnimationFromCurrentItems();
/**
* Returns whether animation finished or not
* @return
*/
void addAnimationSequencerToEditor(bool &finished, bool &cancelled);
int GetFrameMin() const override {return 0;};
int GetFrameMax() const override {return mFrameCount;};
};
#endif //LIMONENGINE_ANIMATIONSEQUENCE_H