Thursday, October 23, 2008

Collision detection continued

I've been working on, or at least thinking about the collision detection problem for the past few days, at least while not distracted by the financial crisis. I'm an eternal optimist and have been buying stock regardless of the downturn, but it has not changed direction yet, and it makes me almost physically nauseus to watch my money disappear at an alarming pace from my etrade account. So I tend to log on to etrade and click refresh refresh refresh instead of working.

One slight problem I encountered with being able to even begin test for collisions is that I have just access to local coordinates, but I need world coordinates. Normally local -> world transformation is performed by OpenGL, but it is not possible to access the transformed coordinates because they only exist in the 3D accelerator chip for an instant. AFAIK I now have to ask OpenGL to give me the matrix (glGetFloatv), gather all vertex coordinates from meshes and then do the matrix multiplication myself. Currently I'm really confused about the order of components in the matrix given to me by OpenGL. Also I'm not sure what to do with the extra row and column that matrix has. I suspect it is about the "w component" which I have to somehow multiple or divide x, y, z with, but not sure exactly how.

Until I understand this, I suppose any attempt to code this will just result in a tangled mess.