Antkeeper  0.0.1
Public Member Functions | List of all members
skeleton Class Reference

Skeletal animation skeleton. More...

#include <skeleton.hpp>

Public Member Functions

 skeleton (std::size_t bone_count)
 Constructs a skeleton. More...
 
 skeleton ()
 Constructs an empty skeleton. More...
 
void update_rest_pose ()
 Updates the rest pose of the skeleton. More...
 
bone_index_type add_bones (std::size_t bone_count)
 Add one or more bones to the skeleton. More...
 
bone_index_type add_bone ()
 Adds a single bone to the skeleton. More...
 
bone_index_type add_bone (hash::fnv1a32_t name)
 Adds a single named bone to the skeleton. More...
 
void remove_bones ()
 Removes all bones from the skeleton. More...
 
animation_poseadd_pose (hash::fnv1a32_t name)
 Adds a pose to the skeleton. More...
 
void remove_pose (hash::fnv1a32_t name)
 Removes a pose from the skeleton. More...
 
void remove_poses ()
 Removes all poses from the skeleton, excluding the rest pose. More...
 
void set_bone_parent (bone_index_type child_index, bone_index_type parent_index)
 Sets the parent of a bone. More...
 
void set_bone_transform (bone_index_type index, const bone_transform_type &transform)
 Sets the transform of a bone, relative to its parent bone. More...
 
void set_bone_name (bone_index_type index, hash::fnv1a32_t name)
 Sets the name of a bone. More...
 
std::size_t get_bone_count () const noexcept
 Returns the number of bones in the skeleton. More...
 
bone_index_type get_bone_parent (bone_index_type child_index) const
 Returns the index of the parent of a bone. More...
 
std::optional< bone_index_typeget_bone_index (hash::fnv1a32_t name) const
 Finds the index of a bone from the bone's name. More...
 
const rest_poseget_rest_pose () const noexcept
 Returns the skeleton's rest pose. More...
 
const animation_poseget_pose (hash::fnv1a32_t name) const
 Finds a pose from the poses's name. More...
 
animation_poseget_pose (hash::fnv1a32_t name)
 Finds a pose from the poses's name. More...
 

Detailed Description

Skeletal animation skeleton.

Definition at line 34 of file skeleton.hpp.

Constructor & Destructor Documentation

◆ skeleton() [1/2]

skeleton::skeleton ( std::size_t  bone_count)
explicit

Constructs a skeleton.

Parameters
bone_countNumber of bones in the skeleton.

Definition at line 23 of file skeleton.cpp.

◆ skeleton() [2/2]

skeleton::skeleton ( )

Constructs an empty skeleton.

Definition at line 28 of file skeleton.cpp.

Member Function Documentation

◆ add_bone() [1/2]

bone_index_type skeleton::add_bone ( )
inline

Adds a single bone to the skeleton.

Returns
Index of the added bone.

Definition at line 66 of file skeleton.hpp.

◆ add_bone() [2/2]

bone_index_type skeleton::add_bone ( hash::fnv1a32_t  name)

Adds a single named bone to the skeleton.

Parameters
nameName of the bone.
Returns
Index of the added bone.
Exceptions
std::invalid_argumentDuplicate bone name.

Definition at line 47 of file skeleton.cpp.

◆ add_bones()

bone_index_type skeleton::add_bones ( std::size_t  bone_count)

Add one or more bones to the skeleton.

Parameters
bone_countNumber of bones to add.
Returns
Index of the first added bone.

Definition at line 37 of file skeleton.cpp.

◆ add_pose()

animation_pose & skeleton::add_pose ( hash::fnv1a32_t  name)

Adds a pose to the skeleton.

Parameters
nameName of the pose.
Returns
Reference to the added pose.
Exceptions
std::invalid_argumentDuplicate pose name.

Definition at line 63 of file skeleton.cpp.

◆ get_bone_count()

std::size_t skeleton::get_bone_count ( ) const
inlinenoexcept

Returns the number of bones in the skeleton.

Definition at line 148 of file skeleton.hpp.

◆ get_bone_index()

std::optional< bone_index_type > skeleton::get_bone_index ( hash::fnv1a32_t  name) const

Finds the index of a bone from the bone's name.

Parameters
nameName of a bone.
Returns
Index of the bone, or std::nullopt if no bone with the given name was found.

Definition at line 113 of file skeleton.cpp.

◆ get_bone_parent()

bone_index_type skeleton::get_bone_parent ( bone_index_type  child_index) const
inline

Returns the index of the parent of a bone.

Parameters
child_indexIndex of the child bone.
Returns
Index of the child bone's parent, or index if the child bone has no parent.

Definition at line 160 of file skeleton.hpp.

◆ get_pose() [1/2]

animation_pose * skeleton::get_pose ( hash::fnv1a32_t  name)

Finds a pose from the poses's name.

Parameters
nameName of a pose.
Returns
Non-owning pointer to the pose, or nullptr if no pose with the given name was found.

Definition at line 133 of file skeleton.cpp.

◆ get_pose() [2/2]

const animation_pose * skeleton::get_pose ( hash::fnv1a32_t  name) const

Finds a pose from the poses's name.

Parameters
nameName of a pose.
Returns
Non-owning pointer to the pose, or nullptr if no pose with the given name was found.

Definition at line 123 of file skeleton.cpp.

◆ get_rest_pose()

const rest_pose& skeleton::get_rest_pose ( ) const
inlinenoexcept

Returns the skeleton's rest pose.

Definition at line 187 of file skeleton.hpp.

◆ remove_bones()

void skeleton::remove_bones ( )

Removes all bones from the skeleton.

Definition at line 56 of file skeleton.cpp.

◆ remove_pose()

void skeleton::remove_pose ( hash::fnv1a32_t  name)

Removes a pose from the skeleton.

Parameters
nameName of the pose to remove.
Exceptions
std::invalid_argumentPose not found.

Definition at line 75 of file skeleton.cpp.

◆ remove_poses()

void skeleton::remove_poses ( )

Removes all poses from the skeleton, excluding the rest pose.

Definition at line 83 of file skeleton.cpp.

◆ set_bone_name()

void skeleton::set_bone_name ( bone_index_type  index,
hash::fnv1a32_t  name 
)

Sets the name of a bone.

Parameters
indexIndex of a bone.
nameName of the bone.
Exceptions
std::invalid_argumentDuplicate bone name.

Definition at line 98 of file skeleton.cpp.

◆ set_bone_parent()

void skeleton::set_bone_parent ( bone_index_type  child_index,
bone_index_type  parent_index 
)

Sets the parent of a bone.

Parameters
child_indexIndex of the child bone.
parent_indexIndex of the parent bone.
Warning
The index of a child bone must be greater than the index of its parent.
Exceptions
std::invalid_argumentChild bone index precedes parent bone index.

Definition at line 88 of file skeleton.cpp.

◆ set_bone_transform()

void skeleton::set_bone_transform ( bone_index_type  index,
const bone_transform_type transform 
)
inline

Sets the transform of a bone, relative to its parent bone.

Parameters
indexIndex of a bone.
transformBone transform, relative to the parent bone.

Definition at line 130 of file skeleton.hpp.

◆ update_rest_pose()

void skeleton::update_rest_pose ( )

Updates the rest pose of the skeleton.

Definition at line 32 of file skeleton.cpp.


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