![]() |
Kale
|
#include <SkeletalAnimatable.hpp>
Public Member Functions | |
SkeletalAnimatable () | |
SkeletalAnimatable (const Skeleton &base) | |
void | setBase (const Skeleton &skeleton) |
const std::vector< Transform > & | getSkeleton (float deltaTime) |
const std::vector< Transform > & | getSkeletonNoRecalc () const |
Vector2f | transform (Vector2f vert, const std::array< std::pair< int, float >, 4 > &weights, float deltaTime) |
Vector2f | transformNoRecalc (Vector2f vert, const std::array< std::pair< int, float >, 4 > &weights) const |
![]() | |
StateAnimatable () | |
StateAnimatable (JSON json) | |
void | updateState (float deltaTime) |
void | addStructure (T state, const Skeleton &structure) |
void | removeStructure (T state) |
Skeleton | getStructure (T state) const |
void | animateTo (T state, float duration) |
void | animateOnce (std::vector< std::pair< T, float > > stages) |
void | animateLoop (std::vector< std::pair< T, float > > stages) |
void | setState (T state) |
T | getCurrentState () const |
std::vector< std::pair< T, float > > | getStateComposition () const |
bool | isTransitioning () const |
Protected Member Functions | |
void | update (size_t threadNum, const Scene &scene, float deltaTime) override |
void | preUpdate (size_t threadNum, const Scene &scene, float deltaTime) override |
![]() | |
virtual void | begin (const Scene &scene) |
virtual void | render (const Camera &camera, float deltaTime) const |
virtual void | end (const Scene &scene) |
Node () | |
Node (float preUpdateTime, float updateTime) | |
Private Member Functions | |
void | recalculateSkeleton (float deltaTime) |
Private Attributes | |
std::vector< Transform > | skeleton |
Skeleton | base |
bool | skeletonRecalculated |
std::mutex | mutex |
Additional Inherited Members | |
![]() | |
std::string | name |
const float | updateTime = 100.0f |
const float | preUpdateTime = 100.0f |
![]() | |
std::optional< std::mutex > | mutex |
![]() | |
int | state |
int | transitionState |
bool | transitioning |
float | transitionTime |
float | transitionDuration |
std::unordered_map< int, Skeleton > | structures |
std::vector< std::pair< int, float > > | animationInfo |
size_t | animationIndex |
bool | animationLoop |
A system for skeletal animations. Unlike the state animatable system, skeletal animatables are a node and can be directly added to the scene. Nodes which support skeleton animatables can link to the node via a shared ptr.
Definition at line 142 of file SkeletalAnimatable.hpp.
SkeletalAnimatable::SkeletalAnimatable | ( | ) |
Creates an empty skeletal animatable
Definition at line 50 of file SkeletalAnimatable.cpp.
SkeletalAnimatable::SkeletalAnimatable | ( | const Skeleton & | base | ) |
Creates a skeletal animatable with a base skeleton which all given vertices are weighted by
base | The base skeleton all transformed vertices are rigged by |
Definition at line 58 of file SkeletalAnimatable.cpp.
const std::vector< Transform > & SkeletalAnimatable::getSkeleton | ( | float | deltaTime | ) |
Thread-Safe method to get the current skeleton, must be called during a pre-update and cannot be called during the update. If you need access to the skeleton for transformation/skinning during an update, use getSkeletonNoRecalc().
deltaTime | The duration of the last frame in microseconds |
Definition at line 134 of file SkeletalAnimatable.cpp.
const std::vector< Transform > & SkeletalAnimatable::getSkeletonNoRecalc | ( | ) | const |
Thread-Safe method to get the current skeleton, the skeleton will not be recalculated even if it is flagged as out of date. This method should only be called after pre-updates, otherwise it may not be updated, or worse may update on another thread while given.
Definition at line 145 of file SkeletalAnimatable.cpp.
|
overrideprotectedvirtual |
Called prior to update, perfect place to do things such as updating the bounding box, etc
threadNum | the index of the thread this update is called on |
scene | The scene being updated to |
deltaTime | The duration of the last frame in microseconds |
Reimplemented from Kale::Node.
Definition at line 124 of file SkeletalAnimatable.cpp.
|
private |
Recalculates the skeleton based on the current state composition
deltaTime | The duration of the last frame in microseconds |
Definition at line 74 of file SkeletalAnimatable.cpp.
void SkeletalAnimatable::setBase | ( | const Skeleton & | skeleton | ) |
Sets the base skeleton transformed vertices are rigged by
skeleton | The base skeleton transformed vertices are rigged by |
Definition at line 66 of file SkeletalAnimatable.cpp.
Vector2f SkeletalAnimatable::transform | ( | Vector2f | vert, |
const std::array< std::pair< int, float >, 4 > & | weights, | ||
float | deltaTime ) |
Transforms a single vertex given its weights, cannot be called during the update.
vert | The vertex to transform |
weights | The weights of the vertex, 4 pairs of the index of the bone along with the significance. Must add up to 1, set the index of the bone to -1 if it is unassigned. |
deltaTime | The duration of the last frame in microseconds |
Transforms a single vertex given its weights
vert | The vertex to transform |
weights | The weights of the vertex, 4 pairs of the index of the bone along with the significance. Must add up to 1, set the index of the bone to -1 if it is unassigned. |
Definition at line 156 of file SkeletalAnimatable.cpp.
Vector2f SkeletalAnimatable::transformNoRecalc | ( | Vector2f | vert, |
const std::array< std::pair< int, float >, 4 > & | weights ) const |
Transforms a single vertex given its weights. This method should only be called after pre-updates, otherwise it may not be updated, or worse may update on another thread while given.
vert | The vertex to transform |
weights | The weights of the vertex, 4 pairs of the index of the bone along with the significance. Must add up to 1, set the index of the bone to -1 if it is unassigned. |
Transforms a single vertex given its weights
vert | The vertex to transform |
weights | The weights of the vertex, 4 pairs of the index of the bone along with the significance. Must add up to 1, set the index of the bone to -1 if it is unassigned. |
Definition at line 168 of file SkeletalAnimatable.cpp.
|
overrideprotectedvirtual |
Called on update, perfect place to do any physics updating, game logic, etc
threadNum | the index of the thread this update is called on |
scene | The scene being updated to |
deltaTime | The duration of the last frame in microseconds |
Reimplemented from Kale::Node.
Definition at line 114 of file SkeletalAnimatable.cpp.
|
private |
The base state of the skeleton, vertices are rigged to this skeleton
Definition at line 153 of file SkeletalAnimatable.hpp.
|
private |
Mutex used for ensuring safe access to skeleton updates
Definition at line 164 of file SkeletalAnimatable.hpp.
|
private |
The currently held skeleton offsets
Definition at line 148 of file SkeletalAnimatable.hpp.
|
private |
Whether or not the skeleton has been recalculated for this frame. This is set to true whenever the skeleton is recalculated and set to false again every update.
Definition at line 159 of file SkeletalAnimatable.hpp.