Hi I'm creating a game using OpenGL and c++ for my final year project and I've got a quick question about using rays for collisions. I understand the theory behind it but I'm having an issue implementing it. I'm loading my models using Assimp and I'm trying to create a bounding box around the models so that I can check for a ray-box intersection, but when the transformations are applied during rendering, the box does not move with the model. I have created my own vertex and fragment shaders that draws the models. What approach is best for situation? Should I find a way to also move the bounding box, or is there another method to help with this? I considered using a frame buffer object from the point of view of the ray but I think this is overcomplicating things. I'm using rays as the game is a first person sniping game, and bullets would move too fast to find the box intersections.
To perform the ray-box intersection test, update the box and ray coordinates into same coordinate space (i.e. world space, or object's local space) for the test. This means that you update your box representation along with the transform of your object to avoid "the box does not move with the model" issue you described.
Trying to go the route of rendering the object into a frame buffer and doing per-pixel tests to check for intersection is a poor idea due to added latency and performance costs.
Hi I tried to implement the AABB bounding box, but when I apply the model's transformation matrix the values are incorrect. I think this is something to do with the rotation in th matrix. After debugging i found a lot of the values were low numbers. To apply the transformations I set each corner of the box and applied the transformation to each one, then circled between them to find the lowest value.