Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sphere texture mapping - distortion strip problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Sword7   Members   -  Reputation: 114

Like
0Likes
Like

Posted 23 April 2013 - 08:39 PM

Hello folks,

 

I am writing a small program to display planet earth by using glDrawElements and vertex/indices array.

 

It normally displays planet earth but seam strip between alaska and russia land.  I think that it is a problem with texcoords or glDrawElements function call.  I tried different ways but it always display distrotion strip.  Does anyone know any working around to get rid of distrotion strip?

Look at my code below.

 

Thanks!

Sword7

 

    int    thetaExtent = extent;

    int    phiExtent   = extent/2;

    int    theta1      = theta0 + thetaExtent;

    int    phi1        = phi0 + phiExtent;

    double phiStep     = (PI) / phiExtent;

    double thetaStep   = (2 * PI) / thetaExtent;

 
    double *v = vertices;

    double *t = texCoords;
    for (int phi = phi0; phi <= phi1; phi += ri.step) {

        for (int theta = theta0; theta < theta1; theta += ri.step) {

            *v++ = sin(phi * phiStep) * cos(theta * thetaStep);

            *v++ = cos(phi * phiStep);

            *v++ = sin(phi * phiStep) * sin(theta * thetaStep);



            *t++ = 1 - (theta * (1.0 / thetaExtent));

            *t++ = phi * (1.0 / phiExtent);

        }

    }



    uint16 *i = indices;

    for (int p = 0; p < phiExtent; p++) {

        for (int t = 0; t < thetaExtent; t++) {

            *i++ = p * thetaExtent + t;

            *i++ = p * thetaExtent + (t+1);

            *i++ = (p+1) * thetaExtent + (t+1);

            *i++ = (p+1) * thetaExtent + t;

        }

    }

 
    glVertexPointer(3, GL_DOUBLE, 0, vertices);

    glNormalPointer(GL_DOUBLE, 0, vertices);

    glTexCoordPointer(2, GL_DOUBLE, 0, texCoords);



    glDrawElements(GL_QUADS, nIndices, GL_UNSIGNED_SHORT, indices);


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS