Original Post
Hi, I've spent the past few days googling and reading books, getting ready to include bounding box collision into my engine, and I'm having trouble understanding some of the details. Here's what I *think* the course of action should be: 1) Find the min and max vertex positions of all models [DONE] 2) Calculate the 8 vertices of the box corners [DONE] 3) Before detection, transform the vertices of the box into world-space coordinates The 3rd step is where I'm troubled. Say I translate and rotate my object using OpenGL's glTranslatef and glRotatef, how would I calculate the new world-space coordinates for the bounding box? The vertices in the vertex array would still be the same. I found a DirectX tutorial containing the following:
Quote:What steps are the equivalent of calling D3DXVec3TransformCoord(), in OpenGL?
When we need to check for collisions we transform the 8 corners of the bounding box by the world matrix. In Direct3D we can use the D3DXVec3TransformCoord(...) function e.g. // Transform the 8 corners of our object space bounding box into world space D3DXVECTOR3 worldBounds[8]; for( int i = 0; i < 8; i++ ) D3DXVec3TransformCoord( &worldBounds, &m_objectBounds, &matWorld );
