Radium Engine
1.5.20
|
#include <Engine/Scene/SkeletonComponent.hpp>
Public Types | |
using | Animation = std::vector<Core::Animation::KeyFramedValue<Core::Transform>> |
Animations are lists of keyframed transforms (one per bone). | |
Public Member Functions | |
SkeletonComponent (const std::string &name, Entity *entity) | |
SkeletonComponent (const SkeletonComponent &)=delete | |
SkeletonComponent & | operator= (const SkeletonComponent &)=delete |
Component interface | |
void | initialize () override |
Pure virtual method to be overridden by any component. When this method is called you are guaranteed that all other startup systems have been loaded. | |
bool | canEdit (const Core::Utils::Index &roIdx) const override |
Returns true if a transform can be edited with the render object index given as a key. | |
Core::Transform | getTransform (const Core::Utils::Index &roIdx) const override |
Get the transform associated with the given RO index key. | |
Core::Transform | getBoneTransform (uint boneIdx, const Ra::Core::Animation::HandleArray::SpaceType MODE) |
void | setTransform (const Core::Utils::Index &roIdx, const Core::Transform &transform) override |
Set the new transform associated with the RO index key. | |
void | setBoneTransform (uint boneIdx, const Core::Transform &transform, const Ra::Core::Animation::HandleArray::SpaceType MODE) |
Build from fileData | |
void | handleSkeletonLoading (const Core::Asset::HandleData *data) |
Create the skeleton from the given data. | |
void | handleAnimationLoading (const std::vector< Core::Asset::AnimationData * > &data) |
Create the animations from the given data. | |
Skeleton-based animation data | |
const std::string & | getSkelName () const |
Returns the name of the skeleton. | |
void | setSkeleton (const Core::Animation::Skeleton &skel) |
Set the animation skeleton. | |
const Core::Animation::Skeleton * | getSkeleton () |
Returns the animation skeleton. | |
size_t | getAnimationCount () const |
Return the number of animations. | |
const Animation & | getAnimation (const size_t i) const |
Return the i -th animation. | |
Animation & | getAnimation (const size_t i) |
Return the i -th animation. | |
Animation & | addNewAnimation () |
Creates a new empty animation from the current pose. | |
void | removeAnimation (const size_t i) |
Deletes the i-th animation. | |
void | useAnimation (const size_t i) |
Set the animation to play. | |
size_t | getAnimationId () const |
Return the index of the animation to play. | |
Animation Process | |
void | update (Scalar time) |
Updates the skeleton pose as the pose corresponding to time time . | |
Scalar | getAnimationTime () const |
Returns the current time of animation. | |
std::pair< Scalar, Scalar > | getAnimationTimeInterval () const |
Returns the start and end time of the current animation. | |
void | setSpeed (const Scalar value) |
Set animation speed factor. | |
Scalar | getSpeed () const |
Return animation speed factor. | |
void | autoRepeat (const bool status) |
Toggle animation auto repeat. | |
bool | isAutoRepeat () const |
Return true is animation auto repeat is on, false otherwise. | |
void | pingPong (const bool status) |
Toggle animation ping-pong. | |
bool | isPingPong () const |
Return true is animation ping-pong is on, false otherwise. | |
Skeleton display and manipulation | |
void | setXray (bool on) const |
bool | isXray () const |
Return true if bones are displayed in xray mode, false otherwise. | |
void | toggleSkeleton (const bool status) |
Toggle skeleton bones display. | |
bool | isShowingSkeleton () const |
Return true if the skeleton is displayed. | |
const std::map< Core::Utils::Index, uint > * | getBoneRO2idx () const |
Returns the map from RO index to bone index. | |
void | updateDisplay () |
Updates the skeleton display. | |
void | setManipulationScheme (const Core::Animation::Skeleton::Manipulation &scheme) |
Sets the given manipulation scheme for the Skeleton. | |
Core::Animation::Skeleton::Manipulation | getManipulationScheme () |
Returns the manipulation scheme for the Skeleton. | |
Public Member Functions inherited from Ra::Engine::Scene::Component | |
Component (const std::string &name, Entity *entity) | |
CONSTRUCTOR. | |
virtual | ~Component () |
DESTRUCTOR. | |
virtual void | setEntity (Entity *entity) |
Set entity the component is part of. This method is called by the entity. | |
virtual Entity * | getEntity () const |
Return the entity the component belongs to. | |
virtual const std::string & | getName () const |
Return the component's name. | |
virtual void | setSystem (System *system) |
Set the system to which the component belongs. | |
virtual System * | getSystem () const |
Returns the system to which the component belongs. | |
Core::Utils::Index | addRenderObject (Rendering::RenderObject *renderObject) |
Add a new render object to the component. This adds the RO to the manager for drawing. | |
void | removeRenderObject (const Core::Utils::Index &roIdx) |
Remove the render object from the component. | |
void | notifyRenderObjectExpired (const Core::Utils::Index &idx) |
virtual Core::Aabb | computeAabb () |
void | invalidateAabb () |
const std::vector< Core::Utils::Index > & | getRenderObjects () |
Friends | |
class | SkeletonBasedAnimationSystem |
Additional Inherited Members | |
Public Attributes inherited from Ra::Engine::Scene::Component | |
std::vector< Core::Utils::Index > | m_renderObjects |
Static Protected Member Functions inherited from Ra::Engine::Scene::Component | |
static Rendering::RenderObjectManager * | getRoMgr () |
Shortcut to access the render object manager. | |
Protected Attributes inherited from Ra::Engine::Scene::Component | |
std::string | m_name {} |
Entity * | m_entity { nullptr } |
System * | m_system { nullptr } |
The SkeletonComponent is responsible for the management of skeleton-based character animations. It stores the animation Skeleton and the animation data and is responsible for drawing the skeleton.
Regarding Component Communication, an AnimationComponent gives access to the following data from the skeleton's name:
Definition at line 41 of file SkeletonComponent.hpp.
using Ra::Engine::Scene::SkeletonComponent::Animation = std::vector<Core::Animation::KeyFramedValue<Core::Transform>> |
Animations are lists of keyframed transforms (one per bone).
Definition at line 47 of file SkeletonComponent.hpp.
Ra::Engine::Scene::SkeletonComponent::SkeletonComponent | ( | const std::string & | name, |
Entity * | entity ) |
Definition at line 41 of file SkeletonComponent.cpp.
|
override |
Definition at line 44 of file SkeletonComponent.cpp.
SkeletonComponent::Animation & Ra::Engine::Scene::SkeletonComponent::addNewAnimation | ( | ) |
Creates a new empty animation from the current pose.
Definition at line 132 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::autoRepeat | ( | const bool | status | ) |
Toggle animation auto repeat.
Definition at line 225 of file SkeletonComponent.cpp.
|
overridevirtual |
Returns true if a transform can be edited with the render object index given as a key.
Reimplemented from Ra::Engine::Scene::Component.
Definition at line 48 of file SkeletonComponent.cpp.
|
inline |
Return the i
-th animation.
Definition at line 100 of file SkeletonComponent.hpp.
|
inline |
Return the i
-th animation.
Definition at line 97 of file SkeletonComponent.hpp.
|
inline |
Return the number of animations.
Definition at line 94 of file SkeletonComponent.hpp.
size_t Ra::Engine::Scene::SkeletonComponent::getAnimationId | ( | ) | const |
Return the index of the animation to play.
Definition at line 150 of file SkeletonComponent.cpp.
Scalar Ra::Engine::Scene::SkeletonComponent::getAnimationTime | ( | ) | const |
Returns the current time of animation.
Definition at line 201 of file SkeletonComponent.cpp.
std::pair< Scalar, Scalar > Ra::Engine::Scene::SkeletonComponent::getAnimationTimeInterval | ( | ) | const |
Returns the start and end time of the current animation.
Definition at line 205 of file SkeletonComponent.cpp.
const std::map< Index, uint > * Ra::Engine::Scene::SkeletonComponent::getBoneRO2idx | ( | ) | const |
Returns the map from RO index to bone index.
Definition at line 416 of file SkeletonComponent.cpp.
Core::Transform Ra::Engine::Scene::SkeletonComponent::getBoneTransform | ( | uint | boneIdx, |
const Ra::Core::Animation::HandleArray::SpaceType | MODE ) |
Definition at line 68 of file SkeletonComponent.cpp.
Core::Animation::Skeleton::Manipulation Ra::Engine::Scene::SkeletonComponent::getManipulationScheme | ( | ) |
Returns the manipulation scheme for the Skeleton.
Definition at line 377 of file SkeletonComponent.cpp.
|
inline |
Returns the animation skeleton.
Definition at line 91 of file SkeletonComponent.hpp.
|
inline |
Returns the name of the skeleton.
Definition at line 85 of file SkeletonComponent.hpp.
Scalar Ra::Engine::Scene::SkeletonComponent::getSpeed | ( | ) | const |
Return animation speed factor.
Definition at line 221 of file SkeletonComponent.cpp.
|
overridevirtual |
Get the transform associated with the given RO index key.
Reimplemented from Ra::Engine::Scene::Component.
Definition at line 53 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::handleAnimationLoading | ( | const std::vector< Core::Asset::AnimationData * > & | data | ) |
Create the animations from the given data.
Definition at line 92 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::handleSkeletonLoading | ( | const Core::Asset::HandleData * | data | ) |
Create the skeleton from the given data.
Definition at line 79 of file SkeletonComponent.cpp.
|
inlineoverridevirtual |
Pure virtual method to be overridden by any component. When this method is called you are guaranteed that all other startup systems have been loaded.
Implements Ra::Engine::Scene::Component.
Definition at line 57 of file SkeletonComponent.hpp.
bool Ra::Engine::Scene::SkeletonComponent::isAutoRepeat | ( | ) | const |
Return true is animation auto repeat is on, false otherwise.
Definition at line 229 of file SkeletonComponent.cpp.
bool Ra::Engine::Scene::SkeletonComponent::isPingPong | ( | ) | const |
Return true is animation ping-pong is on, false otherwise.
Definition at line 237 of file SkeletonComponent.cpp.
bool Ra::Engine::Scene::SkeletonComponent::isShowingSkeleton | ( | ) | const |
Return true if the skeleton is displayed.
Definition at line 260 of file SkeletonComponent.cpp.
bool Ra::Engine::Scene::SkeletonComponent::isXray | ( | ) | const |
Return true if bones are displayed in xray mode, false otherwise.
Definition at line 249 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::pingPong | ( | const bool | status | ) |
Toggle animation ping-pong.
Definition at line 233 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::removeAnimation | ( | const size_t | i | ) |
Deletes the i-th
animation.
Definition at line 140 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::setBoneTransform | ( | uint | boneIdx, |
const Core::Transform & | transform, | ||
const Ra::Core::Animation::HandleArray::SpaceType | MODE ) |
Definition at line 71 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::setManipulationScheme | ( | const Core::Animation::Skeleton::Manipulation & | scheme | ) |
Sets the given manipulation scheme for the Skeleton.
Definition at line 372 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::setSkeleton | ( | const Core::Animation::Skeleton & | skel | ) |
Set the animation skeleton.
Definition at line 126 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::setSpeed | ( | const Scalar | value | ) |
Set animation speed factor.
Definition at line 217 of file SkeletonComponent.cpp.
|
overridevirtual |
Set the new transform associated with the RO index key.
Reimplemented from Ra::Engine::Scene::Component.
Definition at line 59 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::setXray | ( | bool | on | ) | const |
Turns xray display on/off for the skeleton bones.
Definition at line 243 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::toggleSkeleton | ( | const bool | status | ) |
Toggle skeleton bones display.
Definition at line 254 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::update | ( | Scalar | time | ) |
Updates the skeleton pose as the pose corresponding to time time
.
Definition at line 156 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::updateDisplay | ( | ) |
Updates the skeleton display.
Definition at line 349 of file SkeletonComponent.cpp.
void Ra::Engine::Scene::SkeletonComponent::useAnimation | ( | const size_t | i | ) |
Set the animation to play.
Definition at line 146 of file SkeletonComponent.cpp.
|
friend |
Definition at line 44 of file SkeletonComponent.hpp.