• Breaking News

    After Rotation, Wrong Location of Height being Displayed I am trying to make the height from the ballPosition.x and ballPosition.z accurate after a rotation. Right now, when checking the ballPosition's height after a rotation, it has the height values of the old location with the new rotation. It tries to rise above the incline in the wrong position. I have included four code snippets and a video to demonstrate. This is the update of ballPosition, it isn't taking into effect any rotation. //forward if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS) { cameraPos.z = cameraPos.z - gMoveBallForward; ballPosition.z = ballPosition.z - gMoveBallForward; } This causes rotation: if (glfwGetKey(window, GLFW_KEY_O) == GLFW_PRESS) { gkeypress = 2; } if (glfwGetKey(window, GLFW_KEY_P) == GLFW_PRESS) { gkeypress = 1; } This changes the camera and rotates the world. ViewMatrix = glm::lookAt(cameraPos, glm::vec3(0.0f, 0.0f, -82.0f), cameraUp); //p or o pressed - rotation if (gkeypress) { if (gkeypress == 1) { gchange = gchange + .1005f; } else { gchange = gchange - .1005f; } gkeypress = 0; } ModelMatrix = glm::rotate(ModelMatrix, glm::radians(gchange), glm::vec3(0.0f, 1.0f, 0.0f)); ModelMatrix = glm::translate(ModelMatrix, glm::vec3(-19.5f, 0.0f, -24.5f)); ProjectionMatrix = glm::perspective(glm::radians(30.f), (float)1366 / (float)768, .001f, 1000.0f); glm::mat4 MVP = ProjectionMatrix * ViewMatrix * ModelMatrix; This is faulty code, when there has been a rotate, it finds and displays the height of the ball at the wrong location. float heightvalue = getHeightOfTerrain(ballPosition.x, ballPosition.z); ModelMatrix1 = glm::translate(ModelMatrix1, glm::vec3(0.0f, heightvalue-.8f, (-13.0f))); Thank you for your help, Josheir 4_29_2019 10_56_41 PM.mp4 https://ift.tt/eA8V8J

    I am trying to make the height from the ballPosition.x and ballPosition.z accurate after a rotation. Right now, when checking the ballPosition's height after a rotation, it has the height values of the old location with the new rotation. It tries to rise above the incline in the wrong position. I have included four code snippets and a video to demonstrate. This is the update of ballPosition, it isn't taking into effect any rotation. //forward if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS) { cameraPos.z = cameraPos.z - gMoveBallForward; ballPosition.z = ballPosition.z - gMoveBallForward; } This causes rotation: if (glfwGetKey(window, GLFW_KEY_O) == GLFW_PRESS) { gkeypress = 2; } if (glfwGetKey(window, GLFW_KEY_P) == GLFW_PRESS) { gkeypress = 1; } This changes the camera and rotates the world. ViewMatrix = glm::lookAt(cameraPos, glm::vec3(0.0f, 0.0f, -82.0f), cameraUp); //p or o pressed - rotation if (gkeypress) { if (gkeypress == 1) { gchange = gchange + .1005f; } else { gchange = gchange - .1005f; } gkeypress = 0; } ModelMatrix = glm::rotate(ModelMatrix, glm::radians(gchange), glm::vec3(0.0f, 1.0f, 0.0f)); ModelMatrix = glm::translate(ModelMatrix, glm::vec3(-19.5f, 0.0f, -24.5f)); ProjectionMatrix = glm::perspective(glm::radians(30.f), (float)1366 / (float)768, .001f, 1000.0f); glm::mat4 MVP = ProjectionMatrix * ViewMatrix * ModelMatrix; This is faulty code, when there has been a rotate, it finds and displays the height of the ball at the wrong location. float heightvalue = getHeightOfTerrain(ballPosition.x, ballPosition.z); ModelMatrix1 = glm::translate(ModelMatrix1, glm::vec3(0.0f, heightvalue-.8f, (-13.0f))); Thank you for your help, Josheir 4_29_2019 10_56_41 PM.mp4

    from GameDev.net http://bit.ly/2WgylwH

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728