Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
eng::GameObject Class Reference

#include <GameObject.h>

+ Inheritance diagram for eng::GameObject:
+ Collaboration diagram for eng::GameObject:

Public Member Functions

virtual ~GameObject ()=default
 
virtual void Init ()
 
virtual void LoadProperties (const nlohmann::json &json)
 
virtual void Update (float deltaTime)
 
const std::string & GetName () const
 
void SetName (const std::string &name)
 
GameObjectGetParent ()
 
bool SetParent (GameObject *parent)
 
SceneGetScene ()
 
bool IsAlive () const
 
void MarkForDestroy ()
 
void SetActive (bool active)
 
bool IsActive () const
 
void AddComponent (Component *component)
 
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<Component, T>>>
T * GetComponent ()
 
GameObjectFindChildByName (const std::string &name)
 
const glm::vec3 & GetPosition () const
 
glm::vec3 GetWorldPosition () const
 
glm::vec2 GetPosition2D () const
 
glm::vec2 GetWorldPosition2D () const
 
void SetPosition (const glm::vec3 &pos)
 
void SetWorldPosition (const glm::vec3 &pos)
 
void SetPosition2D (const glm::vec2 &pos)
 
const glm::quat & GetRotation () const
 
glm::quat GetWorldRotation ()
 
float GetRotation2D () const
 
void SetRotation (const glm::quat &rot)
 
void SetWorldRotation (const glm::quat &rot)
 
void SetRotation2D (float rotation)
 
const glm::vec3 & GetScale () const
 
glm::vec2 GetScale2D () const
 
void SetScale (const glm::vec3 &scale)
 
void SetScale2D (const glm::vec2 &scale)
 
glm::mat4 GetLocalTransform () const
 
glm::mat4 GetLocalTransform2D () const
 
glm::mat4 GetWorldTransform () const
 
glm::mat4 GetWorldTransform2D () const
 

Static Public Member Functions

static GameObjectLoadGLTF (const std::string &path, Scene *scene)
 

Protected Member Functions

 GameObject ()=default
 

Protected Attributes

std::string m_name
 
GameObjectm_parent = nullptr
 
Scenem_scene = nullptr
 
std::vector< std::unique_ptr< GameObject > > m_children
 
std::vector< std::unique_ptr< Component > > m_components
 
bool m_isAlive = true
 
glm::vec3 m_position = glm::vec3(0.0f)
 
glm::quat m_rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f)
 
glm::vec3 m_scale = glm::vec3(1.0f)
 
bool m_active = true
 

Friends

class Scene
 

Detailed Description

Definition at line 14 of file GameObject.h.

Constructor & Destructor Documentation

◆ ~GameObject()

virtual eng::GameObject::~GameObject ( )
virtualdefault

◆ GameObject()

eng::GameObject::GameObject ( )
protecteddefault

Member Function Documentation

◆ AddComponent()

void eng::GameObject::AddComponent ( Component component)

Definition at line 105 of file GameObject.cpp.

References eng::Component::Init(), m_components, and eng::Component::m_owner.

Referenced by TestObject::TestObject().

◆ FindChildByName()

GameObject * eng::GameObject::FindChildByName ( const std::string &  name)

Definition at line 116 of file GameObject.cpp.

References m_children, and m_name.

Referenced by Player::Init(), and Player::Update().

◆ GetComponent()

template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<Component, T>>>
T * eng::GameObject::GetComponent ( )
inline

Definition at line 34 of file GameObject.h.

References m_components.

◆ GetLocalTransform()

glm::mat4 eng::GameObject::GetLocalTransform ( ) const

Definition at line 248 of file GameObject.cpp.

References m_position, m_rotation, and m_scale.

Referenced by GetWorldTransform().

◆ GetLocalTransform2D()

glm::mat4 eng::GameObject::GetLocalTransform2D ( ) const

Definition at line 264 of file GameObject.cpp.

References GetRotation2D(), m_position, and m_scale.

Referenced by GetWorldTransform2D().

◆ GetName()

const std::string & eng::GameObject::GetName ( ) const

Definition at line 55 of file GameObject.cpp.

References m_name.

◆ GetParent()

GameObject * eng::GameObject::GetParent ( )

Definition at line 65 of file GameObject.cpp.

References m_parent.

Referenced by eng::CameraComponent::GetViewMatrix(), and eng::Scene::SetParent().

◆ GetPosition()

const glm::vec3 & eng::GameObject::GetPosition ( ) const

Definition at line 134 of file GameObject.cpp.

References m_position.

Referenced by eng::CameraComponent::GetViewMatrix().

◆ GetPosition2D()

glm::vec2 eng::GameObject::GetPosition2D ( ) const

Definition at line 145 of file GameObject.cpp.

References m_position.

◆ GetRotation()

const glm::quat & eng::GameObject::GetRotation ( ) const

◆ GetRotation2D()

float eng::GameObject::GetRotation2D ( ) const

Definition at line 198 of file GameObject.cpp.

References m_rotation.

Referenced by GetLocalTransform2D().

◆ GetScale()

const glm::vec3 & eng::GameObject::GetScale ( ) const

Definition at line 228 of file GameObject.cpp.

References m_scale.

◆ GetScale2D()

glm::vec2 eng::GameObject::GetScale2D ( ) const

Definition at line 233 of file GameObject.cpp.

References m_scale.

◆ GetScene()

Scene * eng::GameObject::GetScene ( )

Definition at line 80 of file GameObject.cpp.

References m_scene.

Referenced by eng::ParseGLTFNode().

◆ GetWorldPosition()

glm::vec3 eng::GameObject::GetWorldPosition ( ) const

◆ GetWorldPosition2D()

glm::vec2 eng::GameObject::GetWorldPosition2D ( ) const

Definition at line 150 of file GameObject.cpp.

References GetWorldTransform2D().

◆ GetWorldRotation()

glm::quat eng::GameObject::GetWorldRotation ( )

◆ GetWorldTransform()

glm::mat4 eng::GameObject::GetWorldTransform ( ) const

◆ GetWorldTransform2D()

glm::mat4 eng::GameObject::GetWorldTransform2D ( ) const

◆ Init()

void eng::GameObject::Init ( )
virtual

Reimplemented in JumpPlatform, and Player.

Definition at line 21 of file GameObject.cpp.

◆ IsActive()

bool eng::GameObject::IsActive ( ) const

Definition at line 100 of file GameObject.cpp.

References m_active.

◆ IsAlive()

bool eng::GameObject::IsAlive ( ) const

Definition at line 85 of file GameObject.cpp.

References m_isAlive.

◆ LoadGLTF()

◆ LoadProperties()

void eng::GameObject::LoadProperties ( const nlohmann::json &  json)
virtual

Definition at line 25 of file GameObject.cpp.

◆ MarkForDestroy()

void eng::GameObject::MarkForDestroy ( )

Definition at line 90 of file GameObject.cpp.

References m_isAlive.

Referenced by Bullet::Update().

◆ SetActive()

void eng::GameObject::SetActive ( bool  active)

Definition at line 95 of file GameObject.cpp.

References m_active.

◆ SetName()

void eng::GameObject::SetName ( const std::string &  name)

Definition at line 60 of file GameObject.cpp.

References m_name.

Referenced by eng::Scene::CreateObject().

◆ SetParent()

bool eng::GameObject::SetParent ( GameObject parent)

Definition at line 70 of file GameObject.cpp.

References m_scene, and eng::Scene::SetParent().

◆ SetPosition()

void eng::GameObject::SetPosition ( const glm::vec3 &  pos)

Definition at line 156 of file GameObject.cpp.

References m_position.

Referenced by SetWorldPosition(), and eng::PlayerControllerComponent::Update().

◆ SetPosition2D()

void eng::GameObject::SetPosition2D ( const glm::vec2 &  pos)

Definition at line 176 of file GameObject.cpp.

References m_position.

◆ SetRotation()

void eng::GameObject::SetRotation ( const glm::quat &  rot)

Definition at line 203 of file GameObject.cpp.

References m_rotation.

Referenced by SetWorldRotation(), and eng::PlayerControllerComponent::Update().

◆ SetRotation2D()

void eng::GameObject::SetRotation2D ( float  rotation)

Definition at line 223 of file GameObject.cpp.

References m_rotation.

◆ SetScale()

void eng::GameObject::SetScale ( const glm::vec3 &  scale)

Definition at line 238 of file GameObject.cpp.

References m_scale.

◆ SetScale2D()

void eng::GameObject::SetScale2D ( const glm::vec2 &  scale)

Definition at line 243 of file GameObject.cpp.

References m_scale.

◆ SetWorldPosition()

void eng::GameObject::SetWorldPosition ( const glm::vec3 &  pos)

Definition at line 161 of file GameObject.cpp.

References GetWorldTransform(), m_parent, and SetPosition().

Referenced by eng::PhysicsComponent::Update().

◆ SetWorldRotation()

void eng::GameObject::SetWorldRotation ( const glm::quat &  rot)

Definition at line 208 of file GameObject.cpp.

References GetWorldRotation(), m_parent, and SetRotation().

Referenced by eng::PhysicsComponent::Update().

◆ Update()

void eng::GameObject::Update ( float  deltaTime)
virtual

Reimplemented in Bullet, Player, and TestObject.

Definition at line 29 of file GameObject.cpp.

References m_active, m_children, and m_components.

Referenced by Bullet::Update(), Player::Update(), and TestObject::Update().

Friends And Related Symbol Documentation

◆ Scene

friend class Scene
friend

Definition at line 93 of file GameObject.h.

Member Data Documentation

◆ m_active

bool eng::GameObject::m_active = true
protected

Definition at line 91 of file GameObject.h.

Referenced by IsActive(), SetActive(), and Update().

◆ m_children

std::vector<std::unique_ptr<GameObject> > eng::GameObject::m_children
protected

Definition at line 85 of file GameObject.h.

Referenced by FindChildByName(), eng::Scene::SetParent(), and Update().

◆ m_components

std::vector<std::unique_ptr<Component> > eng::GameObject::m_components
protected

Definition at line 86 of file GameObject.h.

Referenced by AddComponent(), GetComponent(), and Update().

◆ m_isAlive

bool eng::GameObject::m_isAlive = true
protected

Definition at line 87 of file GameObject.h.

Referenced by IsAlive(), and MarkForDestroy().

◆ m_name

std::string eng::GameObject::m_name
protected

Definition at line 82 of file GameObject.h.

Referenced by FindChildByName(), GetName(), and SetName().

◆ m_parent

GameObject* eng::GameObject::m_parent = nullptr
protected

◆ m_position

glm::vec3 eng::GameObject::m_position = glm::vec3(0.0f)
protected

◆ m_rotation

glm::quat eng::GameObject::m_rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f)
protected

◆ m_scale

glm::vec3 eng::GameObject::m_scale = glm::vec3(1.0f)
protected

◆ m_scene

Scene* eng::GameObject::m_scene = nullptr
protected

Definition at line 84 of file GameObject.h.

Referenced by GetScene(), SetParent(), and Player::Update().


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