opengl

How to correctly rotate an OBB ?

How to correctly rotate an OBB ?

Hello everyone, I made, with OpenGL, a car simulator. For the car collision box, I used an OBB.The problem is when i wanna rotate the collision box. for this, I use this function : std::vector<glm::vec3> rotateCollisionBox(float angle, glm::vec3 boxMin, glm::vec3 boxMax) { std::vector<glm::vec3> rotatedVertices; glm::mat4 rotationMatrix = glm::rotate(glm::mat4(1.0f), glm::radians(angle), glm::vec3(0.0, 1.0, 0.0)); std::vector<glm::vec3> corners = { glm::vec3(boxMin.x, boxMin.y, boxMin.z), glm::vec3(boxMax.x, boxMin.y, boxMin.z), glm::vec3(boxMin.x, boxMax.y, boxMin.z), glm::vec3(boxMax.x, boxMax.y, boxMin.z), glm::vec3(boxMin.x, boxMin.y, boxMax.z), glm::vec3(boxMax.x, boxMin.y, boxMax.z), glm::vec3(boxMin.x, boxMax.y, boxMax.z), glm::vec3(boxMax.x, boxMax.y, boxMax.z) }; for (auto& vertex : corners) { glm::vec3 rotatedVertex = glm::vec3(rotationMatrix * glm::vec4(vertex, 1.0f)); rotatedVertices.push_back(rotatedVertex); } glm::vec3 xAxis = glm::normalize(glm::vec3(rotationMatrix[0]));…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.