diff --git a/cw 7/src/ex_7_1.hpp b/cw 7/src/ex_7_1.hpp index 52f73d9..906e727 100644 --- a/cw 7/src/ex_7_1.hpp +++ b/cw 7/src/ex_7_1.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "SOIL/SOIL.h" namespace texture { @@ -82,9 +83,13 @@ float aspectRatio = 1.f; unsigned int textureID; float tiltAngle=0; -//= glm::radians(0.0f); // Kąt przechylenia statku + +double easeInExpo(double x) { + return pow(2, 10 * x - 10); +} + glm::mat4 createCameraMatrix() { glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir,glm::vec3(0.f,1.f,0.f))); @@ -240,9 +245,8 @@ void renderScene(GLFWwindow* window) }); - drawObjectTexture(shipContext, - glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::rotate(glm::mat4(), tiltAngle * glm::radians(30.f), glm::vec3(0, 0, 1)) * glm::scale(glm::vec3(0.1f)), + glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::rotate(glm::mat4(), tiltAngle * glm::radians(30.0f), glm::vec3(0, 0, 1)) * glm::scale(glm::vec3(0.1f)), texture::ship, texture::shipNormal ); //drawObjectTexture(shipContext, @@ -413,6 +417,8 @@ void mouseCallback(GLFWwindow* window, double xpos, double ypos) { spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));*/ } + + //obsluga wejscia void processInput(GLFWwindow* window) { @@ -421,7 +427,7 @@ void processInput(GLFWwindow* window) float angleSpeed = 0.005f; float moveSpeed = 0.005f; - + double x = 0.002; glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); @@ -442,11 +448,22 @@ void processInput(GLFWwindow* window) spaceshipPos -= spaceshipUp * moveSpeed; if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) { spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0)); - tiltAngle -= 0.05; + tiltAngle -= easeInExpo(x); + } else { + if (tiltAngle < 0) { + tiltAngle += 0.0005; + } + + } if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) { spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0)); - tiltAngle += 0.05; + tiltAngle += easeInExpo(-x); + } else { + if (tiltAngle > 0) { + tiltAngle -= 0.0005; + } + } if (glfwGetKey(window, GLFW_KEY_G) == GLFW_PRESS) START_AS = true; @@ -457,6 +474,9 @@ void processInput(GLFWwindow* window) cameraDir = spaceshipDir; tiltAngle = fmaxf(-1, fminf(1, tiltAngle)); + + // dodać else, że jak klawisz A/D nie wciśnięty to się prostuje + //niech ta funkcja easinexpo zadziała pls