Suppose I have a sphere and a plane drawn in XY and I can move the ball. I want to know if it hits the plane. My thought is:
-Get the sphere position (center)
-Compare the (sphere position (Z coordinate) + radius) with the coordinate Z = 0
if true, means that de sphere hit the plane.
But how get the sphere position? I can use the transformation matrix? Like:
GLfloat matrix[4][4];
glGetFloatv(GL_MODELVIEW_MATRIX, &matrix[0][0]);
The code to draw the sphere is:
glPushMatrix();
glTranslatef(1.0, altura_braco, 0.0);
glScalef(1.0, 1.0, 1.0);
glColor3f(0.0f, 1.0f, 1.0f);
glutSolidSphere(0.2, 100.0, 100.0);
glPopMatrix();