1

非常に基本的な質問は知っていますが、探している答えが見つかりませんでした。基本的に、カメラ オーバーレイに回転する 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; 
}

テクスチャ座標と法線を生成する方法を説明できる人はいますか?

4

0 に答える 0