小编Ela*_*ine的帖子

太阳系的问题

所以,这是我的问题.我应该制造一个太阳系,太阳位于中心,行星围绕着旋转; 每个星球都应该有自己的卫星.

所以,我做到了这一切,但我无法让地球自行旋转......地球围绕太阳旋转,月球围绕地球旋转......我怎样才能让地球自行旋转?当我在代码中放入另一个"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 …
Run Code Online (Sandbox Code Playgroud)

c++ opengl

4
推荐指数
1
解决办法
1643
查看次数

标签 统计

c++ ×1

opengl ×1