How to match the texture on the sides of the icosahedron?

I have been developing a 3D game for a long time. I went through this and found that I didn’t know enough to actually make a game.

I'm currently trying to add texture to the icosahedron (in the “Look at the main drawing” section) that he used in the tutorial, but I can't get the texture on more than one side. The other sides are completely invisible without any logical reason (they showed up perfectly until I added the texture).

Here are my main questions:

  • How to make the texture display correctly without using millions of vertices and colors to simulate the results?

  • How to move an object based on a variable that I can set in other functions?

+3
source share
1 answer

Try to think of your icosahedron as a low poly sphere. I believe that the Lamarche icosahedron has a center at 0,0,0. Look at this tutorial, it is written for directX, but it explains the general principle of displaying the texture of the sphere http://www.mvps.org/directx/articles/spheremap.htm . I used it in my project and it works great. You move the 3D object using various transformation matrices. You should have something like this

glPushMatrix();
glTranslatef();
draw icosahedron;
glPopMatrix();

Here is my code snippet on how I made texCoords for a hemisphere form based on the tutorial mentioned above

    GLfloat *ellipsoidTexCrds;
Vector3D *ellipsoidNorms;

int numVerts = *numEllipsoidVerticesHandle;

ellipsoidTexCrds = calloc(numVerts * 2, sizeof(GLfloat));
ellipsoidNorms = *ellipsoidNormalsHandle;

for(int i = 0, j = 0; i < numVerts * 2; i+=2, j++)
{

    ellipsoidTexCrds[i] = asin(ellipsoidNorms[j].x)/M_PI + 0.5; 
    ellipsoidTexCrds[i+1] = asin(ellipsoidNorms[j].y)/M_PI + 0.5;
}

, , , . , , (0,0,0), . , .

, 3D- iPhone, Ogre3D, .

, :)

+3

All Articles