1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-05-09 10:34:05 +00:00

anim editor: support up to 9 tracks/anims at once. wip still.

This commit is contained in:
fgenesis 2025-01-12 02:15:19 +01:00
parent 2b2d4c712f
commit 8369a7168f
4 changed files with 717 additions and 385 deletions

File diff suppressed because it is too large Load diff

View file

@ -12,11 +12,23 @@ class DebugButton;
class Gradient;
// internal
class TimelineRender;
class KeyframeWidget;
struct AnimationEditorPage;
class TimelineTickRender;
class AnimationEditor : public StateObject
{
void _copyKey();
void _pasteKey();
enum EditMode
{
AE_SELECT, // moving mouse selects nearest bone
AE_EDITING_MOVE, // moving mouse moves editingBone
AE_EDITING_ROT, // moving mouse rotates editingBone
AE_STRIP, // in strip edit mode for editingBone
AE_SPLINE, // in spline edit mode for editingBone
};
public:
AnimationEditor();
void applyState();
@ -43,10 +55,8 @@ public:
void reorderKeys();
void saveFile();
void loadFile();
void copyKey();
void pasteKey();
void loadFile(const char *fn);
void reloadFile();
void nextAnim();
void prevAnim();
@ -77,32 +87,26 @@ public:
void undo();
void redo();
void pushUndo();
void clearUndoHistory();
void applyTranslation();
void applyRotation();
void moveNextWidgets(float dt);
std::deque<SkeletalSprite> undoHistory;
size_t undoEntry;
int currentKey;
int rotOffset;
SkeletalSprite *editSprite;
Bone *editingBone;
int boneEdit;
DebugFont *text, *text2;
Bone *editingBone; // only changed when editMode == AE_SELECT
SkeletalSprite *editingBoneSprite; // updated together with editingBone
int editingBonePage;
EditMode editMode;
DebugFont *text, *text2, *toptext;
void goToTitle();
SkeletalKeyframe copyBuffer;
std::string editingFile;
void action(int id, int state, int source, InputDevice device);
void rebuildKeyframeWidgets();
@ -118,9 +122,6 @@ public:
bool mouseSelection;
SkeletalKeyframe buffer;
bool editingStrip;
bool assistedSplineEdit;
size_t selectedStripPoint;
@ -155,9 +156,36 @@ public:
void toggleSplineMode();
DebugButton *bSplineAssist;
void updateButtonLabels();
void toggleGradient();
Gradient *bgGrad;
TimelineRender *timeline;
Animation *getPageAnimation(size_t page) const;
Animation *getCurrentPageAnimation() const;
SkeletalSprite *getPageSprite(size_t page) const;
SkeletalSprite *getCurrentPageSprite() const;
bool isAnimating() const;
float getAnimTime() const;
AnimationEditorPage *pages;
Quad *spriteRoot;
TimelineTickRender *timelineTicks;
void selectPage(unsigned page);
int curPage;
private:
void selectPage0() { selectPage(0); }
void selectPage1() { selectPage(1); }
void selectPage2() { selectPage(2); }
void selectPage3() { selectPage(3); }
void selectPage4() { selectPage(4); }
void selectPage5() { selectPage(5); }
void selectPage6() { selectPage(6); }
void selectPage7() { selectPage(7); }
void selectPage8() { selectPage(8); }
void _stopExtraEditModes();
};

View file

@ -555,6 +555,13 @@ Animation* AnimationLayer::getCurrentAnimation()
return &s->animations[currentAnimation];
}
Animation* AnimationLayer::getCurrentAnimationOrNull()
{
if (currentAnimation == -1)
return &blendAnimation;
return currentAnimation < s->animations.size() ? &s->animations[currentAnimation] : NULL;
}
void AnimationLayer::createTransitionAnimation(Animation& to, float time)
{
blendAnimation.keyframes.clear();
@ -1354,6 +1361,8 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
stopAnimation();
animLayers.clear();
deleteBones();
if(fn.empty())
return;
filenameLoaded = fn;
@ -1906,6 +1915,11 @@ Animation *SkeletalSprite::getCurrentAnimation(size_t layer)
return layer < animLayers.size() ? animLayers[layer].getCurrentAnimation() : NULL;
}
Animation *SkeletalSprite::getCurrentAnimationOrNull(size_t layer)
{
return layer < animLayers.size() ? animLayers[layer].getCurrentAnimationOrNull() : NULL;
}
void SkeletalSprite::setTime(float time, size_t layer)
{
if(layer < animLayers.size())
@ -2078,7 +2092,7 @@ void SkeletalSprite::setFreeze(bool f)
void SkeletalSprite::updateBones()
{
if (!frozen)
if (!frozen && isLoaded())
{
for (size_t i = 0; i < animLayers.size(); i++)
{

View file

@ -202,6 +202,7 @@ public:
AnimationLayer();
void setSkeletalSprite(SkeletalSprite *s);
Animation *getCurrentAnimation();
Animation *getCurrentAnimationOrNull();
void animate(const std::string &animation, int loop);
void update(float dt);
void updateBones();
@ -275,6 +276,7 @@ public:
Bone* getSelectedBone(bool mouseBased = true);
Animation *getCurrentAnimation(size_t layer=0);
Animation *getCurrentAnimationOrNull(size_t layer=0);
void nextAnimation();