3 #include "../../debug_ui.h"
26 std::vector<Triangle> triangles = {
41 std::vector<PosColorVertex> verticies = {
42 {-1.0f, 1.0f, 1.0f, 0xff000000 },
43 { 1.0f, 1.0f, 1.0f, 0xff0000ff },
44 {-1.0f, -1.0f, 1.0f, 0xff00ff00 },
45 { 1.0f, -1.0f, 1.0f, 0xff00ffff },
46 {-1.0f, 1.0f, -1.0f, 0xffff0000 },
47 { 1.0f, 1.0f, -1.0f, 0xffff00ff },
48 {-1.0f, -1.0f, -1.0f, 0xffffff00 },
49 { 1.0f, -1.0f, -1.0f, 0xffffffff },
52 bool auto_rebuild =
false;
53 int delete_triangle_at = -1;
54 int delete_vertex_at = -1;
65 if (ImGui::Begin(
"Geometry Test", &
show))
67 ImGui::Checkbox(
"auto rebuild", &auto_rebuild);
71 if (ImGui::CollapsingHeader(
"triangles"))
73 ImGui::PushID(
"triangle_controls");
75 if (ImGui::Button(
"+"))
80 if (ImGui::Button(
"delete @"))
82 if (delete_triangle_at < triangles.size() && delete_triangle_at > -1)
84 triangles.erase(triangles.begin() + delete_triangle_at);
88 ImGui::InputInt(
"index", &delete_triangle_at);
94 for (
int i = 0; i < triangles.size(); i++)
96 ImGui::PushItemWidth(250.0f);
97 ImGui::PushID(std::string(
"triangle_i_" + std::to_string(i)).c_str());
99 Triangle* triangle = &triangles.at(i);
100 ImGui::InputShort(
"x", (
short*)&triangle->
x, 1, 10, NULL);
102 ImGui::InputShort(
"y", (
short*)&triangle->
y, 1, 10, NULL);
104 ImGui::InputShort(
"z", (
short*)&triangle->
z, 1, 10, NULL);
107 ImGui::PopItemWidth();
111 if (ImGui::CollapsingHeader(
"verticies"))
113 ImGui::PushID(
"vertex_controls");
115 if (ImGui::Button(
"+"))
120 if (ImGui::Button(
"delete @"))
122 if (delete_vertex_at < verticies.size() && delete_vertex_at > -1)
124 verticies.erase(verticies.begin() + delete_vertex_at);
128 ImGui::InputInt(
"index", &delete_vertex_at);
134 for (
int i = 0; i < verticies.size(); i++)
136 ImGui::PushItemWidth(250.0f);
137 ImGui::PushID(std::string(
"vertex_i_" + std::to_string(i)).c_str());
140 ImGui::InputFloat(
"x", &vertex->
x);
142 ImGui::InputFloat(
"y", &vertex->
y);
144 ImGui::InputFloat(
"z", &vertex->
z);
146 ImVec4
color = ImGui::ColorConvertU32ToFloat4(vertex->
abgr);
148 ImGui::ColorEdit4(
"color", (
float*)&
color);
150 vertex->
abgr = ImGui::ColorConvertFloat4ToU32(
color);
152 ImGui::PopItemWidth();
159 ImGui::TextDisabled(
"model data is automatically rebuilt");
163 std::vector<uint16_t> triangles_raw = {};
167 triangles_raw.push_back(t.x);
168 triangles_raw.push_back(t.y);
169 triangles_raw.push_back(t.z);
178 if (ImGui::Button(
"rebuild model data"))
182 std::vector<uint16_t> triangles_raw = {};
186 triangles_raw.push_back(t.x);
187 triangles_raw.push_back(t.y);
188 triangles_raw.push_back(t.z);