diff --git a/cw_8/grk-cw8.vcxproj b/cw_8/grk-cw8.vcxproj index e2577f6..3cea7e4 100644 --- a/cw_8/grk-cw8.vcxproj +++ b/cw_8/grk-cw8.vcxproj @@ -60,7 +60,7 @@ Application true Unicode - v143 + v142 Application diff --git a/cw_8/src/projekt.hpp b/cw_8/src/projekt.hpp index a53cfd2..20c2eab 100644 --- a/cw_8/src/projekt.hpp +++ b/cw_8/src/projekt.hpp @@ -119,21 +119,22 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint a void processInput(GLFWwindow* window) { + float cameraSpeed = 0.1f * deltaTime * 15; + if (engineIs == 2) + //cameraSpeed = cameraSpeed * 1.8;//1.5; + cameraSpeed = 0.1f * deltaTime * 15 * 1.8; + if (!glfwJoystickIsGamepad(GLFW_JOYSTICK_1)) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); - float cameraSpeed = 0.1f * deltaTime * 15; - //station glm::vec3(0.f, 0.4f, 4.f) - if (engineIs==1&&spaceshipPos.x > -0.7 && 0.3>spaceshipPos.x && spaceshipPos.z > 3.7 && 4.3>spaceshipPos.z) + if (engineIs==1&&spaceshipPos.x > -0.7 && 0.3>spaceshipPos.x && spaceshipPos.z > 3.7 && 4.3>spaceshipPos.z&& spaceshipPos.y > -0.7 && 0.3 > spaceshipPos.y) { if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) engineIs = 2; } - if (engineIs == 2) - cameraSpeed = cameraSpeed * 1.8;//1.5; if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) @@ -146,6 +147,12 @@ void processInput(GLFWwindow* window) spaceshipDir = glm::vec3(glm::eulerAngleY(-cameraSpeed) * glm::vec4(spaceshipDir, 0)); }else if (glfwGetGamepadState(GLFW_JOYSTICK_1, ¤tState)) { + //station glm::vec3(0.f, 0.4f, 4.f) + if (engineIs == 1 && spaceshipPos.x > -0.7 && 0.3 > spaceshipPos.x && spaceshipPos.z > 3.7 && 4.3 > spaceshipPos.z && spaceshipPos.y > 0.1 && 0.7 > spaceshipPos.y) + { + if (currentState.buttons[GLFW_GAMEPAD_BUTTON_A]==GLFW_PRESS) + engineIs = 2; + } if(currentState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER] > 0.01) spaceshipPos += deltaTime * 5 * spaceshipDir * currentState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER]; if (currentState.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER] > 0.01) @@ -278,12 +285,15 @@ void isTouching(glm::vec3 objectPos) { //spaceXYZ = glm::vec3(float x, float y, float z); float xpos = spaceshipPos.x; float zpos = spaceshipPos.z; + float ypos = spaceshipPos.y; float xup = objectPos.x+0.2; float xdown = objectPos.x-0.2; float zup = objectPos.z+0.2; float zdown = objectPos.z-0.2; + float yup = objectPos.y + 0.4; + float ydown = objectPos.y - 0.4; //6,0,0 - if (xup > xpos&&xpos > xdown && zup > zpos &&zpos > zdown) + if (xup >= xpos&&xpos >= xdown && zup >= zpos &&zpos >= zdown && ypos >= ydown && yup >= ypos) //if(xpos>6&&1>zpos&&zpos>-1) engineIs = 1; return; @@ -349,7 +359,7 @@ void renderScene(GLFWwindow* window) { drawObjectToInstall(stationContext, glm::translate(glm::vec3(0.f, 0.4f, 4.f)) * glm::scale(glm::vec3(0.052f)) * glm::eulerAngleXYZ(time / 2, time / 2, time / 2), texture::station_albedo, texture::station_normal, texture::station_ao, texture::station_roughness, texture::station_metallic); drawObjectToInstall(stationContext, glm::translate(glm::vec3(0.f, 0.4f, 4.f)) * glm::scale(glm::vec3(0.054f)) * glm::eulerAngleX(0.5f) * glm::eulerAngleXZ(time, time), texture::station_albedo, texture::station_normal, texture::station_ao, texture::station_roughness, texture::station_metallic); - if (spaceshipPos.x > -0.7 && 0.3 > spaceshipPos.x && spaceshipPos.z > 3.7 && 4.3 > spaceshipPos.z) + if (spaceshipPos.x > -0.7 && 0.3 > spaceshipPos.x && spaceshipPos.z > 3.7 && 4.3 > spaceshipPos.z && spaceshipPos.y > -0.7 && 0.3 > spaceshipPos.y) { drawObjectToInstall(shipContext, glm::translate(spaceshipPos)