-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGameObject.cpp
76 lines (65 loc) · 1.3 KB
/
GameObject.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "GameObject.h"
#include "GLFWApp.h"
GameObject::GameObject() : m_parent(nullptr), m_mesh(nullptr), m_object_type(OBJECT_NORMAL)//, m_animator(nullptr)//, m_collider(nullptr)
{
}
GameObject::~GameObject()
{
#ifdef _DEBUG
std::cout << "Obj Dtor\n";
#endif
Release();
}
void GameObject::Initialize()
{
m_transform.Update();
}
void GameObject::Initialize(const glm::vec3& init_pos)
{
m_transform.m_translation = init_pos;
m_transform.Update();
}
void GameObject::Initialize(Transform & trans)
{
m_transform = trans;
m_transform.Update();
}
void GameObject::Update()
{
if (m_object_type == OBJECT_FLAG_ENUM::OBJECT_STATIC)
return;
m_transform.Update();
}
void GameObject::Release()
{
m_mesh.reset();
//m_animator.reset();
//delete m_transform;
}
void GameObject::AddChild(std::shared_ptr<GameObject> child)
{
m_childs.push_back(child);
}
void GameObject::setParent(std::shared_ptr<GameObject> parent)
{
m_parent = parent;
m_transform.setParent(&(parent->m_transform));
}
void GameObject::setMesh(std::shared_ptr<Mesh> obj)
{
m_mesh = obj;
}
void GameObject::setObjectType(OBJECT_FLAG_ENUM type)
{
m_object_type = type;
}
void GameObject::setName(std::string name)
{
m_name = name;
}
/*
void GameObject::setAnimator(std::shared_ptr<Animator> animator)
{
//m_animator = animator;
}
*/