
opengl的一道编程题
这是一个螺旋线voidRenderScene(void){GLfloatx,y,z,angle;//Storeageforcoordinatesandangles//Cl...
这是一个螺旋线
void RenderScene(void)
{
GLfloat x,y,z,angle; // Storeage for coordinates and angles
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);
// Save matrix state and do the rotation
glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
// Call only once for all remaining points
glBegin(GL_LINE_STRIP);
z = -50.0f;
for(angle = 0.0f; angle <= (2.0f*3.1415f)*3.0f; angle += 0.1f)
{
x = 50.0f*cos(angle);
y = 50.0f*sin(angle);
// Specify the point and move the Z value up a little
glVertex3f(x, y, z);
z += 0.5f;
}
// Done drawing points
glEnd();
// Restore transformations
glPopMatrix();
// Flush drawing commands
glutSwapBuffers();
}
怎么改才能让螺旋线绕中心轴转呢,现在是x轴 展开
void RenderScene(void)
{
GLfloat x,y,z,angle; // Storeage for coordinates and angles
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);
// Save matrix state and do the rotation
glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
// Call only once for all remaining points
glBegin(GL_LINE_STRIP);
z = -50.0f;
for(angle = 0.0f; angle <= (2.0f*3.1415f)*3.0f; angle += 0.1f)
{
x = 50.0f*cos(angle);
y = 50.0f*sin(angle);
// Specify the point and move the Z value up a little
glVertex3f(x, y, z);
z += 0.5f;
}
// Done drawing points
glEnd();
// Restore transformations
glPopMatrix();
// Flush drawing commands
glutSwapBuffers();
}
怎么改才能让螺旋线绕中心轴转呢,现在是x轴 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询