persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
AnimationController.hpp
Go to the documentation of this file.
1#pragma once
3#include <aegis/ndsTypes.hpp>
4
5#include <aegis/types.hpp>
6#include <nds.h>
7#include <vector>
8
17{
18 public:
20 static void create();
22 static void destroy();
25
31 bool loadModel(const char* filepath);
32
43 bool loadTextures(
44 int count, const unsigned int** bitmaps, const int* widths, const int* heights, const bool* isRGBA);
45
47 void unloadTextures();
48
54 void set(int animIndex, bool loop = true);
56 void play();
58 void stop();
60 void pause();
61
66 void setAnimationSpeed(ae::q20_12_t speedMultiplier = ae::q20_12_t{1.0})
67 {
68 animSpeedFP = (int)(speedMultiplier * ae::q20_12_t{128.0});
69 }
70
72 void update();
73
75 void render();
76
78 bool isAnimationPlaying() const
79 {
80 return isPlaying;
81 }
82
84 {
85 return currentAnimIndex;
86 }
87
88 private:
93
94 void renderNode(int nodeId);
95 Keyframe getInterpolatedFrame(const AnimTrack& track, int timeFP, int nodeId);
96 static int textureSizeToEnum(int px);
97
98 std::vector<AnimNode> modelNodes;
99 std::vector<Animation> animations;
100 std::vector<int> trackIndices; // Per-node cached search position.
101 std::vector<int> rootNodes;
102
103 // One GL texture ID per texture slot; empty when no textures are loaded.
104 std::vector<int> textureIDs;
105
108 int animSpeedFP = 128; // 128 = 0.5 frames per tick (converts 30fps to 60fps)
109 bool isPlaying = false;
110 bool isFinishing = false;
111 bool isLooping = true;
112};
void pause()
Finishes the current animation at its next boundary.
void play()
Starts the selected animation.
std::vector< int > rootNodes
static void destroy()
Destroys the singleton instance and unloads model textures.
void render()
Renders the model hierarchy using the current animation frame.
static AnimationController * getInstance()
~AnimationController()
Releases texture objects owned by the controller.
Keyframe getInterpolatedFrame(const AnimTrack &track, int timeFP, int nodeId)
void setAnimationSpeed(ae::q20_12_t speedMultiplier=ae::q20_12_t{1.0})
Sets animation playback speed.
static void create()
Creates the singleton instance if it does not exist.
void update()
Advances the selected animation by one frame tick.
static int textureSizeToEnum(int px)
void stop()
Stops playback and resets the selected animation frame.
static AnimationController * instance
bool loadModel(const char *filepath)
Loads an MDL2 or legacy MDL1 model file.
std::vector< int > textureIDs
std::vector< int > trackIndices
bool loadTextures(int count, const unsigned int **bitmaps, const int *widths, const int *heights, const bool *isRGBA)
Uploads model textures to VRAM after loadModel().
std::vector< AnimNode > modelNodes
void set(int animIndex, bool loop=true)
Selects an animation.
void unloadTextures()
Deletes all model texture objects from VRAM.
std::vector< Animation > animations