所以,這是我的問題。我應該製造一個太陽系,太陽在中心,行星在旋轉;每個行星都應該有自己的衛星。所以,我做了所有,但我無法做到地球自轉......地球圍繞太陽旋轉,月球圍繞地球旋轉......我如何讓地球旋轉本身?當我把另一個「glrotating」命令裏面的代碼,月亮落下地球或發生一些奇怪的事情......我的太陽系問題
這裏如下我的代碼...
// EARTH
// INFO: 1) it's 3rd planet from the Sun;
// 2) it's 5th largest planet in the Solar System, with an equatorial radius of 6378.388km;
// 3) it's 3rd fastest planet, because its orbital period is of 365 earth-days (1 year).
void Earth(void)
{
DrawOrbit(5.5, 1);
glRotatef((GLfloat) year*6.2, 0.0, 1.0, 0.0); //orbital movement for the Earth around the Sun
glTranslatef(5.5, 0.0, 0.0);
glColor3f(0.0, 0.3, 1.0);
glutSolidSphere(0.28, 20, 10); //draw Earth: more or less, the Earth has got the same dimension of Venus.
// The Earth has got one natural satellites: the Moon. Let's draw it:
glPushMatrix();
glRotatef((GLfloat) day*2, 0.0, 1.0, 0.0); //rotate for the moon
glTranslatef(0.5, 0.0, 0.0);
glColor3f(1.0f, 1.0f, 1.0f);
glutSolidSphere(0.05, 5, 4); //draw moon: its diameter is about a quarter the diameter of Earth
glPopMatrix();
}
我假設你使用的是OpenGL? – 2011-05-28 13:10:39
這個問題的標題是偉大的。 xD – Cephron 2011-05-28 13:20:58
只要你不使用紋理,無論如何你都不會注意到旋轉地球的網格。當你開始使用紋理時,只需移動一個紋理座標,地球就會開始旋轉 – hirschhornsalz 2011-05-28 13:30:26