Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Scene::SkeletonComponent Class Reference

#include <Engine/Scene/SkeletonComponent.hpp>

+ Inheritance diagram for Ra::Engine::Scene::SkeletonComponent:
+ Collaboration diagram for Ra::Engine::Scene::SkeletonComponent:

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
 
SkeletonComponentoperator= (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::stringgetSkelName () const
 Returns the name of the skeleton.
 
void setSkeleton (const Core::Animation::Skeleton &skel)
 Set the animation skeleton.
 
const Core::Animation::SkeletongetSkeleton ()
 Returns the animation skeleton.
 
size_t getAnimationCount () const
 Return the number of animations.
 
const AnimationgetAnimation (const size_t i) const
 Return the i -th animation.
 
AnimationgetAnimation (const size_t i)
 Return the i -th animation.
 
AnimationaddNewAnimation ()
 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 EntitygetEntity () const
 Return the entity the component belongs to.
 
virtual const std::stringgetName () const
 Return the component's name.
 
virtual void setSystem (System *system)
 Set the system to which the component belongs.
 
virtual SystemgetSystem () 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 {}
 
Entitym_entity { nullptr }
 
Systemm_system { nullptr }
 

Detailed Description

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:

  • the Skeleton;
  • the mapping from the bones RenderObject's index to the bones indices within the Skeleton;
  • the reference Pose;
  • the current Animation;
  • the current animation time;
  • whether the animation time has been reset.

Definition at line 41 of file SkeletonComponent.hpp.

Member Typedef Documentation

◆ Animation

Animations are lists of keyframed transforms (one per bone).

Definition at line 47 of file SkeletonComponent.hpp.

Constructor & Destructor Documentation

◆ SkeletonComponent()

Ra::Engine::Scene::SkeletonComponent::SkeletonComponent ( const std::string & name,
Entity * entity )

Definition at line 41 of file SkeletonComponent.cpp.

◆ ~SkeletonComponent()

Ra::Engine::Scene::SkeletonComponent::~SkeletonComponent ( )
override

Definition at line 44 of file SkeletonComponent.cpp.

Member Function Documentation

◆ addNewAnimation()

SkeletonComponent::Animation & Ra::Engine::Scene::SkeletonComponent::addNewAnimation ( )

Creates a new empty animation from the current pose.

Definition at line 132 of file SkeletonComponent.cpp.

+ Here is the call graph for this function:

◆ autoRepeat()

void Ra::Engine::Scene::SkeletonComponent::autoRepeat ( const bool status)

Toggle animation auto repeat.

Definition at line 225 of file SkeletonComponent.cpp.

◆ canEdit()

bool Ra::Engine::Scene::SkeletonComponent::canEdit ( const Core::Utils::Index & ) const
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.

◆ getAnimation() [1/2]

Animation & Ra::Engine::Scene::SkeletonComponent::getAnimation ( const size_t i)
inline

Return the i -th animation.

Definition at line 100 of file SkeletonComponent.hpp.

◆ getAnimation() [2/2]

const Animation & Ra::Engine::Scene::SkeletonComponent::getAnimation ( const size_t i) const
inline

Return the i -th animation.

Definition at line 97 of file SkeletonComponent.hpp.

◆ getAnimationCount()

size_t Ra::Engine::Scene::SkeletonComponent::getAnimationCount ( ) const
inline

Return the number of animations.

Definition at line 94 of file SkeletonComponent.hpp.

◆ getAnimationId()

size_t Ra::Engine::Scene::SkeletonComponent::getAnimationId ( ) const

Return the index of the animation to play.

Definition at line 150 of file SkeletonComponent.cpp.

◆ getAnimationTime()

Scalar Ra::Engine::Scene::SkeletonComponent::getAnimationTime ( ) const

Returns the current time of animation.

Definition at line 201 of file SkeletonComponent.cpp.

◆ getAnimationTimeInterval()

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.

+ Here is the call graph for this function:

◆ getBoneRO2idx()

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.

◆ getBoneTransform()

Core::Transform Ra::Engine::Scene::SkeletonComponent::getBoneTransform ( uint boneIdx,
const Ra::Core::Animation::HandleArray::SpaceType MODE )

Definition at line 68 of file SkeletonComponent.cpp.

◆ getManipulationScheme()

Core::Animation::Skeleton::Manipulation Ra::Engine::Scene::SkeletonComponent::getManipulationScheme ( )

Returns the manipulation scheme for the Skeleton.

Definition at line 377 of file SkeletonComponent.cpp.

◆ getSkeleton()

const Core::Animation::Skeleton * Ra::Engine::Scene::SkeletonComponent::getSkeleton ( )
inline

Returns the animation skeleton.

Definition at line 91 of file SkeletonComponent.hpp.

◆ getSkelName()

const std::string & Ra::Engine::Scene::SkeletonComponent::getSkelName ( ) const
inline

Returns the name of the skeleton.

Definition at line 85 of file SkeletonComponent.hpp.

◆ getSpeed()

Scalar Ra::Engine::Scene::SkeletonComponent::getSpeed ( ) const

Return animation speed factor.

Definition at line 221 of file SkeletonComponent.cpp.

◆ getTransform()

Core::Transform Ra::Engine::Scene::SkeletonComponent::getTransform ( const Core::Utils::Index & ) const
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.

◆ handleAnimationLoading()

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.

+ Here is the call graph for this function:

◆ handleSkeletonLoading()

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.

+ Here is the call graph for this function:

◆ initialize()

void Ra::Engine::Scene::SkeletonComponent::initialize ( )
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.

◆ isAutoRepeat()

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.

◆ isPingPong()

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.

◆ isShowingSkeleton()

bool Ra::Engine::Scene::SkeletonComponent::isShowingSkeleton ( ) const

Return true if the skeleton is displayed.

Definition at line 260 of file SkeletonComponent.cpp.

◆ isXray()

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.

◆ pingPong()

void Ra::Engine::Scene::SkeletonComponent::pingPong ( const bool status)

Toggle animation ping-pong.

Definition at line 233 of file SkeletonComponent.cpp.

◆ removeAnimation()

void Ra::Engine::Scene::SkeletonComponent::removeAnimation ( const size_t i)

Deletes the i-th animation.

Definition at line 140 of file SkeletonComponent.cpp.

◆ setBoneTransform()

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.

◆ setManipulationScheme()

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.

◆ setSkeleton()

void Ra::Engine::Scene::SkeletonComponent::setSkeleton ( const Core::Animation::Skeleton & skel)

Set the animation skeleton.

Definition at line 126 of file SkeletonComponent.cpp.

+ Here is the call graph for this function:

◆ setSpeed()

void Ra::Engine::Scene::SkeletonComponent::setSpeed ( const Scalar value)

Set animation speed factor.

Definition at line 217 of file SkeletonComponent.cpp.

◆ setTransform()

void Ra::Engine::Scene::SkeletonComponent::setTransform ( const Core::Utils::Index & ,
const Core::Transform &  )
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.

◆ setXray()

void Ra::Engine::Scene::SkeletonComponent::setXray ( bool on) const

Turns xray display on/off for the skeleton bones.

Todo
the way skeletons will be displayed will be changed.

Definition at line 243 of file SkeletonComponent.cpp.

◆ toggleSkeleton()

void Ra::Engine::Scene::SkeletonComponent::toggleSkeleton ( const bool status)

Toggle skeleton bones display.

Definition at line 254 of file SkeletonComponent.cpp.

◆ update()

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.

+ Here is the call graph for this function:

◆ updateDisplay()

void Ra::Engine::Scene::SkeletonComponent::updateDisplay ( )

Updates the skeleton display.

Definition at line 349 of file SkeletonComponent.cpp.

◆ useAnimation()

void Ra::Engine::Scene::SkeletonComponent::useAnimation ( const size_t i)

Set the animation to play.

Definition at line 146 of file SkeletonComponent.cpp.

Friends And Related Symbol Documentation

◆ SkeletonBasedAnimationSystem

friend class SkeletonBasedAnimationSystem
friend

Definition at line 44 of file SkeletonComponent.hpp.


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