Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CGradientBandInterpolation Class Reference

Helper class for blending multiple animations based on a parameter vector. More...

#include <Animation/CGradientBandInterpolation.h>

Classes

struct  SSample
 Represents an animation sample point with its associated weight. More...

Public Member Functions

core::array< SSample * > & getSamples ()
 Gets the list of animation samples.
SSampleaddSample (int id, const core::vector3df &vector)
 Adds a new animation sample point.
void removeSample (SSample *sample)
 Removes a specific animation sample.
void clear ()
 Removes all animation samples.
void sampleWeightsPolar (const core::vector3df &vector)
 Calculates blending weights using polar gradient band interpolation.
void sampleWeightsCartesian (const core::vector3df &vector)
 Calculates blending weights using Cartesian gradient band interpolation.

Protected Attributes

core::array< SSample * > m_samples
 List of all animation samples.

Detailed Description

Helper class for blending multiple animations based on a parameter vector.

This is typically used for locomotion systems (e.g., blending Idle, Walk, Run based on velocity). Reference: https://github.com/runevision/LocomotionSystem

Example: Locomotion blending

CGradientBandInterpolation blending;
blending.addSample(ID_IDLE, core::vector3df(0, 0, 0));
blending.addSample(ID_WALK, core::vector3df(0, 0, 1.5f));
blending.addSample(ID_RUN, core::vector3df(0, 0, 5.0f));
// Target velocity
core::vector3df velocity(0, 0, 3.0f);
blending.sampleWeightsPolar(velocity);
// Apply weights to skeletons
for (auto* sample : blending.getSamples()) {
animController->getSkeleton(sample->Id)->getTimeline().Weight = sample->Weight;
}
void sampleWeightsPolar(const core::vector3df &vector)
Calculates blending weights using polar gradient band interpolation.
core::array< SSample * > & getSamples()
Gets the list of animation samples.
Definition CGradientBandInterpolation.h:95
SSample * addSample(int id, const core::vector3df &vector)
Adds a new animation sample point.

Member Function Documentation

◆ addSample()

SSample * Skylicht::CGradientBandInterpolation::addSample ( int id,
const core::vector3df & vector )

Adds a new animation sample point.

Parameters
idThe sample ID.
vectorThe position in parameter space.
Returns
Pointer to the newly created sample.

◆ getSamples()

core::array< SSample * > & Skylicht::CGradientBandInterpolation::getSamples ( )
inline

Gets the list of animation samples.

Returns
Reference to the samples array.

◆ removeSample()

void Skylicht::CGradientBandInterpolation::removeSample ( SSample * sample)

Removes a specific animation sample.

Parameters
samplePointer to the sample to remove.

◆ sampleWeightsCartesian()

void Skylicht::CGradientBandInterpolation::sampleWeightsCartesian ( const core::vector3df & vector)

Calculates blending weights using Cartesian gradient band interpolation.

Best suited for 2D/3D parameter spaces without directional wrapping.

Parameters
vectorThe input parameter vector.

◆ sampleWeightsPolar()

void Skylicht::CGradientBandInterpolation::sampleWeightsPolar ( const core::vector3df & vector)

Calculates blending weights using polar gradient band interpolation.

Best suited for parameters like direction and speed.

Parameters
vectorThe input parameter vector (e.g., target velocity).

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