From 9fcf4ad62c8af545debfe797b67ee6e87a8ff566 Mon Sep 17 00:00:00 2001 From: Matraf Date: Thu, 20 Jan 2022 14:01:40 +0100 Subject: [PATCH] fixed shark --- grafika_projekt/src/main.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/grafika_projekt/src/main.cpp b/grafika_projekt/src/main.cpp index b649efc..eff2de1 100644 --- a/grafika_projekt/src/main.cpp +++ b/grafika_projekt/src/main.cpp @@ -349,6 +349,32 @@ glm::mat4 createCameraMatrix() return Core::createViewMatrixQuat(cameraPos, rotation); } +/* +glm::mat4 createCameraMatrix() +{ + glm::quat quatX = glm::angleAxis(differenceY * 0.01f, glm::vec3(1.0, 0.0, 0.0)); + glm::quat quatY = glm::angleAxis(differenceX * 0.01f, glm::vec3(0.0, 1.0, 0.0)); + + auto rotX = glm::normalize(quatX); + auto rotY = glm::normalize(quatY); + + rotationX = glm::normalize(rotX * rotationX); + rotationY = glm::normalize(rotY * rotationY); + + rotation = glm::normalize(rotationX * rotationY); + + cameraDir = inverse(rotation) * glm::vec3(0, 0, -1); + cameraSide = inverse(rotation) * glm::vec3(1, 0, 0); + + differenceY = 0.0f; + differenceX = 0.0f; + + cameraPos = glm::vec3(spherePos.x, spherePos.y, spherePos.z) + glm::mat3_cast(inverse(rotation)) * glm::vec3(0, 2, 7); + + return Core::createViewMatrixQuat(cameraPos, rotation); +} +*/ + std::vector changeKeyPoints(std::vector keyPoints, glm::vec3 toChange) { std::vector result; int size = keyPoints.size(); @@ -465,10 +491,16 @@ void renderScene() drawObjectTexture(fishContext, animationMatrix(time + 15, change3, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture); drawObjectTexture(fishContext, animationMatrix(time + 15, change4, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture); drawObjectTexture(fangtoothContext, animationMatrix(time + 15, change1, fishKeyPointsSecond, fishKeyRotationSecond, glm::vec3(0.25f), 1.f), textureFangtooth, programTexture); - drawObjectTexture(sharkContext, animationMatrix(time + 15, change1, sharkKeyPoints, sharkKeyRotation, glm::vec3(10.8f), 1.f), textureShark, programTexture); time -= 5; } } + + if (time > -10) { + drawObjectTexture(sharkContext, animationMatrix(time + 15, change1, sharkKeyPoints, sharkKeyRotation, glm::vec3(10.8f), 1.f), textureShark, programTexture); + time -= 5; + } + + //for (int i = 0; i < 3; i++) { // if (time > -10) {