Project

General

Profile

« Previous | Next » 

Revision a4962b9c

Added by Leszek Koltunski over 3 years ago

Progress with any size Kilominx.

View differences:

src/main/java/org/distorted/objects/TwistyDiamond.java
389 389
        case 7: axis = 0; layer =             1; break;
390 390
        }
391 391

  
392
      return CUBITS[cubit].mRotationRow[axis] == layer ? cubitface : NUM_FACES;
392
      return CUBITS[cubit].mRotationRow[axis] == layer ? cubitface : NUM_TEXTURES;
393 393
      }
394 394
    else
395 395
      {
396
      return cubitface>0 ? NUM_FACES : retFaceTetraBelongsTo(cubit-numO, size);
396
      return cubitface>0 ? NUM_TEXTURES : retFaceTetraBelongsTo(cubit-numO, size);
397 397
      }
398 398
    }
399 399

  
src/main/java/org/distorted/objects/TwistyKilominx.java
216 216
      float vY = D*center[1] - y;
217 217
      float vZ = D*center[2] - z;
218 218

  
219
      float T = 0.5f + leftRight*(mult*D*SIN18 + 1.0f)/(numLayers-1);
219
      float T = 0.5f + leftRight*(mult*SIN18 + 1.0f)/(numLayers-1);
220

  
220 221
      x = D * (T*c1[0]+(1.0f-T)*c2[0]);
221 222
      y = D * (T*c1[1]+(1.0f-T)*c2[1]);
222 223
      z = D * (T*c1[2]+(1.0f-T)*c2[2]);
......
341 342
        {
342 343
        float tmp   = (numLayers/3.0f)/(numLayers-1);
343 344
        float height= tmp*COS18;
344
        float width = tmp + (type/2)*height*SIN18/COS18;
345
        float width = tmp + (type/2)*tmp*SIN18;
345 346

  
346 347
        mEdgeMeshes[indexCornerEdge][type] = FactoryCubit.getInstance().createKilominxEdgeMesh(numLayers,width,height, (type%2)==0 );
347 348
        }
......
369 370
    }
370 371

  
371 372
///////////////////////////////////////////////////////////////////////////////////////////////////
372
// TODO
373 373

  
374
  int getFaceColor(int cubit, int cubitface, int numLayers)
374
  int getCornerColor(int cubit, int cubitface, int numLayers, int numCubitsPerCorner)
375 375
    {
376
    if( numLayers==3 )
376
    if( cubitface<0 || cubitface>2 ) return NUM_TEXTURES;
377

  
378
    int part  = cubit % numCubitsPerCorner;
379
    int corner= cubit / numCubitsPerCorner;
380

  
381
    if( part==0 )
377 382
      {
378
      return cubitface>=0 && cubitface<3 ? mCornerFaceMap[cubit][cubitface] : NUM_TEXTURES*NUM_FACES;
383
      return mCornerFaceMap[corner][cubitface];
379 384
      }
385
    else
386
      {
387
      int N = (numCubitsPerCorner-1)/3;
388
      int block = (part-1) % N;
389
      int index = (part-1) / N;
380 390

  
381
    int numCubitsPerCorner = numCubitsPerCorner(numLayers);
382
    int numCubitsPerEdge   = numCubitsPerEdge(numLayers);
391
      if( block< (numLayers-3)/2 )
392
        {
393
        switch(index)
394
          {
395
          case 0: return cubitface==1 ? NUM_TEXTURES : mCornerFaceMap[corner][cubitface];
396
          case 1: return cubitface==0 ? NUM_TEXTURES : mCornerFaceMap[corner][cubitface];
397
          case 2: return cubitface==2 ? NUM_TEXTURES : mCornerFaceMap[corner][cubitface];
398
          }
399
        }
400
      else
401
        {
402
        switch(index)
403
          {
404
          case 0: return cubitface==0 ? mCornerFaceMap[corner][cubitface] : NUM_TEXTURES;
405
          case 1: return cubitface==2 ? mCornerFaceMap[corner][cubitface] : NUM_TEXTURES;
406
          case 2: return cubitface==1 ? mCornerFaceMap[corner][cubitface] : NUM_TEXTURES;
407
          }
408
        }
409
      }
410

  
411
    return NUM_TEXTURES;
412
    }
413

  
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415

  
416
  int getEdgeColor(int edge, int cubitface, int numCubitsPerEdge)
417
    {
418
    if( cubitface<0 || cubitface>1 ) return NUM_TEXTURES;
419

  
420
    int part    = edge % numCubitsPerEdge;
421
    int variant = edge / numCubitsPerEdge;
383 422

  
384
    cubit -= (NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge);
423
    part /=2;
385 424

  
386
    if( cubit >= 0 )
425
    return (part==0 || cubitface==((part+1)%2)) ? mEdgeMap[variant][cubitface+2] + ((part+3)/2)*NUM_FACES : NUM_TEXTURES;
426
    }
427

  
428
///////////////////////////////////////////////////////////////////////////////////////////////////
429

  
430
  int getCenterColor(int center, int cubitface, int numLayers)
431
    {
432
     if( numLayers==3 )
387 433
      {
388
      return cubit/5;
434
      return cubitface>=0 && cubitface<3 ? mCornerFaceMap[center][cubitface] : NUM_TEXTURES;
389 435
      }
390 436

  
391
    return 0;
437
    return center/5 + NUM_FACES*(numLayers-1)/2; // TODO
438
    }
439

  
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441

  
442
  int getFaceColor(int cubit, int cubitface, int numLayers)
443
    {
444
    int numCubitsPerCorner = numCubitsPerCorner(numLayers);
445
    int numCubitsPerEdge   = numCubitsPerEdge(numLayers);
446

  
447
    if( cubit < NUM_CORNERS*numCubitsPerCorner )
448
      {
449
      return getCornerColor(cubit,cubitface,numLayers,numCubitsPerCorner);
450
      }
451
    else if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
452
      {
453
      int edge = cubit - NUM_CORNERS*numCubitsPerCorner;
454
      return getEdgeColor(edge,cubitface,numCubitsPerEdge);
455
      }
456
    else
457
      {
458
      int center = cubit-NUM_CORNERS*numCubitsPerCorner-NUM_EDGES*numCubitsPerEdge;
459
      return getCenterColor( center, cubitface, numLayers);
460
      }
392 461
    }
393 462

  
394 463
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff