Bones

namespace tnt
namespace doo

Variables

struct tnt::doo::bones_sys bones
struct bone_comp
#include <Bones.hpp>

A basic struct representing a bone used for skeletal animation.

Public Members

Vector joint
float length

< One end of the bone.

struct bones_sys
#include <Bones.hpp>

A system that handles bones animations.

Public Functions

void add_object(object const &id, bone_comp const &data_)

Add a new object to the bones system.

Parameters
  • id: The id of the object that will have a bone component.

  • data_: The data that the object will contain.

void from_json(object const &id, nlohmann::json const &j)

Add new objects to the bones system by using data from a json chunk.

Parameters
  • id: The id of the object to add to the bones system.

  • j: The json chunk containing the objects data.

void to_json(object const &id, nlohmann::json &j)

Store bones data of a specific object to a json chunk.

Parameters
  • id: The id of the object to serialize to json.

  • j: The json chunk where the data will be saved.

void remove(object const &id) noexcept

Remove an object from the bones system.

Parameters
  • id: The id of the object to remove.

void clear() noexcept

Remove all the objects from the bones system.

Vector bottom(object const &id) const noexcept

Get the other end of the bone of the given object.

Return

tnt::Vector

Parameters
  • id: The id of the object that has the desired bone.

void follow(object const &id, Vector const &target) noexcept

Move the desired joint towards target.

Parameters
  • id: The id of the joint you want to reach the target.

  • target: The destination you want the joint to reach.

Public Members

std::vector<float> length
std::vector<Vector> joint

< The length of each bone.

sparse_set<object> active

< The datas of the bone trees.