Project

General

Profile

« Previous | Next » 

Revision 085d4e11

Added by Leszek Koltunski almost 6 years ago

Sphere: map the texture a bit better around the seam and the poles.

View differences:

src/main/java/org/distorted/library/mesh/MeshSphere.java
184 184
      }
185 185
    else                      // polar triangle
186 186
      {
187
      quotZ = (quotY==1.0 ? 0.0 : quotX / (1.0-quotY));
187
      quotZ = (quotY==1.0 ? 0.5 : quotX / (1.0-quotY));
188 188
      }
189 189

  
190 190
    double longitude = midLongitude(lonV1, lonV2, quotZ );
......
232 232
    // Solution: each such 'jump' triangle, if it is the last in a row, should have the texX of its
233 233
    // last (and maybe forelast as well) vertex remapped to 1.0.
234 234
    // If such triangle is not the last in its row, we need to add two extra vertices between it and
235
    // the next one, remap the old ones' texX to 1.0, and set the two new ones' texX to 0.0.
235
    // the next one, remap the old ones' texX to 1.0, and set one of the two new ones' texX to 0.0.
236 236
    ////////////////////////////////////////////////////////////////////////////////////////////////
237 237

  
238 238
    if( currentVert>=3 )
......
256 256
            }
257 257
          else
258 258
            {
259
            if( latitude> -A )  // top two triangles being corrected
259
            if( latitude> -A )  // one of the top two triangles being corrected
260 260
              {
261 261
              if (2*column+row-1 == level)  // last such triangle in a row; have to introduce extra 2 vertices.
262 262
                {
......
268 268
                repeatVertex(attribs, 2);
269 269
                repeatVertex(attribs, 2);
270 270

  
271
                attribs[VERT_ATTRIBS*(currentVert-1) + TEX_ATTRIB] = 0.0f;
272 271
                attribs[VERT_ATTRIBS*(currentVert-2) + TEX_ATTRIB] = 0.0f;
273 272
                attribs[VERT_ATTRIBS*(currentVert-3) + TEX_ATTRIB] = 1.0f;
274 273

  

Also available in: Unified diff