1

I'm trying to UV a 2D texture on a globe. Here's a piece of code:

double 
    delta = 0.0, // angle of latitude
    theta = 0.0, // angle of longitude
    theta_interval = (2.0 * M_PI) / latitude, // angle of latitude
    delta_interval = M_PI / longitude, // angle of longitude
    u_lats = 0.0, 
    v_longs = 0.0,
    u_lats_interval = 1.0 / latitude,
    v_longs_interval = 1.0 / longitude;

for (int i = 0; i < longitude; ++i) {
    for (int j = 0; j < latitude; ++j) {
        double
            x0 = calc_x0(radius, x, theta, delta),
            y0 = calc_y0(radius, y, theta, delta),
            z0 = calc_z0(radius, z, theta, delta),
            u0 = u_lats,
            v0 = v_longs + v_longs_interval,

            x1 = calc_x1(radius, x, theta, delta, delta_interval),
            y1 = calc_y1(radius, y, theta, delta, delta_interval),
            z1 = calc_z1(radius, z, theta, delta, delta_interval),
            u1 = u_lats + u_lats_interval,
            v1 = v_longs + v_longs_interval,

            x2 = calc_x2(radius, x, theta, theta_interval, delta, delta_interval),
            y2 = calc_y2(radius, y, theta, delta, delta_interval),
            z2 = calc_z2(radius, z, theta, theta_interval, delta, delta_interval),
            u2 = u_lats + u_lats_interval,
            v2 = v_longs,

            x3 = calc_x3(radius, x, theta, theta_interval, delta),
            y3 = calc_y3(radius, y, theta, theta_interval, delta),
            z3 = calc_z3(radius, z, theta, theta_interval, delta),
            u3 = u_lats,
            v3 = v_longs;

            theta += theta_interval;
            u_lats += u_lats_interval;
        }
        v_longs += v_longs_interval;
        theta = 0.0;
        delta += delta_interval;

So the way I wanted to do it is to go through the first 'strap' on the texture and then move on to the next one but it doesn't look good. I'm starting to think that it might be something about the texture because if I render less sphere, for example only 3 iterations of latitude it looks different.

Here's some pictures:

Full globe:

Full globe

Same globe with only three interations of latitude:

Same globe with only three interations of latitude

Does anyone have any idea what I'm doing wrong?

Spektre
  • 49,595
  • 11
  • 110
  • 380
matzar
  • 287
  • 2
  • 19

0 Answers0