Project

General

Profile

« Previous | Next » 

Revision 39cbf9dc

Added by Leszek Koltunski over 8 years ago

Minor: deal with IntelliJ warnings

View differences:

src/main/java/org/distorted/library/Distorted.java
36 36
 * A singleton class used to control various global settings.
37 37
 */
38 38
public class Distorted 
39
{
39
  {
40 40
  /**
41 41
   * When creating an instance of a DistortedObject from another instance, do not clone anything.
42 42
   * Used in the copy constructor.
......
496 496
    {
497 497
    return EffectQueue.setMax(EffectTypes.FRAGMENT.ordinal(),max);
498 498
    }
499

  
500
///////////////////////////////////////////////////////////////////////////////////////////////////
501
//end of file  
502
}
499
  }
src/main/java/org/distorted/library/DistortedBitmapGrid.java
111 111

  
112 112
    //for(int g=0; g<dataLength; g++) android.util.Log.e("BACKGROUND", "pos["+g+"]=("+bufferData[3*g]+","+bufferData[3*g+1]+")");
113 113
    }
114
  };
115

  
116
///////////////////////////////////////////////////////////////////////////////////////////////////
114
  }
src/main/java/org/distorted/library/DistortedCubesGrid.java
56 56
       row = r;
57 57
       col = c;
58 58
       }
59
     };
59
     }
60 60
   
61
   private int frontVert, sideVert;
62 61
   private int mCols, mRows;
63 62
   private short[][] mCubes;
64
   private ArrayList<Edge> mEdges = new ArrayList<Edge>();
63
   private ArrayList<Edge> mEdges = new ArrayList<>();
65 64
   
66 65
///////////////////////////////////////////////////////////////////////////////////////////////////
67 66

  
......
103 102
        while( curr.col!=startX || curr.row!=startY || curr.side!=startS );
104 103
        }
105 104
      
106
      frontVert = 2*( frontWalls + 2*frontSegments - 1);
107
      sideVert  = 2*( sideWalls + sideBends + edges -1);
105
      int frontVert = 2*( frontWalls + 2*frontSegments - 1);
106
      int sideVert  = 2*( sideWalls + sideBends + edges -1);
108 107
      
109 108
      int dataL = frontOnly ? frontVert : (frontVert+1) + (1+sideVert+1) + (1+frontVert);
110 109
      
......
178 177
         for(int i=reallen; i<len; i++) desc += "0";
179 178
         }
180 179
    
181
       if( desc.indexOf("1")>=0 )
180
       if( desc.contains("1") )
182 181
         {
183 182
         mCols = cols;
184 183
         mRows = len/cols;
......
386 385

  
387 386
             if( front ) // NW corner
388 387
               {
389
               position[3*vertex+0] = (centerX-0.5f)/mCols;
388
               position[3*vertex  ] = (centerX-0.5f)/mCols;
390 389
               position[3*vertex+1] = (centerY+0.5f)/mRows;
391 390
               position[3*vertex+2] = FRONTZ;
392
               normal[3*vertex+0]   = mNormalX[0];
391
               normal[3*vertex  ]   = mNormalX[0];
393 392
               normal[3*vertex+1]   = mNormalY[0];
394 393
               normal[3*vertex+2]   = 1.0f;
395
               texture[2*vertex+0]  = (float)j/mCols;
394
               texture[2*vertex  ]  = (float)j/mCols;
396 395
               texture[2*vertex+1]  = (float)i/mRows;     
397 396
               vertex++;
398 397
               }
399 398
             else  // SW corner
400 399
               { 
401
               position[3*vertex+0] = (centerX-0.5f)/mCols;
400
               position[3*vertex  ] = (centerX-0.5f)/mCols;
402 401
               position[3*vertex+1] = (centerY-0.5f)/mRows; 
403 402
               position[3*vertex+2] = BACKZ; 
404
               normal[3*vertex+0]   = mNormalX[1];
403
               normal[3*vertex  ]   = mNormalX[1];
405 404
               normal[3*vertex+1]   = mNormalY[1];
406 405
               normal[3*vertex+2]   =-1.0f;
407
               texture[2*vertex+0]  = (float)j/mCols;
406
               texture[2*vertex  ]  = (float)j/mCols;
408 407
               texture[2*vertex+1]  = (float)(i+1)/mRows;
409 408
               vertex++;
410 409
               
......
415 414

  
416 415
             if( front ) // SW corner
417 416
               {
418
               position[3*vertex+0] = (centerX-0.5f)/mCols;
417
               position[3*vertex  ] = (centerX-0.5f)/mCols;
419 418
               position[3*vertex+1] = (centerY-0.5f)/mRows; 
420 419
               position[3*vertex+2] = FRONTZ; 
421
               normal[3*vertex+0]   = mNormalX[1];
420
               normal[3*vertex  ]   = mNormalX[1];
422 421
               normal[3*vertex+1]   = mNormalY[1];
423 422
               normal[3*vertex+2]   = 1.0f;
424
               texture[2*vertex+0]  = (float)j/mCols;
423
               texture[2*vertex  ]  = (float)j/mCols;
425 424
               texture[2*vertex+1]  = (float)(i+1)/mRows;
426 425
               vertex++; 
427 426
               }
428 427
             else  // NW corner
429 428
               {
430
               position[3*vertex+0] = (centerX-0.5f)/mCols;
429
               position[3*vertex  ] = (centerX-0.5f)/mCols;
431 430
               position[3*vertex+1] = (centerY+0.5f)/mRows;
432 431
               position[3*vertex+2] = BACKZ;
433
               normal[3*vertex+0]   = mNormalX[0];
432
               normal[3*vertex  ]   = mNormalX[0];
434 433
               normal[3*vertex+1]   = mNormalY[0];
435 434
               normal[3*vertex+2]   =-1.0f;
436
               texture[2*vertex+0]  = (float)j/mCols;
435
               texture[2*vertex  ]  = (float)j/mCols;
437 436
               texture[2*vertex+1]  = (float)i/mRows;     
438 437
               vertex++; 
439 438
               }
......
441 440
              
442 441
           if( front )  // NE corner
443 442
             {
444
             position[3*vertex+0] = (centerX+0.5f)/mCols;
443
             position[3*vertex  ] = (centerX+0.5f)/mCols;
445 444
             position[3*vertex+1] = (centerY+0.5f)/mRows;
446 445
             position[3*vertex+2] = FRONTZ; 
447
             normal[3*vertex+0]   = mNormalX[2];
446
             normal[3*vertex  ]   = mNormalX[2];
448 447
             normal[3*vertex+1]   = mNormalY[2];
449 448
             normal[3*vertex+2]   = 1.0f;
450
             texture[2*vertex+0]  = (float)(j+1)/mCols;
449
             texture[2*vertex  ]  = (float)(j+1)/mCols;
451 450
             texture[2*vertex+1]  = (float)i/mRows;
452 451
             vertex++;
453 452
             }
454 453
           else // SE corner
455 454
             {
456
             position[3*vertex+0] = (centerX+0.5f)/mCols;
455
             position[3*vertex  ] = (centerX+0.5f)/mCols;
457 456
             position[3*vertex+1] = (centerY-0.5f)/mRows;
458 457
             position[3*vertex+2] = BACKZ; 
459
             normal[3*vertex+0]   = mNormalX[3];
458
             normal[3*vertex  ]   = mNormalX[3];
460 459
             normal[3*vertex+1]   = mNormalY[3];
461 460
             normal[3*vertex+2]   =-1.0f;
462
             texture[2*vertex+0]  = (float)(j+1)/mCols;
461
             texture[2*vertex  ]  = (float)(j+1)/mCols;
463 462
             texture[2*vertex+1]  = (float)(i+1)/mRows;
464 463
             vertex++; 
465 464
             }
466 465
           
467 466
           if( front )  // SE corner
468 467
             {
469
             position[3*vertex+0] = (centerX+0.5f)/mCols;
468
             position[3*vertex  ] = (centerX+0.5f)/mCols;
470 469
             position[3*vertex+1] = (centerY-0.5f)/mRows;
471 470
             position[3*vertex+2] = FRONTZ; 
472
             normal[3*vertex+0]   = mNormalX[3];
471
             normal[3*vertex  ]   = mNormalX[3];
473 472
             normal[3*vertex+1]   = mNormalY[3];
474 473
             normal[3*vertex+2]   = 1.0f;
475
             texture[2*vertex+0]  = (float)(j+1)/mCols;
474
             texture[2*vertex  ]  = (float)(j+1)/mCols;
476 475
             texture[2*vertex+1]  = (float)(i+1)/mRows;
477 476
             vertex++;
478 477
             }
479 478
           else // NE corner
480 479
             {
481
             position[3*vertex+0] = (centerX+0.5f)/mCols;
480
             position[3*vertex  ] = (centerX+0.5f)/mCols;
482 481
             position[3*vertex+1] = (centerY+0.5f)/mRows;
483 482
             position[3*vertex+2] = BACKZ; 
484
             normal[3*vertex+0]   = mNormalX[2];
483
             normal[3*vertex  ]   = mNormalX[2];
485 484
             normal[3*vertex+1]   = mNormalY[2];
486 485
             normal[3*vertex+2]   =-1.0f;
487
             texture[2*vertex+0]  = (float)(j+1)/mCols;
486
             texture[2*vertex  ]  = (float)(j+1)/mCols;
488 487
             texture[2*vertex+1]  = (float)i/mRows;
489 488
             vertex++; 
490 489
             }
......
505 504
     {
506 505
     if( vertex>0 )
507 506
       {
508
       position[3*vertex+0] = position[3*vertex-3]; 
507
       position[3*vertex  ] = position[3*vertex-3];
509 508
       position[3*vertex+1] = position[3*vertex-2];
510 509
       position[3*vertex+2] = position[3*vertex-1];
511 510

  
512
       normal[3*vertex+0]   = normal[3*vertex-3]; 
511
       normal[3*vertex  ]   = normal[3*vertex-3];
513 512
       normal[3*vertex+1]   = normal[3*vertex-2];
514 513
       normal[3*vertex+2]   = normal[3*vertex-1];
515 514

  
516
       texture[2*vertex+0]  = texture[2*vertex-2];
515
       texture[2*vertex  ]  = texture[2*vertex-2];
517 516
       texture[2*vertex+1]  = texture[2*vertex-1];
518 517
         
519 518
       vertex++;     
......
646 645
  
647 646
     switch(curr.side)
648 647
       {
649
       case NORTH: position[3*vertex+0] = (back ? (centerX-0.5f) : (centerX+0.5f))/mCols; 
648
       case NORTH: position[3*vertex  ] = (back ? (centerX-0.5f) : (centerX+0.5f))/mCols;
650 649
                   position[3*vertex+1] = (centerY+0.5f)/mRows;
651 650
                   position[3*vertex+2] = lower ? BACKZ : FRONTZ;
652 651

  
653
                   normal[3*vertex+0]   = side==NORTH ? 0.0f : (side==WEST?-R:R);
652
                   normal[3*vertex  ]   = side==NORTH ? 0.0f : (side==WEST?-R:R);
654 653
                   normal[3*vertex+1]   = 1.0f;
655 654
                   normal[3*vertex+2]   = lower ? -R:R;
656 655

  
657
                   texture[2*vertex+0]  = (float)(back ? (curr.col  ):(curr.col+1))/mCols;
656
                   texture[2*vertex  ]  = (float)(back ? (curr.col  ):(curr.col+1))/mCols;
658 657
                   texture[2*vertex+1]  = (float)(lower? (curr.row-1):(curr.row  ))/mRows;  
659 658
                   break;
660
       case SOUTH: position[3*vertex+0] = (back ? (centerX+0.5f) : (centerX-0.5f))/mCols;
659
       case SOUTH: position[3*vertex  ] = (back ? (centerX+0.5f) : (centerX-0.5f))/mCols;
661 660
                   position[3*vertex+1] = (centerY-0.5f)/mRows;
662 661
                   position[3*vertex+2] = lower ? BACKZ : FRONTZ;  
663 662
            
664
                   normal[3*vertex+0]   = side==SOUTH ? 0.0f: (side==EAST?-R:R);
663
                   normal[3*vertex  ]   = side==SOUTH ? 0.0f: (side==EAST?-R:R);
665 664
                   normal[3*vertex+1]   =-1.0f;
666 665
                   normal[3*vertex+2]   = lower ? -R:R;
667 666

  
668
                   texture[2*vertex+0]  = (float)(back ? (curr.col+1):(curr.col  ))/mCols;
667
                   texture[2*vertex  ]  = (float)(back ? (curr.col+1):(curr.col  ))/mCols;
669 668
                   texture[2*vertex+1]  = (float)(lower? (curr.row+2):(curr.row+1))/mRows;
670 669
                   break;
671
       case WEST : position[3*vertex+0] = (centerX-0.5f)/mCols;
670
       case WEST : position[3*vertex  ] = (centerX-0.5f)/mCols;
672 671
                   position[3*vertex+1] = (back ? (centerY-0.5f):(centerY+0.5f))/mRows;
673 672
                   position[3*vertex+2] = lower ? BACKZ : FRONTZ;
674 673

  
675
                   normal[3*vertex+0]   =-1.0f;
674
                   normal[3*vertex  ]   =-1.0f;
676 675
                   normal[3*vertex+1]   = side==WEST ? 0.0f : (side==NORTH?-R:R);
677 676
                   normal[3*vertex+2]   = lower ? -R:R;
678 677
 
679
                   texture[2*vertex+0]  = (float)(lower ? (curr.col-1):(curr.col  ))/mCols;
678
                   texture[2*vertex  ]  = (float)(lower ? (curr.col-1):(curr.col  ))/mCols;
680 679
                   texture[2*vertex+1]  = (float)(back  ? (curr.row+1):(curr.row  ))/mRows;
681 680
                   break;
682
       case EAST : position[3*vertex+0] = (centerX+0.5f)/mCols;
681
       case EAST : position[3*vertex  ] = (centerX+0.5f)/mCols;
683 682
                   position[3*vertex+1] = (back ? (centerY+0.5f):(centerY-0.5f))/mRows;
684 683
                   position[3*vertex+2] = lower ? BACKZ : FRONTZ;
685 684

  
686
                   normal[3*vertex+0]   = 1.0f;
685
                   normal[3*vertex  ]   = 1.0f;
687 686
                   normal[3*vertex+1]   = side==EAST ? 0.0f : (side==SOUTH?-R:R);
688 687
                   normal[3*vertex+2]   = lower ? -R:R; 
689 688

  
690
                   texture[2*vertex+0]  = (float)(lower ? (curr.col+2):(curr.col+1))/mCols;
689
                   texture[2*vertex  ]  = (float)(lower ? (curr.col+2):(curr.col+1))/mCols;
691 690
                   texture[2*vertex+1]  = (float)(back  ? (curr.row  ):(curr.row+1))/mRows;
692 691
                   break;
693 692
       }
694 693
     
695
     if(texture[2*vertex+0]>1.0f) texture[2*vertex+0] =2.0f-texture[2*vertex+0];
696
     if(texture[2*vertex+0]<0.0f) texture[2*vertex+0] =    -texture[2*vertex+0];
694
     if(texture[2*vertex  ]>1.0f) texture[2*vertex  ] =2.0f-texture[2*vertex  ];
695
     if(texture[2*vertex  ]<0.0f) texture[2*vertex  ] =    -texture[2*vertex  ];
697 696
     if(texture[2*vertex+1]>1.0f) texture[2*vertex+1] =2.0f-texture[2*vertex+1];
698 697
     if(texture[2*vertex+1]<0.0f) texture[2*vertex+1] =    -texture[2*vertex+1];
699 698
     }
......
705 704
/**
706 705
 * Creates the underlying grid of vertices, normals, texture coords and colors.
707 706
 *    
708
 * @param rows See {@link DistortedCubes#DistortedCubes(String)} 
709
 * @param desc See {@link DistortedCubes#DistortedCubes(String)}
707
 * @param cols      See {@link DistortedCubes#DistortedCubes(int,String,int,boolean)}
708
 * @param desc      See {@link DistortedCubes#DistortedCubes(int,String,int,boolean)}
709
 * @param frontOnly See {@link DistortedCubes#DistortedCubes(int,String,int,boolean)}
710 710
 */
711 711
   public DistortedCubesGrid(int cols, String desc, boolean frontOnly)
712 712
      {
......
720 720
      
721 721
      for(int i=0; i<dataLength; i++)
722 722
        {
723
        colorData[COLOR_DATA_SIZE*i+0] = 1.0f; // r
723
        colorData[COLOR_DATA_SIZE*i  ] = 1.0f; // r
724 724
        colorData[COLOR_DATA_SIZE*i+1] = 1.0f; // g
725 725
        colorData[COLOR_DATA_SIZE*i+2] = 1.0f; // b
726 726
        colorData[COLOR_DATA_SIZE*i+3] = 1.0f; // a

Also available in: Unified diff