主题:OPENGL球体自转公转问题(牛仔进)
好久没来,知道牛仔对OPENGL有研究,现在正在学,遇到个问题特来请教,欢迎会的朋友也回答下!
glPushMatrix();
glRotatef((GLfloat)year,0.0,1.0,0.0);
glTranslatef(3.0,0.0,0.0);
glRotatef((GLfloat)day,0.0,1.0,0.0);
glColor3f(0.0,1.0,0.0);
glutWireSphere(0.3,10,8);
glPushMatrix();
glRotatef((GLfloat)year,0.0,1.0,0.0);
glTranslatef(1.0,0.0,0.0);
glRotatef((GLfloat)day,0.0,1.0,0.0);
glColor3f(0.0,0.0,1.0);
glutWireSphere(0.1,10,8);
glPopMatrix();
glPopMatrix();
以上代码是一个行星和它里面一个卫星,现在我想把它改为
glPushMatrix();
glRotatef((GLfloat)year,0.0,1.0,0.0);
glTranslatef(3.0,0.0,0.0);
glRotatef((GLfloat)day,1.0,1.0,4.0);//这行修改的
glColor3f(0.0,1.0,0.0);
glutWireSphere(0.3,10,8);
glPushMatrix();
glRotatef((GLfloat)year,0.0,1.0,0.0);
glTranslatef(1.0,0.0,0.0);
glRotatef((GLfloat)day,0.0,1.0,0.0);
glColor3f(0.0,0.0,1.0);
glutWireSphere(0.1,10,8);
glPopMatrix();
glPopMatrix();
这样可以实现行星自转倾斜而不是绕y轴,而卫星又能绕着行星转吗?(前面还有个主星体没把代码给出来!)
glPushMatrix();
glRotatef((GLfloat)year,0.0,1.0,0.0);
glTranslatef(3.0,0.0,0.0);
glRotatef((GLfloat)day,0.0,1.0,0.0);
glColor3f(0.0,1.0,0.0);
glutWireSphere(0.3,10,8);
glPushMatrix();
glRotatef((GLfloat)year,0.0,1.0,0.0);
glTranslatef(1.0,0.0,0.0);
glRotatef((GLfloat)day,0.0,1.0,0.0);
glColor3f(0.0,0.0,1.0);
glutWireSphere(0.1,10,8);
glPopMatrix();
glPopMatrix();
以上代码是一个行星和它里面一个卫星,现在我想把它改为
glPushMatrix();
glRotatef((GLfloat)year,0.0,1.0,0.0);
glTranslatef(3.0,0.0,0.0);
glRotatef((GLfloat)day,1.0,1.0,4.0);//这行修改的
glColor3f(0.0,1.0,0.0);
glutWireSphere(0.3,10,8);
glPushMatrix();
glRotatef((GLfloat)year,0.0,1.0,0.0);
glTranslatef(1.0,0.0,0.0);
glRotatef((GLfloat)day,0.0,1.0,0.0);
glColor3f(0.0,0.0,1.0);
glutWireSphere(0.1,10,8);
glPopMatrix();
glPopMatrix();
这样可以实现行星自转倾斜而不是绕y轴,而卫星又能绕着行星转吗?(前面还有个主星体没把代码给出来!)