Tiny3D
Loading...
Searching...
No Matches
t3dskeleton.h File Reference
#include "t3dmodel.h"
Include dependency graph for t3dskeleton.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  T3DBone
 
struct  T3DSkeleton
 

Functions

T3DSkeleton t3d_skeleton_create_buffered (const T3DModel *model, int bufferCount)
 
static T3DSkeleton t3d_skeleton_create (const T3DModel *model)
 
static void t3d_skeleton_use (const T3DSkeleton *skel)
 
T3DSkeleton t3d_skeleton_clone (const T3DSkeleton *skel, bool useMatrices)
 
void t3d_skeleton_reset (T3DSkeleton *skeleton)
 
void t3d_skeleton_blend (const T3DSkeleton *skelRes, const T3DSkeleton *skelA, const T3DSkeleton *skelB, float factor)
 
void t3d_skeleton_update (T3DSkeleton *skeleton)
 
void t3d_skeleton_destroy (T3DSkeleton *skeleton)
 
int t3d_skeleton_find_bone (T3DSkeleton *skeleton, const char *name)
 
static T3DVec3 t3d_skeleton_get_bone_pos_model_space (const T3DSkeleton *skeleton, int boneIdx)
 
static void t3d_model_draw_skinned (const T3DModel *model, const T3DSkeleton *skeleton)
 

Detailed Description

Function Documentation

◆ t3d_model_draw_skinned()

static void t3d_model_draw_skinned ( const T3DModel * model,
const T3DSkeleton * skeleton )
inlinestatic

Draws a skinned model with default settings. Alternatively, use 't3d_model_draw_custom' and set 'matrices' in the config.

Parameters
model

◆ t3d_skeleton_blend()

void t3d_skeleton_blend ( const T3DSkeleton * skelRes,
const T3DSkeleton * skelA,
const T3DSkeleton * skelB,
float factor )

Blends two skeletons together. Note: it is safe to use the same skeleton as an input and output parameter.

Parameters
skelResResulting skeleton
skelAFirst skeleton
skelBSecond skeleton
factorBlend factor (0.0-1.0), you are allowed to go beyond these values to "overdrive" animations

◆ t3d_skeleton_clone()

T3DSkeleton t3d_skeleton_clone ( const T3DSkeleton * skel,
bool useMatrices )

Clones a skeleton instance. This can also be used to create optimized skeletons for blending animations.

Parameters
skelSkeleton to clone
useMatricesIf false, no matrices will be allocated, this is useful for blending animations
Returns
Cloned skeleton

◆ t3d_skeleton_create()

static T3DSkeleton t3d_skeleton_create ( const T3DModel * model)
inlinestatic

Creates a skeleton instance from a model's skeleton definition

Parameters
modelThe model to create the skeleton from
Returns
The created skeleton

◆ t3d_skeleton_create_buffered()

T3DSkeleton t3d_skeleton_create_buffered ( const T3DModel * model,
int bufferCount )

Creates a skeleton instance from a model's skeleton definition. It will internally reserve multiple matrix stacks to allow for buffering. This can be used to update a skeleton while the last frame is still being rendered. Note that only the fixed-point matrices are buffered, the bone data itself is not.

Parameters
modelThe model to create the skeleton from
bufferCountnumber of buffers, should match the frame-buffer count
Returns
The created skeleton

◆ t3d_skeleton_destroy()

void t3d_skeleton_destroy ( T3DSkeleton * skeleton)

Frees data allocated in the skeleton struct. Note: it's safe to call this multiple times, pointers are set to NULL.

Parameters
skeletonThe skeleton to destroy

◆ t3d_skeleton_find_bone()

int t3d_skeleton_find_bone ( T3DSkeleton * skeleton,
const char * name )

Tries to finds a bone with the given name in the skeleton. Returns the index of the bone or -1 if not found.

Parameters
skeletonThe skeleton to search in
nameName of the bone to find
Returns
Index of the bone or -1 if not found

◆ t3d_skeleton_get_bone_pos_model_space()

static T3DVec3 t3d_skeleton_get_bone_pos_model_space ( const T3DSkeleton * skeleton,
int boneIdx )
inlinestatic

Gets the position in model space of the bone with the given index from its matrix. This assumes the bone matrix has been updated beforehand with t3d_skeleton_update.

Parameters
skeletonThe skeleton containing the bone
boneIdxIndex of the bone
Returns
The T3DVec3 position of the bone in model space

◆ t3d_skeleton_reset()

void t3d_skeleton_reset ( T3DSkeleton * skeleton)

Resets a skeleton to its initial state (resting pose). This can be useful when switching between animations. Note: To recalculate the bone matrices too, call 't3d_skeleton_update' afterwards.

Parameters
skeletonThe skeleton to reset

◆ t3d_skeleton_update()

void t3d_skeleton_update ( T3DSkeleton * skeleton)

Updates the skeleton's bone matrices if data has changed. Call this after making changes to the bones individual properties (pos/rot/scale). To make this work, the hasChanged flag in the bone must also be set

Parameters
skeletonThe skeleton to update

◆ t3d_skeleton_use()

static void t3d_skeleton_use ( const T3DSkeleton * skel)
inlinestatic

Sets the given skeleton up for the next draw call. This has to be used for buffered skeletons, but is a no-op for single-buffer skeletons.

Parameters
skelskeleton to use in the next draw