我知道它非常基本的问题,但我找不到我正在寻找的答案。基本上我必须在相机叠加层上显示一个旋转的 3D 球体。除了在那个球体上应用纹理之外,我什么都有。这是我生成三角形条的代码。
int createSphere (GLfloat spherePoints[], GLfloat fRadius, GLfloat step){
int points = 0;
GLfloat uStep = DEGREES_TO_RADIANS (step);
GLfloat vStep = uStep;
for (GLfloat u = 0.0f; u <= (2 * M_PI); u += uStep) {
for (GLfloat v = -M_PI_2; v <= M_PI_2; v += vStep) {
points++;
spherePoints[(points - 1) * 3] = fRadius * cosf(v) * cosf(u); // x
spherePoints[((points - 1) * 3) + 1] = fRadius * cosf(v) * sinf(u); // y
spherePoints[((points - 1) * 3) + 2] = fRadius * sinf(v); // z
points++;
spherePoints[(points - 1) * 3] = fRadius * cosf(v) * cosf(u + uStep); // x
spherePoints[((points - 1) * 3) + 1] = fRadius * cosf(v) * sinf(u + uStep); // y
spherePoints[((points - 1) * 3) + 2] = fRadius * sinf(v); // z
points++;
spherePoints[(points - 1) * 3] = fRadius * cosf(v + vStep) * cosf(u); // x
spherePoints[((points - 1) * 3) + 1] = fRadius * cosf(v + vStep) * sinf(u); // y
spherePoints[((points - 1) * 3) + 2] = fRadius * sinf(v + vStep); // z
points++;
spherePoints[(points - 1) * 3] = fRadius * cosf(v + vStep) * cosf(u + uStep); // x
spherePoints[((points - 1) * 3) + 1] = fRadius * cosf(v + vStep) * sinf(u + uStep); // y
spherePoints[((points - 1) * 3) + 2] = fRadius * sinf(v + vStep); // z
}
}
return points;
}
谁能解释如何生成纹理坐标和法线?