I thought I had this figured out, but apparently I was mistaken. I'm failing to understand a small but crucial step here.

Anyhow, in order to implement collision detection, I need to know the coordinates in world space of the objects. Previously, I would simply track their position by how much they've been rotated and translated. But, since implementing rotation by quaternions, I seem to have lost the ability to do that (or, more likely, I simply just don't know how). I'm rotating and translating the Model Matrix by a translation matrix and rotation matrix.

a simple example:

ModelMatrix = TranslationMatrix * RotationMatrix * ModelMatrix;

where the translation and rotation matrices are created by

TranslationMatrix = glm::translate(movement); RotationMatrix = glm::mat4_cast(quaternion);

, respectively.

Right now, I'm trying to retrieve the world coordinates by just using the ModelMatrix[3][0],ModelMatrix[3][1], and ModelMatrix[3][2] values. However, I quickly found that this is insufficient as the values slowly become offset (they're roughly correct at first, but as I rotate and move things around, the values constantly increase by small increments over time). I would guess this is because of the way I'm creating the ModelMatrix by multiplying it by itself, but I'm unsure. For example, if I take the distance between the model position(as defined above) and "camera" and output it to the console, if I just spin in place without translating, the output distance very slowly grows. Nothing moves in-game(well, it spins, but ). Again, I would guess this is because it's multiplying the previous rotation by the new one, but I've yet to be able to pin this down.

Most advice I've found online suggests to simply track the position separately. If this is the case, I suppose my question would be how would I go about keeping track of the coordinates after rotating and translating them (I understand how to do this with simple trigonometry rotations and translations, but I don't know quite how to do so using quaternions). I realize it ought to be relatively simple, since I've told openGL where to put the object:P However, I'm finding it rather difficult with the matrix multiplication and quaternion involved (essentially, in my limited knowledge, I'm waving my hand at openGL and saying "put it over there somewhere." It works to put it there, but I'm failing to retrieve where exactly "there" is.)

Otherwise, is there a better way to retrieve the world coordinates of an object? Are the first three values of the bottom column of the matrix sufficient, but I'm somehow messing up their values by multiplying it by itself?

Anyway, thanks in advance for any help. Please let me know if you need more of the code, I genuinely appreciate any assistance .

**Edited by Misantes, 19 June 2014 - 09:10 PM.**