Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Engine::Skeleton Class Reference

#include <Skeleton.hpp>

Classes

struct  Animation
 
struct  AnimationNode
 
struct  AnimationPositionKey_t
 
struct  AnimationRotationKey_t
 
struct  AnimationScalingKey_t
 
struct  Bone
 A structure containing information a bone. More...
 
struct  BoneData_t
 

Public Types

typedef struct Engine::Skeleton::Bone Bone_t
 A structure containing information a bone. More...
 

Public Member Functions

 Skeleton (const aiScene *scene)
 Creates a new animation data object, loading in the animation data from the provided scene. More...
 
void LoadAnimationSet (const aiScene *scene, eastl::vector< eastl::string > names={})
 Loads in animation data form the provided scene. If the animation data does not match the skeleton of the model (using bone names that are not in the skeleton) a error gets reported but the data will be loaded. The skeleton data used will be the data from the scene used to first initialize the object. More...
 
virtual ~Skeleton ()
 Destroys the Data, cleaning up the bone tree. More...
 
eastl::vector< eastl::string > GetAnimations ()
 Returns a list of the loaded animations as a vector of names. Use these names to load a specific animation. More...
 
void SetAnimation (eastl::string animation, bool resetTime)
 Sets the current animation of the mesh. More...
 
float GetAnimationDuration (size_t animation)
 Returns the duration of a single loop of the animation. More...
 
bool HasAnimations ()
 Whether or not any animations have been loaded. More...
 
TextureGetAnimationData (size_t animation)
 Returns a texture containing the animation snapshots for the current animation. More...
 
size_t GetAnimationIndex (eastl::string animation)
 Returns a texture containing the animation snapshots for the current animation. More...
 
float GetAnimationTicksPerSecond (size_t animation)
 Returns the number of animation ticks per second. This is equal to the number of animation snapshots per second. More...
 
eastl::map< eastl::string, Bone_t * > GetBoneMap ()
 Returns a map that uses the name of a bone as key to return the corresponding bone. More...
 
Bone_tGetRootBone ()
 Returns the root bone of the skeleton. More...
 
void SetName (eastl::string name)
 Sets the name of the skeleton. More...
 
eastl::string GetName ()
 Returns the name of the skeleton (normally the path). More...
 

Protected Types

typedef struct Engine::Skeleton::Animation Animation_t
 
typedef struct Engine::Skeleton::AnimationNode AnimationNode_t
 

Protected Member Functions

void ReadBones (Bone_t *bone, aiNode *node)
 
void DestroyBone (Bone_t *bone)
 
void SetBoneTransform (eastl::string bone, glm::mat4 transform)
 
void SetBoneTransform (Bone_t *bone, glm::mat4 transform)
 
void UpdateBoneTransformData (Bone_t *bone)
 
void UpdateBoneTreeTransformData ()
 
void Update (float deltaTime)
 
virtual void UpdateBoneBuffers ()
 
glm::mat4 InterpolateScale (float time, AnimationNode_t node)
 
glm::mat4 InterpolateRotation (float time, AnimationNode_t node)
 
glm::mat4 InterpolatePosition (float time, AnimationNode_t node)
 
glm::mat4 TransformToMat4 (aiMatrix4x4 transform)
 

Protected Attributes

bool animated
 
Bone_trootBone
 
eastl::vector< BoneData_tboneData
 
eastl::map< eastl::string, size_t > animationMap
 
eastl::vector< Animation_t * > animations
 
const aiScene * scene
 
Animation_tcurrentAnimation
 
size_t currentAnimationIndex
 
float time
 
float speed
 
bool paused
 
bool looping
 
eastl::map< eastl::string, Bone_t * > boneMap
 
eastl::string name
 

Detailed Description

Definition at line 17 of file Skeleton.hpp.

Member Typedef Documentation

A structure containing information a bone.

Constructor & Destructor Documentation

Engine::Skeleton::Skeleton ( const aiScene *  scene)

Creates a new animation data object, loading in the animation data from the provided scene.

Parameters
scenescene containing the model skeleton and animation data.

Definition at line 17 of file Skeleton.cpp.

Engine::Skeleton::~Skeleton ( )
virtual

Destroys the Data, cleaning up the bone tree.

Definition at line 369 of file Skeleton.cpp.

Member Function Documentation

void Engine::Skeleton::DestroyBone ( Bone_t bone)
protected

Definition at line 650 of file Skeleton.cpp.

Texture * Engine::Skeleton::GetAnimationData ( size_t  animation)

Returns a texture containing the animation snapshots for the current animation.

Parameters
animationThe animation to get the data for.
Returns
A shared pointer to a texture containing the data.

Definition at line 573 of file Skeleton.cpp.

float Engine::Skeleton::GetAnimationDuration ( size_t  animation)

Returns the duration of a single loop of the animation.

Parameters
animationThe index of the animation to return the duration of.
Returns
Duration of the animation in seconds.

Definition at line 526 of file Skeleton.cpp.

size_t Engine::Skeleton::GetAnimationIndex ( eastl::string  animation)

Returns a texture containing the animation snapshots for the current animation.

Parameters
animationThe name of the animation to get the data for.
Returns
A shared pointer to a texture containing the data.

Definition at line 583 of file Skeleton.cpp.

eastl::vector< eastl::string > Engine::Skeleton::GetAnimations ( )

Returns a list of the loaded animations as a vector of names. Use these names to load a specific animation.

Returns
A vector containing animation names

Definition at line 381 of file Skeleton.cpp.

float Engine::Skeleton::GetAnimationTicksPerSecond ( size_t  animation)

Returns the number of animation ticks per second. This is equal to the number of animation snapshots per second.

Parameters
animationThe animation to get the data from.
Returns
The number of ticks per second as a float.

Definition at line 595 of file Skeleton.cpp.

eastl::map< eastl::string, Skeleton::Bone_t * > Engine::Skeleton::GetBoneMap ( )

Returns a map that uses the name of a bone as key to return the corresponding bone.

Returns
A map containing pointers to bones using the name as key.

Definition at line 605 of file Skeleton.cpp.

eastl::string Engine::Skeleton::GetName ( )

Returns the name of the skeleton (normally the path).

Returns
The name of the skeleton.

Definition at line 620 of file Skeleton.cpp.

Skeleton::Bone_t * Engine::Skeleton::GetRootBone ( )

Returns the root bone of the skeleton.

Returns
A pointer to the root bone of the skeleton.

Definition at line 610 of file Skeleton.cpp.

bool Engine::Skeleton::HasAnimations ( )

Whether or not any animations have been loaded.

Returns
Boolean indicating if animations have been loaded or not.

Definition at line 568 of file Skeleton.cpp.

glm::mat4 Engine::Skeleton::InterpolatePosition ( float  time,
AnimationNode_t  node 
)
protected

Definition at line 490 of file Skeleton.cpp.

glm::mat4 Engine::Skeleton::InterpolateRotation ( float  time,
AnimationNode_t  node 
)
protected

Definition at line 452 of file Skeleton.cpp.

glm::mat4 Engine::Skeleton::InterpolateScale ( float  time,
AnimationNode_t  node 
)
protected

Definition at line 416 of file Skeleton.cpp.

void Engine::Skeleton::LoadAnimationSet ( const aiScene *  scene,
eastl::vector< eastl::string >  names = {} 
)

Loads in animation data form the provided scene. If the animation data does not match the skeleton of the model (using bone names that are not in the skeleton) a error gets reported but the data will be loaded. The skeleton data used will be the data from the scene used to first initialize the object.

Parameters
sceneScene to load additional animations from.
namesThe optional names of the animation sets to load.

Definition at line 196 of file Skeleton.cpp.

void Engine::Skeleton::ReadBones ( Bone_t bone,
aiNode *  node 
)
protected

Definition at line 625 of file Skeleton.cpp.

void Engine::Skeleton::SetAnimation ( eastl::string  animation,
bool  resetTime 
)

Sets the current animation of the mesh.

Parameters
animationThe name of the animation to use.
resetTimeIf the animation should be reset to the starting point.

Definition at line 391 of file Skeleton.cpp.

void Engine::Skeleton::SetBoneTransform ( eastl::string  bone,
glm::mat4  transform 
)
protected

Definition at line 658 of file Skeleton.cpp.

void Engine::Skeleton::SetBoneTransform ( Bone_t bone,
glm::mat4  transform 
)
protected

Definition at line 666 of file Skeleton.cpp.

void Engine::Skeleton::SetName ( eastl::string  name)

Sets the name of the skeleton.

Parameters
nameThe new name.

Definition at line 615 of file Skeleton.cpp.

glm::mat4 Engine::Skeleton::TransformToMat4 ( aiMatrix4x4  transform)
protected

Definition at line 685 of file Skeleton.cpp.

void Engine::Skeleton::Update ( float  deltaTime)
protected

Definition at line 537 of file Skeleton.cpp.

void Engine::Skeleton::UpdateBoneBuffers ( )
protectedvirtual

Definition at line 412 of file Skeleton.cpp.

void Engine::Skeleton::UpdateBoneTransformData ( Bone_t bone)
protected

Definition at line 671 of file Skeleton.cpp.

void Engine::Skeleton::UpdateBoneTreeTransformData ( )
protected

Definition at line 406 of file Skeleton.cpp.

Member Data Documentation

bool Engine::Skeleton::animated
protected

Definition at line 133 of file Skeleton.hpp.

eastl::map<eastl::string, size_t> Engine::Skeleton::animationMap
protected

Definition at line 175 of file Skeleton.hpp.

eastl::vector<Animation_t*> Engine::Skeleton::animations
protected

Definition at line 177 of file Skeleton.hpp.

eastl::vector<BoneData_t> Engine::Skeleton::boneData
protected

Definition at line 173 of file Skeleton.hpp.

eastl::map<eastl::string, Bone_t*> Engine::Skeleton::boneMap
protected

Definition at line 193 of file Skeleton.hpp.

Animation_t* Engine::Skeleton::currentAnimation
protected

Definition at line 181 of file Skeleton.hpp.

size_t Engine::Skeleton::currentAnimationIndex
protected

Definition at line 183 of file Skeleton.hpp.

bool Engine::Skeleton::looping
protected

Definition at line 191 of file Skeleton.hpp.

eastl::string Engine::Skeleton::name
protected

Definition at line 195 of file Skeleton.hpp.

bool Engine::Skeleton::paused
protected

Definition at line 189 of file Skeleton.hpp.

Bone_t* Engine::Skeleton::rootBone
protected

Definition at line 171 of file Skeleton.hpp.

const aiScene* Engine::Skeleton::scene
protected

Definition at line 179 of file Skeleton.hpp.

float Engine::Skeleton::speed
protected

Definition at line 187 of file Skeleton.hpp.

float Engine::Skeleton::time
protected

Definition at line 185 of file Skeleton.hpp.


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