Hi all
I want to make the moon rotate the earth but instead it rotates around some point between the sun and the earth…and i dont get it…can someone help me?
Here’s my code:
void drawsphere(void)
{
GLUquadricObj *pObj;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
pObj = gluNewQuadric();
glPushMatrix();
glTranslatef(0.0f, 0.0f, -2.0f);
glColor3f(1.0f, 1.0f, 0.0f);
gluSphere(pObj, .15f, 40, 20);
glRotatef(alpha, 0.0f, 0.0f, 1.0f); glTranslatef(1.0f,0.0f,-2.0f);
glColor3f(0.0f,0.0f,1.0f); // Terra
gluSphere(pObj, 0.1f, 40,20);
glRotatef(fMoonRot, 0.0f, 0.0f, 1.0f);
glTranslatef(.5f , 0.0f, -2.0f);
fMoonRot+= 2.0f;
if(fMoonRot > 360.0f)
fMoonRot = 0.0f; glColor3ub(105,105,105);
gluSphere(pObj, 0.02f, 40,20);
glPopMatrix();
glutSwapBuffers();
}