I have a rotating object, a cube, which I rotate in OpenGL as follows:
gl.glPushMatrix();
gl.glTranslatef(400.0f, 300.0f, 1300.0f);
gl.glRotatef(m_x, 4.0f, 0.0f, 0.0f);
gl.glRotatef(m_y, 0.0f, 4.0f, 0.0f);
gl.glRotatef(m_z, 0.0f, 0.0f, 42.0f);
gl.glCallList(++shapeNumber); // cube 2
gl.glPopMatrix();
(m_x
, m_y
, and m_z
are the change in the rotation each frame.)
I want to detect a collision between the camera and that rotating object, and to do that I need to get the coordinates of the rotated object in real time. How can I accomplish that?