Iphone 使用纹理iOS旋转球体
我知道这是一个非常基本的问题,但我找不到我想要的答案。基本上,我必须显示一个旋转的三维球体上的相机覆盖。我已经得到了一切,除了将纹理应用到球体上。这是我生成三角形条带的代码Iphone 使用纹理iOS旋转球体,iphone,ios,opengl-es,Iphone,Ios,Opengl Es,我知道这是一个非常基本的问题,但我找不到我想要的答案。基本上,我必须显示一个旋转的三维球体上的相机覆盖。我已经得到了一切,除了将纹理应用到球体上。这是我生成三角形条带的代码 int createSphere (GLfloat spherePoints[], GLfloat fRadius, GLfloat step){ int points = 0; GLfloat uStep = DEGREES_TO_RADIANS (step); GLfloat vStep
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;
}
int-createSphere(GLfloat-spherePoints[],GLfloat-fRadius,GLfloat-step){
积分=0;
GLP=度到弧度(步长);
GLfloat vStep=uStep;
为了(GLfloat u=0.0f;u什么是纹理?具体来说,您希望它使用什么投影?发布OpenGL代码:在哪里创建纹理、绑定纹理并渲染场景。此代码对于这个问题没有用处。@tc纹理是尺寸为.512*1024的球体。@Max上面的代码为我正确绘制了一个有线球体。此代码生成对于顶点,如何编辑相同的代码以生成法线和纹理坐标?