You can get the current matrix for each object:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(x,y,z);
glRotate(r,1,0,0);
glTranslate(-x,-y,-z);
for (i=0 to 20) objects
glpushMatrix();
... some matrix transformations specific for the object
... and get the final matrix and store it to object member
glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&object->modelMatrix);
draw_object()
glpopMatrix();
When crossing rays, simply multiply the matrix of the object with the coordinate of the local center point to get it in the absolute space where the ray is defined.
source
share