12#ifndef FOOLSENGINE_SCENECOMPONENTS_H
13#define FOOLSENGINE_SCENECOMPONENTS_H
16#include <glm/gtc/quaternion.hpp>
17#include <nlohmann/json.hpp>
81 return !(*
this == other);
152 inline void from_json(
const nlohmann::json& json, Placement& placement) {
154 json.at(
"position")[0].get_to(placement.mPosition.x);
155 json.at(
"position")[1].get_to(placement.mPosition.y);
156 json.at(
"position")[2].get_to(placement.mPosition.z);
157 json.at(
"position")[3].get_to(placement.mPosition.w);
159 json.at(
"orientation")[0].get_to(placement.mOrientation.w);
160 json.at(
"orientation")[1].get_to(placement.mOrientation.x);
161 json.at(
"orientation")[2].get_to(placement.mOrientation.y);
162 json.at(
"orientation")[3].get_to(placement.mOrientation.z);
163 placement.mOrientation = glm::normalize(placement.mOrientation);
165 json.at(
"scale")[0].get_to(placement.mScale.x);
166 json.at(
"scale")[1].get_to(placement.mScale.y);
167 json.at(
"scale")[2].get_to(placement.mScale.z);
171 inline void to_json(nlohmann::json& json,
const Placement& placement) {
175 placement.mPosition.x,
176 placement.mPosition.y,
177 placement.mPosition.z,
178 placement.mPosition.w,
181 placement.mOrientation.w,
182 placement.mOrientation.x,
183 placement.mOrientation.y,
184 placement.mOrientation.z,
195 inline void to_json(nlohmann::json& json,
const SceneHierarchyData& sceneHierarchyData) {
196 (void)json; (void)sceneHierarchyData;
200 inline void from_json(
const nlohmann::json& json,
SceneHierarchyData& sceneHierarchyData) {
201 (void)json; (void)sceneHierarchyData;
205 inline void to_json(nlohmann::json& json,
const Transform& transform) {
213 inline void from_json(
const nlohmann::json& json,
Transform& transform) {
215 transform.mModelMatrix = glm::mat4{1.f};
233 float simulationProgress
237 .mPosition{ (1.f - simulationProgress) * previousState.
mPosition + simulationProgress * nextState.
mPosition },
239 .mScale{ (1.f - simulationProgress) * previousState.
mScale + simulationProgress * nextState.
mScale }
258 float simulationProgress
282 float simulationProgress
285 (void)simulationProgress;
RangeMapperLinear mProgressLimits
a functor that performs the actual interpolation in the default case
Definition ecs_world.hpp:354
ToyMaker Engine's implementation of an ECS system.
T operator()(const T &previousState, const T &nextState, float simulationProgress=1.f) const
Returns an interpolated value for a component between two given states.
Definition ecs_world.hpp:2346
constexpr EntityID kMaxEntities
A user-set constant which limits the number of creatable entities in a single ECS system.
Definition ecs_world.hpp:119
std::uint64_t EntityID
A single unsigned integer used as a name for an entity managed by an ECS system.
Definition ecs_world.hpp:68
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition camera_system.hpp:20
A component representing the position, rotation, and scale of an entity.
Definition scene_components.hpp:30
bool operator!=(const Placement &other)
An explicit specification for the inequality operator.
Definition scene_components.hpp:80
bool operator==(const Placement &other)
Compares this placement object to another for equality.
Definition scene_components.hpp:65
glm::quat mOrientation
This entity's orientation, as a glm::quat value.
Definition scene_components.hpp:43
static std::string getComponentTypeName()
Gets the component type string for this component.
Definition scene_components.hpp:56
glm::vec4 mPosition
This entity's position.
Definition scene_components.hpp:35
glm::vec3 mScale
Factors along each axis by which geometry should be multiplied and scaled.
Definition scene_components.hpp:49
Component representing hierarchical information related to this entity.
Definition scene_components.hpp:118
static std::string getComponentTypeName()
Gets the component type string associated with this object.
Definition scene_components.hpp:148
EntityID mSibling
The entityID of this entity's next sibling.
Definition scene_components.hpp:133
EntityID mParent
The entityID of this entity's parent.
Definition scene_components.hpp:125
EntityID mChild
The first child of this entity.
Definition scene_components.hpp:141