Skip to content

Commit 21508fd

Browse files
committed
clean up model selection gui code
1 parent 51cc538 commit 21508fd

File tree

3 files changed

+53
-31
lines changed

3 files changed

+53
-31
lines changed

Model-Modifier/Model-Modifier.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@
344344
<ClInclude Include="src\external\stb\stb_image_write.h" />
345345
<ClInclude Include="src\HeightMap.h" />
346346
<ClInclude Include="src\HeightMapUniform.h" />
347+
<ClInclude Include="src\ImguiSections.h" />
347348
<ClInclude Include="src\renderer\SaveImage.h" />
348349
<ClInclude Include="src\scene\Light.h" />
349350
<ClInclude Include="src\scene\Material.h" />

Model-Modifier/src/ImguiSections.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#pragma once
2+
3+
#include "scene/object/ObjectSelect.h"
4+
#include <string>
5+
#include <utility>
6+
#include <vector>
7+
8+
9+
std::vector<std::pair<unsigned int, const char *>> geometricObjectNames
10+
{
11+
{ CRUMPLED, "Crumbled" },
12+
{ CUBE, "Cube" },
13+
{ DOUBLETORUS, "Double torus"},
14+
{ FANDISK, "Fandisk" },
15+
{ ICOSA, "Icosahedron" },
16+
{ OCTA, "Octahedron" },
17+
{ OLOID, "Oloid" },
18+
{ SPHERE, "Sphere" },
19+
{ STAR, "Star" },
20+
{ T, "T-Shape" },
21+
{ TORUS, "Torus" },
22+
{ TUBES, "Tubes" }
23+
};
24+
25+
std::vector<std::pair<unsigned int, const char*>> modelObjectNames
26+
{
27+
{ ANKYLOSAURUS, "Ankylosaurus"},
28+
{ ARMADILLO, "Armadillo" },
29+
{ BOB, "Bob (Tri)" },
30+
{ BOB2, "Bob (Quad)" },
31+
{ BUNNY, "Bunny" },
32+
{ COW, "Cow (Tri)" },
33+
{ COW2, "Cow (Mixed)" },
34+
{ COWHEAD, "Cow head" },
35+
{ FACE, "Face" },
36+
{ GARGOYLE, "Gargoyle" },
37+
{ KITTEN, "Kitten" },
38+
{ SHUTTLE, "Shuttle" },
39+
{ SUZANNE, "Suzanne" },
40+
{ TEAPOT, "Teapot" },
41+
{ TEDDY, "Teddy" }
42+
};

Model-Modifier/src/main.cpp

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "scene/Light.h"
2525
#include "scene/surface/Surface.h"
2626

27+
#include "ImguiSections.h"
28+
2729
enum shaderEnum
2830
{
2931
GOURAND,
@@ -299,42 +301,19 @@ int main()
299301
if (ImGui::CollapsingHeader("Geometric objects"))
300302
{
301303
ImGui::Indent();
302-
303-
ImGui::RadioButton("Crumbled", &nextObject, CRUMPLED);
304-
ImGui::RadioButton("Cube", &nextObject, CUBE);
305-
ImGui::RadioButton("Double torus", &nextObject, DOUBLETORUS);
306-
ImGui::RadioButton("Fandisk", &nextObject, FANDISK);
307-
ImGui::RadioButton("Icosahedron", &nextObject, ICOSA);
308-
ImGui::RadioButton("Octahedron", &nextObject, OCTA);
309-
ImGui::RadioButton("Oloid", &nextObject, OLOID);
310-
ImGui::RadioButton("Sphere", &nextObject, SPHERE);
311-
ImGui::RadioButton("Star", &nextObject, STAR);
312-
ImGui::RadioButton("T-Shape", &nextObject, T);
313-
ImGui::RadioButton("Torus", &nextObject, TORUS);
314-
ImGui::RadioButton("Tubes", &nextObject, TUBES);
315-
304+
for (std::pair<unsigned int, const char *> displayName : geometricObjectNames)
305+
{
306+
ImGui::RadioButton(displayName.second, &nextObject, displayName.first);
307+
}
316308
ImGui::Unindent();
317309
}
318310
if (ImGui::CollapsingHeader("Model objects"))
319311
{
320312
ImGui::Indent();
321-
322-
ImGui::RadioButton("Ankylosaurus", &nextObject, ANKYLOSAURUS);
323-
ImGui::RadioButton("Armadillo", &nextObject, ARMADILLO);
324-
ImGui::RadioButton("Bob (Tri)", &nextObject, BOB);
325-
ImGui::RadioButton("Bob (Quad)", &nextObject, BOB2);
326-
ImGui::RadioButton("Bunny", &nextObject, BUNNY);
327-
ImGui::RadioButton("Cow (Tri)", &nextObject, COW);
328-
ImGui::RadioButton("Cow (Mixed)", &nextObject, COW2);
329-
ImGui::RadioButton("Cow head", &nextObject, COWHEAD);
330-
ImGui::RadioButton("Face", &nextObject, FACE);
331-
ImGui::RadioButton("Gargoyle", &nextObject, GARGOYLE);
332-
ImGui::RadioButton("Kitten", &nextObject, KITTEN);
333-
ImGui::RadioButton("Shuttle", &nextObject, SHUTTLE);
334-
ImGui::RadioButton("Suzanne", &nextObject, SUZANNE);
335-
ImGui::RadioButton("Teapot", &nextObject, TEAPOT);
336-
ImGui::RadioButton("Teddy", &nextObject, TEDDY);
337-
313+
for (std::pair<unsigned int, const char*> displayName : modelObjectNames)
314+
{
315+
ImGui::RadioButton(displayName.second, &nextObject, displayName.first);
316+
}
338317
ImGui::Unindent();
339318
}
340319
ImGui::Unindent();

0 commit comments

Comments
 (0)