-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathC_MeshInfo.cpp
More file actions
59 lines (51 loc) · 1.56 KB
/
C_MeshInfo.cpp
File metadata and controls
59 lines (51 loc) · 1.56 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
#include "C_MeshInfo.h"
#include "MeshObject.h"
C_MeshInfo::C_MeshInfo(GameObject* gameobject, Component_Type type) : Component(type, gameobject)
{
name = "Mesh Info";
ID = App->RandomNumberGenerator.GetIntRNInRange();
}
C_MeshInfo::~C_MeshInfo()
{
}
bool C_MeshInfo::Enable()
{
active = true;
return true;
}
void C_MeshInfo::Update()
{
if (ImGui::CollapsingHeader(name.c_str(), open_mesh_info))
{
int vs = 0;
int is = 0;
if (gameobject->mesh != nullptr) {
vs = gameobject->mesh->vertices.size();
is = gameobject->mesh->indices.size() / 3;
}
ImGui::Text("Vertices: %i", vs); ImGui::SameLine(); ImGui::Spacing(); ImGui::SameLine(); ImGui::Text("Tris: %i", is);
ImGui::Checkbox("Boundary Box", &gameobject->boundary_box);
if (ImGui::IsItemActivated()) { gameobject->UpdateBox(); }
}
if (!unFold) {
ImGui::GetStateStorage()->SetInt(ImGui::GetID(name.c_str()), 1);
unFold = true;
}
}
bool C_MeshInfo::Disable()
{
active = false;
return true;
}
void C_MeshInfo::Save(const char * _name, json & file)
{
file["Game Objects"][_name]["Components"]["Mesh"]["ID"] = id;
file["Game Objects"][_name]["Components"]["Mesh"]["Name"] = resource_name;
file["Game Objects"][_name]["Components"]["Mesh"]["Active"] = gameobject->boundary_box;
}
void C_MeshInfo::Load(const char * _name, const json & file)
{
id = file["Game Objects"][_name]["Components"]["Mesh"]["ID"].get<UID>();
resource_name = file["Game Objects"][_name]["Components"]["Mesh"]["Name"].get<string>();
gameobject->boundary_box = file["Game Objects"][_name]["Components"]["Mesh"]["Active"].get<bool>();
}