试图制作一个球体。但它看起来不像 3D,实际上它看起来像一个平面的 2D 图片。我在这里想念什么?
谢谢
std::vector<GLfloat> ballVerts;
for(int i = 0; i <= 40; i++)
{
double lat0 = M_PI * (-0.5 + (double) (i - 1) / 40);
double z0 = sin(lat0);
double zr0 = cos(lat0);
double lat1 = M_PI * (-0.5 + (double) i / 40);
double z1 = sin(lat1);
double zr1 = cos(lat1);
for(int j = 0; j <= 40; j++)
{
double lng = 2 * M_PI * (double) (j - 1) / 40;
double x = cos(lng);
double y = sin(lng);
// normals
glNormal3f(x * zr0, y * zr0, z0);
ballVerts.push_back(x * zr0); //X
ballVerts.push_back(y * zr0); //Y
ballVerts.push_back(z0); //Z
ballVerts.push_back(0.0f);
ballVerts.push_back(1.0f);
ballVerts.push_back(0.0f);
ballVerts.push_back(1.0f); //R,G,B,A
// normals
glNormal3f(x * zr1, y * zr1, z1);
ballVerts.push_back(x * zr1); //X
ballVerts.push_back(y * zr1); //Y
ballVerts.push_back(z1); //Z
ballVerts.push_back(0.0f);
ballVerts.push_back(1.0f);
ballVerts.push_back(0.0f);
ballVerts.push_back(1.0f); //R,G,B,A
// 渲染代码此外,我正在旋转这个圆圈,旋转效果很好,因为我有光线变化,它给了我一个想法,它正在旋转并且实际上至少是一个圆圈
glRotatef(Angle, 1.0f, 0.5f, 0.3f);
glBindBuffer(GL_ARRAY_BUFFER, VertexBufferObject[2]);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 7*4, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3200);
glBindBuffer(GL_ARRAY_BUFFER, 0);