diff --git a/OpenGLEngine/MeshGenerator.h b/OpenGLEngine/MeshGenerator.h index 108a183..9bdc5e1 100644 --- a/OpenGLEngine/MeshGenerator.h +++ b/OpenGLEngine/MeshGenerator.h @@ -2,6 +2,8 @@ #include +#include + #include "MeshFactory.h" #include "Mesh.h" #include "BuiltinTypes.h" @@ -10,6 +12,7 @@ namespace charcoal { + using namespace glm; namespace builtin { // Uses MeshFactory to generate meshes for the builtin vertex types. @@ -25,6 +28,107 @@ namespace charcoal return mesh; } + template + Mesh* gen_plane_p(const DrawMode& draw_mode, float width, float depth) + { + Mesh* mesh; + + float x = width / 2.0f; + float z = depth / 2.0f; + + Position pos0(-x, 0.0f, z); + Position pos1(-x, 0.0f, -z); + Position pos2( x, 0.0f, z); + Position pos3( x, 0.0f, -z); + + switch (draw_mode) + { + case DrawMode::DRAW_POINTS: + mesh = MeshFactory::create_mesh(4, 4); + mesh->vertices[0].set_position(pos0); + mesh->vertices[1].set_position(pos1); + mesh->vertices[2].set_position(pos2); + mesh->vertices[3].set_position(pos3); + mesh->indices[0] = 0; + mesh->indices[1] = 1; + mesh->indices[2] = 2; + mesh->indices[3] = 3; + break; + case DrawMode::DRAW_LINE_STRIP: + mesh = MeshFactory::create_mesh(4, 5); + mesh->vertices[0].set_position(pos0); + mesh->vertices[1].set_position(pos1); + mesh->vertices[2].set_position(pos2); + mesh->vertices[3].set_position(pos3); + mesh->indices[0] = 0; + mesh->indices[1] = 1; + mesh->indices[2] = 3; + mesh->indices[3] = 2; + mesh->indices[4] = 0; + break; + case DrawMode::DRAW_LINE_LOOP: + mesh = MeshFactory::create_mesh(4, 4); + mesh->vertices[0].set_position(pos0); + mesh->vertices[1].set_position(pos1); + mesh->vertices[2].set_position(pos2); + mesh->vertices[3].set_position(pos3); + mesh->indices[0] = 0; + mesh->indices[1] = 1; + mesh->indices[2] = 3; + mesh->indices[3] = 2; + break; + case DrawMode::DRAW_LINES: + mesh = MeshFactory::create_mesh(4, 8); + mesh->vertices[0].set_position(pos0); + mesh->vertices[1].set_position(pos1); + mesh->vertices[2].set_position(pos2); + mesh->vertices[3].set_position(pos3); + mesh->indices[0] = 0; + mesh->indices[1] = 1; + mesh->indices[2] = 1; + mesh->indices[3] = 3; + mesh->indices[4] = 3; + mesh->indices[5] = 2; + mesh->indices[6] = 2; + mesh->indices[7] = 0; + break; + case DrawMode::DRAW_TRIANGLE_STRIP: + case DrawMode::DRAW_TRIANGLE_FAN: + mesh = MeshFactory::create_mesh(4, 4); + mesh->vertices[0].set_position(pos0); + mesh->vertices[1].set_position(pos1); + mesh->vertices[2].set_position(pos2); + mesh->vertices[3].set_position(pos3); + mesh->indices[0] = 0; + mesh->indices[1] = 1; + mesh->indices[2] = 3; + mesh->indices[3] = 2; + break; + case DrawMode::DRAW_TRIANGLES: + mesh = MeshFactory::create_mesh(4, 6); + mesh->vertices[0].set_position(pos0); + mesh->vertices[1].set_position(pos1); + mesh->vertices[2].set_position(pos2); + mesh->vertices[3].set_position(pos3); + mesh->indices[0] = 0; + mesh->indices[1] = 1; + mesh->indices[2] = 3; + mesh->indices[3] = 3; + mesh->indices[4] = 1; + mesh->indices[5] = 2; + break; + case DrawMode::DRAW_LINE_STRIP_ADJACENCY: + case DrawMode::DRAW_LINES_ADJACENCY: + case DrawMode::DRAW_TRIANGLE_STRIP_ADJACENCY: + case DrawMode::DRAW_TRIANGLES_ADJACENCY: + case DrawMode::DRAW_PATCHES: + default: + throw EXCEPTION("Unable to gen_plane_p for current draw mode: " + std::string(draw_mode)); + } + + return mesh; + } + template Mesh* gen_cube_p(const DrawMode& draw_mode, float width, float height, float depth) { diff --git a/OpenGLEngine/OpenGLEngine.vcxproj.filters b/OpenGLEngine/OpenGLEngine.vcxproj.filters index ab29a17..7e969a6 100644 --- a/OpenGLEngine/OpenGLEngine.vcxproj.filters +++ b/OpenGLEngine/OpenGLEngine.vcxproj.filters @@ -25,18 +25,6 @@ {c38724ea-6e5b-4561-bb97-74da2a031319} - - {51327f54-6f84-477f-8db8-883b91ebc5c2} - - - {2d1806dc-3a5d-4237-b7e3-4fe6d6576dc2} - - - {e8ae51e5-5508-47c6-804c-6d13408b8d13} - - - {1bb31cb4-7b36-47b6-b9ee-3d5de57f8f0c} - {3f9911e0-108f-4258-99c4-3f56e80ac27e} @@ -58,61 +46,85 @@ {233b4bce-fc64-4ad1-994e-c986befa7ff2} - - {ca004137-6425-4863-b91a-cf32988855be} + + {c67a5bf1-f6fb-4148-904d-9f96a3c34c88} - - {f3f94b58-31cf-4a57-bc2a-0c3a33a6b9ee} + + {51327f54-6f84-477f-8db8-883b91ebc5c2} - - {fa76cc6e-e866-4987-8263-85abac1ac2c6} + + {2d1806dc-3a5d-4237-b7e3-4fe6d6576dc2} - - {2e0e6381-fca9-42aa-87a9-04495a753104} + + {5c0adf5c-83f0-46f0-89c8-83cdf8f0090d} - - {283b2135-b031-48f0-b3cc-564a864e13bd} + + {1bb31cb4-7b36-47b6-b9ee-3d5de57f8f0c} - - {a67acfda-71a8-46cf-8207-bfdece4228ac} + + {e8ae51e5-5508-47c6-804c-6d13408b8d13} - - {4c6497d4-160a-45a1-a23b-7bf905de0824} + + {9cd2885f-9d3b-439c-b206-e3d53f6d7191} - + + {b3bc2383-d099-4fac-a51c-d2d4a8e7dea3} + + {2f2c0657-4ba3-4314-86dd-a600f533f746} - + + {f3f94b58-31cf-4a57-bc2a-0c3a33a6b9ee} + + + {fa76cc6e-e866-4987-8263-85abac1ac2c6} + + + {2e0e6381-fca9-42aa-87a9-04495a753104} + + + {a9e42739-f380-4358-83e5-f994cab7e55c} + + + {f9faae2c-4381-4a2e-a0be-27920a52dc4d} + + + {a67acfda-71a8-46cf-8207-bfdece4228ac} + + + {283b2135-b031-48f0-b3cc-564a864e13bd} + + {ca87b30d-8b69-4c09-90a5-1fe317322c4c} + + {4c6497d4-160a-45a1-a23b-7bf905de0824} + + + {ca004137-6425-4863-b91a-cf32988855be} + Source Files\Example - - Source Files\Engine - - - Source Files\Engine - - Source Files\Engine\Application + Source Files\Engine\Baseline\Application - Source Files\Engine\Application + Source Files\Engine\Baseline\Application - Source Files\Engine\Application + Source Files\Engine\Baseline\Application - Source Files\Engine\Application + Source Files\Engine\Baseline\Application - Source Files\Engine\Rendering + Source Files\Engine\Baseline\Rendering - Source Files\Engine\Rendering + Source Files\Engine\Baseline\Rendering Source Files\Example\Rendering @@ -121,13 +133,10 @@ Source Files\Example\Application - Source Files\Engine\Rendering + Source Files\Engine\Baseline\Rendering - Source Files\Engine\Rendering - - - Source Files\Engine + Source Files\Engine\Baseline\Rendering Source Files\Example\Application @@ -141,91 +150,88 @@ Source Files\Example\Application - - Source Files\Engine\builtin - Source Files\Example\Application - - Source Files\Engine\builtin - Source Files\Example\Application - Source Files\Engine\Rendering + Source Files\Engine\Baseline\Rendering - Source Files\Engine\builtin\Basic + Source Files\Engine\builtin\Scenes\Basic - Source Files\Engine\builtin\Basic + Source Files\Engine\builtin\Scenes\Basic - Source Files\Engine\builtin\Lit + Source Files\Engine\builtin\Scenes\Lit - Source Files\Engine\builtin\Lit + Source Files\Engine\builtin\Scenes\Lit - Source Files\Engine\builtin\Textured + Source Files\Engine\builtin\Scenes\Textured - Source Files\Engine\builtin\Textured + Source Files\Engine\builtin\Scenes\Textured Source Files\Example\Application - - Source Files\Engine - - Source Files\Engine\builtin\LitShadowed + Source Files\Engine\builtin\Scenes\LitShadowed - Source Files\Engine\builtin\LitShadowed + Source Files\Engine\builtin\Scenes\LitShadowed Source Files\Example\Application + + Source Files\Engine\Baseline + + + Source Files\Engine\Baseline + + + Source Files\Engine\Baseline + + + Source Files\Engine\Baseline + + + Source Files\Engine\builtin\General + + + Source Files\Engine\builtin\General + - - Header Files\Engine - - - Header Files\Engine - - - Header Files\Engine - - - Header Files\Engine - - Header Files\Engine\Application + Header Files\Engine\Baseline\Application - Header Files\Engine\Application + Header Files\Engine\Baseline\Application - Header Files\Engine\Application + Header Files\Engine\Baseline\Application - Header Files\Engine\Application + Header Files\Engine\Baseline\Application - Header Files\Engine\Application + Header Files\Engine\Baseline\Application - Header Files\Engine\Rendering + Header Files\Engine\Baseline\Rendering - Header Files\Engine\Rendering + Header Files\Engine\Baseline\Rendering - Header Files\Engine\Rendering + Header Files\Engine\Baseline\Rendering Header Files\Example\Rendering @@ -234,16 +240,10 @@ Header Files\Example\Application - Header Files\Engine\Rendering + Header Files\Engine\Baseline\Rendering - Header Files\Engine\Rendering - - - Header Files\Engine - - - Header Files\Engine + Header Files\Engine\Baseline\Rendering Header Files\Example\Application @@ -263,125 +263,143 @@ Header Files\Example\Application - - Header Files\Engine - - - Header Files\Engine - - - Header Files\Engine - - - Header Files\Engine\builtin - - - Header Files\Engine\builtin - - Header Files\Engine\Rendering + Header Files\Engine\Baseline\Rendering Header Files\Example\Application - - Header Files\Engine\builtin - - - Header Files\Engine\builtin - - - Header Files\Engine\builtin - - - Header Files\Engine\builtin - - - Header Files\Engine\builtin - - - Header Files\Engine\builtin - - - Header Files\Engine\builtin - - - Header Files\Engine\builtin - Header Files\Example\Application - Header Files\Engine\builtin\Basic + Header Files\Engine\builtin\Scenes\Basic - Header Files\Engine\builtin\Basic + Header Files\Engine\builtin\Scenes\Basic - Header Files\Engine\builtin\Basic + Header Files\Engine\builtin\Scenes\Basic - Header Files\Engine\builtin\Lit + Header Files\Engine\builtin\Scenes\Lit - Header Files\Engine\builtin\Lit + Header Files\Engine\builtin\Scenes\Lit - Header Files\Engine\builtin\Lit + Header Files\Engine\builtin\Scenes\Lit - Header Files\Engine\builtin\Textured + Header Files\Engine\builtin\Scenes\Textured - Header Files\Engine\builtin\Textured + Header Files\Engine\builtin\Scenes\Textured - Header Files\Engine\builtin\Textured + Header Files\Engine\builtin\Scenes\Textured Header Files\Example\Application - Header Files\Engine\Rendering - - - Header Files\Engine - - - Header Files\Engine - - - Header Files\Engine - - - Header Files\Engine - - - Header Files\Engine\builtin + Header Files\Engine\Baseline\Rendering - Header Files\Engine\builtin\LitShadowed + Header Files\Engine\builtin\Scenes\LitShadowed - Header Files\Engine\builtin\LitShadowed + Header Files\Engine\builtin\Scenes\LitShadowed - Header Files\Engine\builtin\LitShadowed + Header Files\Engine\builtin\Scenes\LitShadowed Header Files\Example\Application - Header Files\Engine\builtin\Basic + Header Files\Engine\builtin\Scenes\Basic - Header Files\Engine\builtin\Lit + Header Files\Engine\builtin\Scenes\Lit - Header Files\Engine\builtin\Textured + Header Files\Engine\builtin\Scenes\Textured - Header Files\Engine\builtin\LitShadowed + Header Files\Engine\builtin\Scenes\LitShadowed + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\Baseline + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General + + + Header Files\Engine\builtin\General @@ -398,28 +416,28 @@ Source Files\Example\Rendering\Shader Code - Source Files\Engine\builtin\Shaders + Source Files\Engine\builtin\Scenes\Shaders - Source Files\Engine\builtin\Shaders + Source Files\Engine\builtin\Scenes\Shaders - Source Files\Engine\builtin\Shaders + Source Files\Engine\builtin\Scenes\Shaders - Source Files\Engine\builtin\Shaders + Source Files\Engine\builtin\Scenes\Shaders - Source Files\Engine\builtin\Shaders + Source Files\Engine\builtin\Scenes\Shaders - Source Files\Engine\builtin\Shaders + Source Files\Engine\builtin\Scenes\Shaders - Source Files\Engine\builtin\Shaders + Source Files\Engine\builtin\Scenes\Shaders - Source Files\Engine\builtin\Shaders + Source Files\Engine\builtin\Scenes\Shaders \ No newline at end of file