Kemena3D
Loading...
Searching...
No Matches
kemena::kBone Class Reference

Represents one bone in a skeletal animation. More...

#include <kbone.h>

Public Member Functions

 kBone (const kString &boneName, int boneID, aiNodeAnim *channel)
 Constructs a bone from an Assimp animation channel.
 kBone (const kString &boneName, int boneID, std::vector< kKeyPosition > positions, std::vector< kKeyRotation > rotations, std::vector< kKeyScale > scales)
 Constructs a bone from already-decoded keyframe arrays.
void update (float animationTime)
 Interpolates all channels and updates the local transform.
const kMat4 getLocalTransform () const
 Returns the interpolated local transform for the current time.
const kString getName () const
 Returns the bone name.
const int getID () const
 Returns the bone palette index.
int getPositionIndex (float animationTime)
 Finds the index of the position keyframe just before animationTime.
int getRotationIndex (float animationTime)
 Finds the index of the rotation keyframe just before animationTime.
int getScaleIndex (float animationTime)
 Finds the index of the scale keyframe just before animationTime.

Detailed Description

Represents one bone in a skeletal animation.

Constructed from an Assimp node animation channel. Each frame, call update() with the current animation time to interpolate between keyframes and store the result in the local transform matrix, which is read by kAnimator::calculateBoneTransform().

Constructor & Destructor Documentation

◆ kBone() [1/2]

kemena::kBone::kBone ( const kString & boneName,
int boneID,
aiNodeAnim * channel )

Constructs a bone from an Assimp animation channel.

Parameters
boneNameHuman-readable bone name.
boneIDIndex into the mesh's bone palette.
channelAssimp node animation containing keyframe data.

◆ kBone() [2/2]

kemena::kBone::kBone ( const kString & boneName,
int boneID,
std::vector< kKeyPosition > positions,
std::vector< kKeyRotation > rotations,
std::vector< kKeyScale > scales )

Constructs a bone from already-decoded keyframe arrays.

Library-agnostic — populate the channel vectors from whatever importer (Assimp / tinygltf / custom) sourced them.

Member Function Documentation

◆ getID()

const int kemena::kBone::getID ( ) const

Returns the bone palette index.

Returns
Zero-based index into the mesh's bone array.

◆ getLocalTransform()

const kMat4 kemena::kBone::getLocalTransform ( ) const

Returns the interpolated local transform for the current time.

Returns
4x4 local-space bone transform matrix.

◆ getName()

const kString kemena::kBone::getName ( ) const

Returns the bone name.

Returns
Bone name as it appears in the asset.

◆ getPositionIndex()

int kemena::kBone::getPositionIndex ( float animationTime)

Finds the index of the position keyframe just before animationTime.

Parameters
animationTimeCurrent playback time in ticks.
Returns
Index of the preceding position keyframe.

◆ getRotationIndex()

int kemena::kBone::getRotationIndex ( float animationTime)

Finds the index of the rotation keyframe just before animationTime.

Parameters
animationTimeCurrent playback time in ticks.
Returns
Index of the preceding rotation keyframe.

◆ getScaleIndex()

int kemena::kBone::getScaleIndex ( float animationTime)

Finds the index of the scale keyframe just before animationTime.

Parameters
animationTimeCurrent playback time in ticks.
Returns
Index of the preceding scale keyframe.

◆ update()

void kemena::kBone::update ( float animationTime)

Interpolates all channels and updates the local transform.

Parameters
animationTimeCurrent playback position in animation ticks.

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