-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleScene.h
More file actions
147 lines (108 loc) · 3.1 KB
/
Copy pathModuleScene.h
File metadata and controls
147 lines (108 loc) · 3.1 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef __ModuleScene_H__
#define __ModuleScene_H__
#include "Globals.h"
#include "Module.h"
#include "GameObject.h"
#include "Timer.h"
#include "Point.h"
#include "imgui/imgui.h"
#include "MathGeoLib/Math/float2.h"
#include <set>
class MyQuadTree;
class AABBTree;
enum ShapeType
{
OTHER = 0,
SPHERE,
CUBE,
CYLINDER,
TORUS
};
class ModuleScene : public Module
{
public:
ModuleScene();
~ModuleScene();
//Core
bool Init();
update_status PreUpdate();
update_status Update();
bool CleanUp();
//Methods
GameObject* CreateGameObject();
GameObject* CreateGameObject(const char* name, GameObject* parent);
GameObject* CreateGameObject(GameObject* go);
void LoadModel(const char* path, GameObject* parent);
//Creators
void CreateEmpty(GameObject* parent);
void CreateGameObjectBakerHouse(GameObject* parent);
void CreateGameObjectZomBunny(GameObject* parent);
void CreateGameObjectByName(GameObject* parent, const char* name);
void CreateGameObjectShape(GameObject* parent, ShapeType shape);
//Delete
void RemoveGameObject(GameObject* go);
void SelectObjectInHierarchy(GameObject* selected);
//Drawing Methods
void DrawGUI();
//AllGameObjectsCreated
std::set<GameObject*> allGameObjects;
std::set<GameObject*> staticGO;
std::set<GameObject*> dynamicGO;
bool showHierarchy = true;
bool showInspector = true;
std::set<unsigned int> UIDs;
//Game's Main Camera Object
GameObject* mainCamera = nullptr;
//Directional light
GameObject* directionalLight = nullptr;
//QuadTree
MyQuadTree* quadtree = nullptr;
AABBTree* aabbTree = nullptr;
void AddToQuadtree(GameObject* go) const;
bool quadTreeInitialized = false;
//Static objects
void BuildQuadTree();
//Dynamic objects
void BuildAABBTree();
void CreateCubesScript();
void CreateShapesScript();
void CreateHousesScript();
AABB* ComputeSceneAABB() const;
//Move Objects
void MoveObjects(GameObject* go) const;
//Timers
Timer iterative = Timer();
Timer aabbTreeTimer = Timer();
float timeIterative = 0.0f;
float timeAABBTree = 0.0f;
bool quadtreeIsComputed = false;
bool aabbTreeIsComputed = false;
bool moveObjectsArround = false;
bool moveItems = false;
void SaveScene();
void LoadScene();
GameObject* clipboard = nullptr;
void PasteGameObject(GameObject* go);
void DuplicateGameObject(GameObject* go);
void InsertChilds(GameObject* go);
GameObject* selectedByHierarchy = nullptr;
//Mouse Picking
LineSegment* CreateRayCast(const float3 &origin, const float3 &direction, float maxDistance) const;
GameObject* IntersectRayCast(const float3 &origin, const LineSegment &ray);
LineSegment* CreateRayCast(float normalizedX, float normalizedY) const;
LineSegment* currentRay = nullptr;
void PickObject(const ImVec2 &sizeWindow, const ImVec2 &posWindow);
GameObject* GetRoot() const;
private:
//Root
GameObject* root = nullptr;
//GameObjects Counter
unsigned int numberOfGameObjects = 0;
unsigned int numberOfBakerHouse = 0;
unsigned int numberOfSphere = 0;
unsigned int numberOfCube = 0;
unsigned int numberOfTorus = 0;
unsigned int numberOfCylinder = 0;
float2 offset = float2(-5.0f, -25.0f);
};
#endif __ModuleScene_H__