|
Hymn to Beauty
C++ 3D Engine
|
Entity containing various components. More...
#include <Entity.hpp>
Public Member Functions | |
| Entity (World *world, const std::string &name) | |
| Create new entity. More... | |
| ~Entity () | |
| Destructor. More... | |
| Entity * | GetParent () const |
| Get the entity's parent entity. More... | |
| Entity * | AddChild (const std::string &name="") |
| Add child entity. More... | |
| bool | RemoveChild (Entity *child) |
| Remove child entity. More... | |
| Entity * | SetParent (Entity *newParent) |
| Set a new parent. More... | |
| bool | HasChild (const Entity *child, bool deep=true) const |
| Check if entity is a child. More... | |
| Entity * | InstantiateScene (const std::string &name) |
| Instantiate a scene as a child to this entity. More... | |
| Entity * | InstantiateScene (const std::string &name, const std::string &originScene) |
| Instantiate a scene as a child to this entity. More... | |
| void | CheckIfSceneExists (const std::string &filename, bool &error, const std::string &originScene, Json::Value root) |
| Check if scene already exists in any of json files. More... | |
| const std::vector< Entity * > & | GetChildren () const |
| Get all of the entity's children. More... | |
| Entity * | GetChild (const std::string &name) const |
| Get child based on its name. More... | |
| Entity * | GetChildFromIndex (int index) const |
| Get child based on its name. More... | |
| unsigned int | GetNumChildren () const |
| Get the number of children. More... | |
| bool | IsScene () const |
| Get whether the entity is an instantiated scene. More... | |
| template<typename T > | |
| T * | AddComponent () |
| Adds component with type T. More... | |
| template<typename T > | |
| T * | GetComponent () const |
| Gets component with type T. More... | |
| template<typename T > | |
| void | KillComponent () |
| Kill component of type T. More... | |
| void | Kill () |
| Kill the entity, will be removed at the end of the frame. More... | |
| bool | IsKilled () const |
| Get whether entity has been killed. More... | |
| void | Serialize (Json::Value &node, bool load) |
| Save or load entity to/from JSON. More... | |
| const glm::vec3 & | GetPosition () const |
| Get the local position. More... | |
| void | SetPosition (const glm::vec3 &position) |
| Set the local position. More... | |
| glm::vec3 | GetWorldPosition () const |
| Get the position in the world. More... | |
| void | SetWorldPosition (const glm::vec3 &worldPos) |
| Set the position of the entity in world space. More... | |
| void | Move (const glm::vec3 &translation) |
| Move in local space. More... | |
| const glm::vec3 & | GetScale () const |
| Get the local scale. More... | |
| void | SetScale (const glm::vec3 &scale) |
| Set the local scale. More... | |
| const glm::quat & | GetRotation () const |
| Get the rotation of this entity. More... | |
| void | SetRotation (const glm::quat &localRot) |
| Set the local rotation of the entity. More... | |
| glm::quat | GetWorldRotation () const |
| Get rotation of the entity. More... | |
| void | SetWorldRotation (const glm::quat &worldRot) |
| Set the rotation of the entity in world space. More... | |
| glm::vec3 | GetWorldDirection () const |
| Get direction of the entity. More... | |
| void | RotateYaw (float angle) |
| Rotates around the Y axis. More... | |
| void | RotatePitch (float angle) |
| Rotates around the X axis. More... | |
| void | RotateRoll (float angle) |
| Rotates around the Z axis. More... | |
| void | RotateAroundWorldAxis (float angle, const glm::vec3 &axis) |
| Rotates around an axis given in world space. More... | |
| const glm::mat4 & | GetLocalMatrix () const |
| Get the local model matrix. More... | |
| const glm::mat4 & | GetWorldModelMatrix () const |
| Get the world model matrix. More... | |
| void | SetEnabled (bool enabled, bool recursive=false) |
| Set whether the entity should be enabled. More... | |
| bool | IsEnabled () const |
| Get whether the entity is enabled. More... | |
| unsigned int | GetUniqueIdentifier () const |
| Get the entity's UID. More... | |
| void | SetUniqueIdentifier (unsigned int UID) |
| Set the entity's UID. More... | |
Public Attributes | |
| std::string | name |
| Name of the entity. More... | |
| bool | loadPaintModeClicked = false |
| Variables used for enabling and disabling the paint brush tool. More... | |
| bool | brushActive = false |
| bool | vertsLoaded = false |
| bool | painting = false |
| bool | sceneChosen = false |
Entity containing various components.
| Entity::Entity | ( | World * | world, |
| const std::string & | name | ||
| ) |
Create new entity.
| world | The game world in which the entity is contained. |
| name | Name of the entity. |
| Entity::~Entity | ( | ) |
Destructor.
| Entity * Entity::AddChild | ( | const std::string & | name = "" | ) |
Add child entity.
| name | The name of the child entity. |
| T * Entity::AddComponent |
Adds component with type T.
| void Entity::CheckIfSceneExists | ( | const std::string & | filename, |
| bool & | error, | ||
| const std::string & | originScene, | ||
| Json::Value | root | ||
| ) |
Check if scene already exists in any of json files.
| filename | The name of the scene to check. |
| error | Set to true inside the function if it allready exists. |
| originScene | Name of scene you want to check. |
| root | The json value of root scene. |
| Entity * Entity::GetChild | ( | const std::string & | name | ) | const |
Get child based on its name.
| name | The name of the child to get. |
| Entity * Entity::GetChildFromIndex | ( | int | index | ) | const |
Get child based on its name.
| index | The index of the child to get. |
| const std::vector< Entity * > & Entity::GetChildren | ( | ) | const |
Get all of the entity's children.
| T * Entity::GetComponent |
Gets component with type T.
| const glm::mat4 & Entity::GetLocalMatrix | ( | ) | const |
Get the local model matrix.
| unsigned int Entity::GetNumChildren | ( | ) | const |
Get the number of children.
| Entity * Entity::GetParent | ( | ) | const |
Get the entity's parent entity.
| const glm::vec3 & Entity::GetPosition | ( | ) | const |
Get the local position.
| const glm::quat & Entity::GetRotation | ( | ) | const |
Get the rotation of this entity.
| const glm::vec3 & Entity::GetScale | ( | ) | const |
Get the local scale.
| unsigned int Entity::GetUniqueIdentifier | ( | ) | const |
Get the entity's UID.
| glm::vec3 Entity::GetWorldDirection | ( | ) | const |
Get direction of the entity.
| const glm::mat4 & Entity::GetWorldModelMatrix | ( | ) | const |
Get the world model matrix.
| glm::vec3 Entity::GetWorldPosition | ( | ) | const |
Get the position in the world.
| glm::quat Entity::GetWorldRotation | ( | ) | const |
Get rotation of the entity.
| bool Entity::HasChild | ( | const Entity * | child, |
| bool | deep = true |
||
| ) | const |
Check if entity is a child.
| child | The entity you want to check if it is a child. |
| deep | True if we want to check if it's a grandchild, false if we do not. |
| Entity * Entity::InstantiateScene | ( | const std::string & | name | ) |
Instantiate a scene as a child to this entity.
| name | The name of the scene to instantiate. |
| Entity * Entity::InstantiateScene | ( | const std::string & | name, |
| const std::string & | originScene | ||
| ) |
Instantiate a scene as a child to this entity.
| name | The name of the scene to instantiate. |
| originScene | The name of the scene to instantiate within (to check for recursion). |
| bool Entity::IsEnabled | ( | ) | const |
Get whether the entity is enabled.
| bool Entity::IsKilled | ( | ) | const |
Get whether entity has been killed.
| bool Entity::IsScene | ( | ) | const |
Get whether the entity is an instantiated scene.
| void Entity::Kill | ( | ) |
Kill the entity, will be removed at the end of the frame.
| void Entity::KillComponent |
Kill component of type T.
| void Entity::Move | ( | const glm::vec3 & | translation | ) |
Move in local space.
| translation | Movement in local space. |
| bool Entity::RemoveChild | ( | Entity * | child | ) |
Remove child entity.
| child | The entity you want to remove. |
| void Entity::RotateAroundWorldAxis | ( | float | angle, |
| const glm::vec3 & | axis | ||
| ) |
Rotates around an axis given in world space.
| angle | The angle in radians that we want to rotate. |
| axis | World space axis to rotate around. |
| void Entity::RotatePitch | ( | float | angle | ) |
Rotates around the X axis.
| angle | The angle in radians that we want to rotate. |
| void Entity::RotateRoll | ( | float | angle | ) |
Rotates around the Z axis.
| angle | The angle in radians that we want to rotate. |
| void Entity::RotateYaw | ( | float | angle | ) |
Rotates around the Y axis.
| angle | The angle in radians that we want to rotate. |
| void Entity::Serialize | ( | Json::Value & | node, |
| bool | load | ||
| ) |
Save or load entity to/from JSON.
| node | The JSON node to save to or load from. |
| load | Whether to load (otherwise saves). |
| void Entity::SetEnabled | ( | bool | enabled, |
| bool | recursive = false |
||
| ) |
Set whether the entity should be enabled.
| enabled | Whether the entity should be enabled. |
| recursive | Whether to set all children recursively. |
Set a new parent.
| newParent | The entity you want to be the new parent. |
| void Entity::SetPosition | ( | const glm::vec3 & | position | ) |
Set the local position.
| position | The new position. |
| void Entity::SetRotation | ( | const glm::quat & | localRot | ) |
Set the local rotation of the entity.
| localRot | The local rotation you want the entity to have. |
| void Entity::SetScale | ( | const glm::vec3 & | scale | ) |
Set the local scale.
| scale | The new scale. |
| void Entity::SetUniqueIdentifier | ( | unsigned int | UID | ) |
Set the entity's UID.
| UID | the entity's unique identifier to be set |
| void Entity::SetWorldPosition | ( | const glm::vec3 & | worldPos | ) |
Set the position of the entity in world space.
| worldPos | The world position you want the entity to have. |
| void Entity::SetWorldRotation | ( | const glm::quat & | worldRot | ) |
Set the rotation of the entity in world space.
| worldRot | New rotation. |
| bool Entity::brushActive = false |
| bool Entity::loadPaintModeClicked = false |
Variables used for enabling and disabling the paint brush tool.
| std::string Entity::name |
Name of the entity.
| bool Entity::painting = false |
| bool Entity::sceneChosen = false |
| bool Entity::vertsLoaded = false |