Objects

namespace tnt
namespace doo

Variables

struct tnt::doo::objects_sys objects
struct object_data
#include <Objects.hpp>

A struct that holds the basic data of an object.

Public Functions

constexpr object_data(float angle_, Vector const &pos_, Vector const &scale_, object const &parent_ = null) noexcept

Create a new object data handle from the given params.

Parameters
  • angle_: The initial angle of the object.

  • scale_: The initial scale of the object.

  • pos_: The initial position of the object.

  • parent_: The parent of the new object. Leave it as is if you don’t want the object to have a parent.

Public Members

float angle
Vector scale

< The angle of the object.

Vector pos

< The scale of the object.

object parent

< The position of the object.

struct objects_sys
#include <Objects.hpp>

A struct that handles objects data.

Public Functions

object add_object(object_data const &data_) noexcept

Create a new object in place and add it to the system. Return the id of the newly created object.

Return

tnt::doo::object

object_data get_data(object const &id) const noexcept

Get the data of the object with the given id.

Return

object_data

Parameters
  • id: The id of the object.

object from_json(nlohmann::json const &j)

Load objects data from a json chunk.

Return

The id of the created object.

Parameters
  • j: The json chunk that contains the objects data.

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

Store general 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 draw_imgui(object const &id, Window const &win) noexcept

Draw widgets on the given window to modify the datas of the system.

Parameters
  • id: The id of the active object.

  • win: The window where to draw the widgets.

float gAngle(object const &id) const noexcept

Get the angle of the object in global context.

Return

float

Note

The function returns angle[id] if the object has no parent (aka. parent[id] == -1).

Parameters
  • id: The id of the object.

Vector gScale(object const &id) const noexcept

Get the scale of the object in global context.

Return

Vector

Note

The function returns scale[id] if the object has no parent (aka. parent[id] == -1).

Parameters
  • id: The id of the object.

Vector gPos(object const &id) const noexcept

Get the position of the object in global context.

Return

Vector

Note

The function returns pos[id] if the object has no parent (aka. parent[id] == -1).

Parameters
  • id: The id of the object.

void set_parent(object const &id, object const &parent_) noexcept

Change the parent of the given object and apply all the necessary changes.

Parameters
  • id: The id of the child object.

  • parent_: The id of the new parent.

void remove(object const &id) noexcept

Remove the desired object from the objects system.

Note

Please call remove() from the other systems first.

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

void clear() noexcept

Remove all the objects from the objects system.

Note

Please call clear() from the other systems first.

Public Members

std::vector<float> angle
tnt::sparse_set<object> active

< The angles of the objects.

std::vector<object> parent

< The id-s of all the active objects.

std::vector<Vector> scale

< The id-s of the parents of the objects.

std::vector<Vector> pos

< The scales of the objects.