|
Motive Animation System
An open source project by
FPL.
|
Hold animation lists for several object types. More...
#include <anim_table.h>
Hold animation lists for several object types.
A list of lists of animations.
The outer list is indexed by object, the meaning of which is set by the user, but is most likely an enum for the character being animated (e.g. turtle, zombie, happy person, tall person, etc.).
The inner list is indexed by anim_idx, the meaning of which is also set by the user, but is most likely an enum for the action being animated (e.g. idle, walk forward, jump, etc.).
Duplicate animations are only loaded once. This allows different objects to use the same animations without any memory overhead.
Public Types | |
| typedef std::vector< std::string > | ListFileNames |
|
typedef std::vector < ListFileNames > | TableFileNames |
| typedef const char * | LoadFn (const char *file_name, std::string *scratch_buf) |
Public Member Functions | |
| bool | InitFromFlatBuffers (const AnimTableFb &table_fb, LoadFn *load_fn) |
| bool | InitFromFlatBuffers (const AnimListFb &list_fb, LoadFn *load_fn) |
| bool | InitFromAnimFileNames (const TableFileNames &table_names, LoadFn *load_fn) |
| bool | InitFromAnimFileNames (const ListFileNames &list_names, LoadFn *load_fn) |
Load the AnimTable for only one object. | |
| const RigAnim * | Query (int object, int anim_idx) const |
| const RigAnim * | QueryByName (const char *anim_name) const |
| const RigAnim & | DefiningAnim (int object) const |
| Return animation that defines the complete rig of this object. | |
| int | NumObjects () const |
| int | NumAnims (int object) const |
| int | NumUniqueAnims () const |
| typedef const char* motive::AnimTable::LoadFn(const char *file_name, std::string *scratch_buf) |
Callback that loads file_name and returns a pointer to the raw data. Optionally, the function can load the file into scratch_buf, and then return scratch_buf.c_str(). If the load fails, should return nullptr.
Note: Motive does not make assumptions on file io, so the caller must provide this function.
| bool motive::AnimTable::InitFromAnimFileNames | ( | const TableFileNames & | table_names, |
| LoadFn * | load_fn | ||
| ) |
Load the AnimTable specified in the vector of vectors. The top level vector represents the object index. The bottom level vector represents the anim_idx.
| bool motive::AnimTable::InitFromFlatBuffers | ( | const AnimTableFb & | table_fb, |
| LoadFn * | load_fn | ||
| ) |
| bool motive::AnimTable::InitFromFlatBuffers | ( | const AnimListFb & | list_fb, |
| LoadFn * | load_fn | ||
| ) |
Load the animations specified in the FlatBuffer list_fb. All of the loaded animations are for object 0.
|
inline |
Return size of the bottom-most vector. Recall that AnimTable is a vector of vectors.
|
inline |
Return size of the top-most vector. Recall that AnimTable is a vector of vectors.
|
inline |
Return the number of animations for which we've allocated memory. Internally, we avoid duplicating animations.
|
inline |
Get an animation by index. This is fast and is the preferred way to look up an animation.
| object | An enum defined by the caller specifying the object type. For example, if you want separate animations lists for cats and dogs, then object=0 could be cats, and object=1 could be dogs. The enum should run consecutively from 0 to number of object types -1. |
| anim_idx | An enum defined by the caller specifying the index into the animation list for object. If your cat can run and sleep, then you might make run=0 and sleep=1. Enum should run consecutively from 0 to the number of animations - 1. No need for the number of animations to match between objects. |
|
inline |
Get an animation by name. This is slow and should be avoided when possible.