diff --git a/src/gamelogic.cpp b/src/gamelogic.cpp index bef19ac..1681440 100644 --- a/src/gamelogic.cpp +++ b/src/gamelogic.cpp @@ -99,8 +99,8 @@ void initGame(GLFWwindow* window, CommandLineOptions gameOptions) { shader->makeBasicShader("../res/shaders/simple.vert", "../res/shaders/simple.frag"); shader->activate(); - Mesh box = generateBox(boxDimensions.x, boxDimensions.y, boxDimensions.z, true); - Mesh pad = generateBox(padDimensions.x, padDimensions.y, padDimensions.z, false); + Mesh box = generateBox(boxDimensions.x, boxDimensions.y, boxDimensions.z, false); + Mesh pad = generateBox(padDimensions.x, padDimensions.y, padDimensions.z, true); Mesh sphere = generateSphere(1.0, 40, 40); unsigned int ballVAO = generateBuffer(sphere); diff --git a/src/utilities/shapes.cpp b/src/utilities/shapes.cpp index c82b338..079ae2b 100644 --- a/src/utilities/shapes.cpp +++ b/src/utilities/shapes.cpp @@ -4,64 +4,62 @@ Mesh generateBox(float width, float height, float depth, bool flipFaces) { // Hardcoded. Sue me. + // Edit: well, that backfired.. + std::vector vertices = { {0, 0, 0}, + {0, height, depth}, {0, 0, depth}, - {0, height, depth}, - - {0, 0, 0}, - {0, height, depth}, - {0, height, 0}, - - {width, 0, 0}, - {width, height, 0}, - {width, height, depth}, - - {width, 0, 0}, - {width, height, depth}, - {width, 0, depth}, - - {0, 0, 0}, - {width, height, 0}, - {width, 0, 0}, {0, 0, 0}, {0, height, 0}, + {0, height, depth}, + + {width, 0, 0}, + {width, height, depth}, {width, height, 0}, - {0, 0, depth}, + {width, 0, 0}, {width, 0, depth}, {width, height, depth}, - {0, 0, depth}, - {width, height, depth}, - {0, height, depth}, - {0, 0, 0}, {width, 0, 0}, + {width, height, 0}, + + {0, 0, 0}, + {width, height, 0}, + {0, height, 0}, + + {0, 0, depth}, + {width, height, depth}, {width, 0, depth}, + {0, 0, depth}, + {0, height, depth}, + {width, height, depth}, + {0, 0, 0}, {width, 0, depth}, + {width, 0, 0}, + + {0, 0, 0}, {0, 0, depth}, + {width, 0, depth}, {width, height, 0}, + {0, height, depth}, {0, height, 0}, - {0, height, depth}, {width, height, 0}, - {0, height, depth}, - {width, height, depth}}; + {width, height, depth}, + {0, height, depth}}; + + // These are technically inverted relative to the vertex coordinates. + // But for some strange reason the faces are rendered inverted. + // So to make the assignment work this is the best I can do. std::vector normals = { - {-1.0, 0.0, 0.0}, - {-1.0, 0.0, 0.0}, - {-1.0, 0.0, 0.0}, - - {-1.0, 0.0, 0.0}, - {-1.0, 0.0, 0.0}, - {-1.0, 0.0, 0.0}, - {1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, @@ -70,21 +68,21 @@ Mesh generateBox(float width, float height, float depth, bool flipFaces) { {1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, - {0.0, -1.0, 0.0}, - {0.0, -1.0, 0.0}, - {0.0, -1.0, 0.0}, + {-1.0, 0.0, 0.0}, + {-1.0, 0.0, 0.0}, + {-1.0, 0.0, 0.0}, - {0.0, -1.0, 0.0}, - {0.0, -1.0, 0.0}, - {0.0, -1.0, 0.0}, + {-1.0, 0.0, 0.0}, + {-1.0, 0.0, 0.0}, + {-1.0, 0.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.0, 1.0, 0.0}, + {0.0, 0.0, 1.0}, + {0.0, 0.0, 1.0}, + {0.0, 0.0, 1.0}, - {0.0, 1.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.0, 1.0, 0.0}, + {0.0, 0.0, 1.0}, + {0.0, 0.0, 1.0}, + {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 0.0, -1.0}, @@ -94,13 +92,21 @@ Mesh generateBox(float width, float height, float depth, bool flipFaces) { {0.0, 0.0, -1.0}, {0.0, 0.0, -1.0}, - {0.0, 0.0, 1.0}, - {0.0, 0.0, 1.0}, - {0.0, 0.0, 1.0}, + {0.0, 1.0, 0.0}, + {0.0, 1.0, 0.0}, + {0.0, 1.0, 0.0}, - {0.0, 0.0, 1.0}, - {0.0, 0.0, 1.0}, - {0.0, 0.0, 1.0}, + {0.0, 1.0, 0.0}, + {0.0, 1.0, 0.0}, + {0.0, 1.0, 0.0}, + + {0.0, -1.0, 0.0}, + {0.0, -1.0, 0.0}, + {0.0, -1.0, 0.0}, + + {0.0, -1.0, 0.0}, + {0.0, -1.0, 0.0}, + {0.0, -1.0, 0.0}, }; std::vector indices = {