diff --git a/src/main.c b/src/main.c index df88cae..32901ce 100644 --- a/src/main.c +++ b/src/main.c @@ -56,6 +56,8 @@ GLfloat step = 0.0f; const GLfloat pi = 3.14159f; vec3 cameraPosition = {0.0f, 3.0f, 5.5f}; +vec3 objectPosition = {0.0f, 0.0f, 0.0f}; +GLfloat radius = 1.0f; int numModels = 4; char* models[] = { @@ -85,6 +87,25 @@ void handleInputs(double deltaTime) { if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) { cameraPosition.y -= deltaTime * 10; } + + if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) { + objectPosition.x += deltaTime * 10; + } + if (glfwGetKey(window, GLFW_KEY_J) == GLFW_PRESS) { + objectPosition.x -= deltaTime * 10; + } + if (glfwGetKey(window, GLFW_KEY_I) == GLFW_PRESS) { + objectPosition.z += deltaTime * 10; + } + if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS) { + objectPosition.z -= deltaTime * 10; + } + if (glfwGetKey(window, GLFW_KEY_R) == GLFW_PRESS) { + radius += deltaTime * 10; + } + if (glfwGetKey(window, GLFW_KEY_F) == GLFW_PRESS) { + radius -= deltaTime * 10; + } } // input handler to quit with ESC @@ -147,7 +168,6 @@ void init(void) { vertexTextConst = NULL; // create and compile fragment shader - const GLchar *fragmentTextConst = fragmentShader_glsl; GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); @@ -312,7 +332,11 @@ void draw(void) { rotateX(&modelTransformation, &modelTransformation, stepi); } else if (i == 3) { // Example transformations for the fourth object - vec3 v = {1.0f, 0.0f, 0.0f}; + vec3 v = { + objectPosition.x + cos(stepi) * 1.0f, + objectPosition.y + sin(stepi) * 1.0f, + objectPosition.z + }; translate(&modelTransformation, &modelTransformation, &v); }