-
Notifications
You must be signed in to change notification settings - Fork 1
/
GameObject.h
133 lines (96 loc) · 2.43 KB
/
GameObject.h
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef GAMEOBJECT_H_
#define GAMEOBJECT_H_
#include "Globals.h"
#include "Application.h"
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_opengl3.h"
#include "MathGeoLib/include/MathGeoLib.h"
#include "Assimp/include/cimport.h"
#include "Assimp/include/scene.h"
#include "Assimp/include/postprocess.h"
#include "Assimp/include/cfileio.h"
#pragma comment (lib, "lib/Assimp/libx86/assimp.lib")
#ifdef _DEBUG
#pragma comment (lib, "lib/MathGeoLib/libx86/Debug/MathGeoLib.lib")
#else
#pragma comment (lib, "lib/MathGeoLib/libx86/Release/MathGeoLib.lib")
#endif
struct Texture {
uint id;
string path;
aiTextureType type;
vec2 size;
};
class MeshObject;
class Component;
class C_Normals;
class C_Transform;
class C_Camera;
class Animator;
enum aiTextureType;
enum Component_Type;
class GameObject
{
public:
GameObject(string name,GameObject* parent = nullptr);
GameObject(MeshObject* mesh, vector<Texture*> textures, string name);
~GameObject();
virtual void Draw() {}
bool Start();
void StartChilds();
void UpdateChilds();
void drawChilds();
float4x4 mat2float4(mat4x4 mat);
mat4x4 Float2Mat4(float4x4 f);
void CleanUp();
void UpdateBox();
const char* getType(aiTextureType type);
Component* AddComponent(Component_Type type);
Component* getComponent(Component_Type type);
void Save(const char * name, json& file);
void Load(const char * name, const json& file);
public:
MeshObject* mesh = nullptr;
vector<Texture*> textures;
vector<Component*> components;
vector<GameObject*> childs;
GameObject* parent = nullptr;
bool face_normals = false;
bool vertex_normals = false;
string name;
FileFormats c_texformat = PNG;
bool debug_tex = false;
bool active = true;
bool selected = false;
bool _static = false;
AABB box;
AABB aabb;
OBB obb;
bool boundary_box = false;
UID ID = 0;
public:
C_Transform* transform = nullptr;
C_Normals* normals = nullptr;
C_Camera* camera = nullptr;
Animator* animator = nullptr;
public:
//GET COMPONENTS ----------------------------
template<typename RetComponent>
RetComponent* GetComponent()
{
Component::Type type = RetComponent::GetType();
if (type == Component::Type::Transform)
return (RetComponent*)transform;
for (uint i = 0; i < components.size(); i++)
{
if (components[i]->GetType() == type)
{
return ((RetComponent*)(components[i]));
}
}
return nullptr;
}
//GET COMPONENTS ----------------------------
};
#endif GAMEOBJECT_H_