persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
AnimationController Class Reference

Loads, animates, and renders a model in the DS geometry engine. More...

#include <AnimationController.hpp>

Collaboration diagram for AnimationController:

Public Member Functions

bool loadModel (const char *filepath)
 Loads an MDL2 or legacy MDL1 model file.
bool loadTextures (int count, const unsigned int **bitmaps, const int *widths, const int *heights, const bool *isRGBA)
 Uploads model textures to VRAM after loadModel().
void unloadTextures ()
 Deletes all model texture objects from VRAM.
void set (int animIndex, bool loop=true)
 Selects an animation.
void play ()
 Starts the selected animation.
void stop ()
 Stops playback and resets the selected animation frame.
void pause ()
 Finishes the current animation at its next boundary.
void setAnimationSpeed (ae::q20_12_t speedMultiplier=ae::q20_12_t{1.0})
 Sets animation playback speed.
void update ()
 Advances the selected animation by one frame tick.
void render ()
 Renders the model hierarchy using the current animation frame.
bool isAnimationPlaying () const
int getCurrentAnimIndex () const

Static Public Member Functions

static void create ()
 Creates the singleton instance if it does not exist.
static void destroy ()
 Destroys the singleton instance and unloads model textures.
static AnimationController * getInstance ()

Private Member Functions

 AnimationController ()
 ~AnimationController ()
 Releases texture objects owned by the controller.
void renderNode (int nodeId)
Keyframe getInterpolatedFrame (const AnimTrack &track, int timeFP, int nodeId)

Static Private Member Functions

static int textureSizeToEnum (int px)

Private Attributes

std::vector< AnimNode > modelNodes
std::vector< Animation > animations
std::vector< int > trackIndices
std::vector< int > rootNodes
std::vector< int > textureIDs
int currentAnimIndex = -1
int currentFrameFP = 0
int animSpeedFP = 128
bool isPlaying = false
bool isFinishing = false
bool isLooping = true

Static Private Attributes

static AnimationController * instance = nullptr

Detailed Description

Loads, animates, and renders a model in the DS geometry engine.

Model files provide node hierarchies, animation tracks, and display lists. Texture data is supplied separately by generated model helpers and uploaded to VRAM through this controller.

Definition at line 16 of file AnimationController.hpp.

Constructor & Destructor Documentation

◆ AnimationController()

AnimationController::AnimationController ( )
private

Definition at line 34 of file AnimationController.cpp.

Here is the caller graph for this function:

◆ ~AnimationController()

AnimationController::~AnimationController ( )
private

Releases texture objects owned by the controller.

Definition at line 38 of file AnimationController.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ create()

void AnimationController::create ( )
static

Creates the singleton instance if it does not exist.

Definition at line 8 of file AnimationController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy()

void AnimationController::destroy ( )
static

Destroys the singleton instance and unloads model textures.

Definition at line 16 of file AnimationController.cpp.

◆ getCurrentAnimIndex()

int AnimationController::getCurrentAnimIndex ( ) const
inline
Returns
The selected animation index, or -1 when none is selected.

Definition at line 83 of file AnimationController.hpp.

◆ getInstance()

AnimationController * AnimationController::getInstance ( )
static
Returns
The process-wide animation controller instance.

Definition at line 25 of file AnimationController.cpp.

Here is the call graph for this function:

◆ getInterpolatedFrame()

Keyframe AnimationController::getInterpolatedFrame ( const AnimTrack & track,
int timeFP,
int nodeId )
private

Definition at line 345 of file AnimationController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAnimationPlaying()

bool AnimationController::isAnimationPlaying ( ) const
inline
Returns
true when animation playback is active.

Definition at line 78 of file AnimationController.hpp.

◆ loadModel()

bool AnimationController::loadModel ( const char * filepath)

Loads an MDL2 or legacy MDL1 model file.

Parameters
filepathPath to the compiled model binary.
Returns
true if the model was opened and parsed successfully.

Definition at line 96 of file AnimationController.cpp.

Here is the call graph for this function:

◆ loadTextures()

bool AnimationController::loadTextures ( int count,
const unsigned int ** bitmaps,
const int * widths,
const int * heights,
const bool * isRGBA )

Uploads model textures to VRAM after loadModel().

Parameters
countNumber of texture slots.
bitmapsGrit-generated bitmap data, one pointer per slot.
widthsTexture widths in pixels.
heightsTexture heights in pixels.
isRGBAtrue for RGBA textures, false for RGB textures.
Returns
true after texture slots have been allocated and uploaded.
Note
Generated model texture helpers supply the required metadata.

Definition at line 225 of file AnimationController.cpp.

Here is the call graph for this function:

◆ pause()

void AnimationController::pause ( )

Finishes the current animation at its next boundary.

Definition at line 306 of file AnimationController.cpp.

◆ play()

void AnimationController::play ( )

Starts the selected animation.

Definition at line 283 of file AnimationController.cpp.

◆ render()

void AnimationController::render ( )

Renders the model hierarchy using the current animation frame.

Definition at line 407 of file AnimationController.cpp.

Here is the call graph for this function:

◆ renderNode()

void AnimationController::renderNode ( int nodeId)
private

Definition at line 424 of file AnimationController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set()

void AnimationController::set ( int animIndex,
bool loop = true )

Selects an animation.

Parameters
animIndexAnimation index in the loaded model.
loopWhether playback should loop when it reaches the end.

Definition at line 268 of file AnimationController.cpp.

Here is the call graph for this function:

◆ setAnimationSpeed()

void AnimationController::setAnimationSpeed ( ae::q20_12_t speedMultiplier = ae::q20_12_t{1.0})
inline

Sets animation playback speed.

Parameters
speedMultiplierMultiplier relative to the default speed.

Definition at line 66 of file AnimationController.hpp.

◆ stop()

void AnimationController::stop ( )

Stops playback and resets the selected animation frame.

Definition at line 298 of file AnimationController.cpp.

◆ textureSizeToEnum()

int AnimationController::textureSizeToEnum ( int px)
staticprivate

Definition at line 43 of file AnimationController.cpp.

Here is the caller graph for this function:

◆ unloadTextures()

void AnimationController::unloadTextures ( )

Deletes all model texture objects from VRAM.

Definition at line 257 of file AnimationController.cpp.

Here is the caller graph for this function:

◆ update()

void AnimationController::update ( )

Advances the selected animation by one frame tick.

Definition at line 311 of file AnimationController.cpp.

Member Data Documentation

◆ animations

std::vector<Animation> AnimationController::animations
private

Definition at line 99 of file AnimationController.hpp.

◆ animSpeedFP

int AnimationController::animSpeedFP = 128
private

Definition at line 108 of file AnimationController.hpp.

◆ currentAnimIndex

int AnimationController::currentAnimIndex = -1
private

Definition at line 106 of file AnimationController.hpp.

◆ currentFrameFP

int AnimationController::currentFrameFP = 0
private

Definition at line 107 of file AnimationController.hpp.

◆ instance

AnimationController * AnimationController::instance = nullptr
staticprivate

Definition at line 92 of file AnimationController.hpp.

◆ isFinishing

bool AnimationController::isFinishing = false
private

Definition at line 110 of file AnimationController.hpp.

◆ isLooping

bool AnimationController::isLooping = true
private

Definition at line 111 of file AnimationController.hpp.

◆ isPlaying

bool AnimationController::isPlaying = false
private

Definition at line 109 of file AnimationController.hpp.

◆ modelNodes

std::vector<AnimNode> AnimationController::modelNodes
private

Definition at line 98 of file AnimationController.hpp.

◆ rootNodes

std::vector<int> AnimationController::rootNodes
private

Definition at line 101 of file AnimationController.hpp.

◆ textureIDs

std::vector<int> AnimationController::textureIDs
private

Definition at line 104 of file AnimationController.hpp.

◆ trackIndices

std::vector<int> AnimationController::trackIndices
private

Definition at line 100 of file AnimationController.hpp.


The documentation for this class was generated from the following files: