2012-03-04 3 views
0

저는 현재 작업중인 애플리케이션의 Android API 샘플에서 Kube 애플리케이션을 사용하고 있습니다.Android Kube API 샘플의 구조가 깨져졌습니다.

이 샘플은 27 개의 작은 큐브로 만들어진 OpenGL에서 Rubik 's Cube 모델을 생성합니다. 그 후 큐브는 내가 완전히

// adjust mPermutation based on the completed layer rotation 
      int[] newPermutation = new int[27]; 
      for (int i = 0; i < 27; i++) { 
       newPermutation[i] = mPermutation[mCurrentLayerPermutation[i]]; 
//      newPermutation[i] = mCurrentLayerPermutation[mPermutation[i]]; 
      } 
      mPermutation = newPermutation; 
      updateLayers(); 

샘플이 잘 작동을 이해하지 않는 층은 과정에 따라 설정되는 각 회전 후, 큐브의 임의 층을 돌려 애니메이션() 메소드에 스크램블되고 있지만, 어떤 이유로 회전의 방향을 true로 변경하면 레이어가 올바르게 업데이트되지 않은 것처럼 큐브가 서로 중첩됩니다.
도움을 주시면 감사하겠습니다 :) 경우에 누군가가 관심 있도록 Cubes overlapping

답변

2

나는 문제를 스스로 해결 :
사실이 큐브에 세 번 회전처럼 다른 방향으로 회전 수에 방향을 변경 큐브에 새 위치를 올바르게 저장하려면 일반 방향을 사용하십시오. 아래 코드와 같이 새 위치를 세 번 저장해야합니다.

   if (mAngleIncrement < 0) { // checks the turning direction 
      int[] newPermutation = new int[27]; 
      for (int i = 0; i < 27; i++) { 
       newPermutation[i] = mPermutation[mCurrentLayerPermutation[i]]; 

      } 
      mPermutation = newPermutation; 
      updateLayers(); 
     } 
     else { 
      int[] newPermutation = new int[27]; 
      for (int i = 0; i < 27; i++) { 
       newPermutation[i] = mPermutation[mCurrentLayerPermutation[i]]; 
      } 
      mPermutation = newPermutation; 

      newPermutation = new int[27]; 
      for (int i = 0; i < 27; i++) { 
       newPermutation[i] = mPermutation[mCurrentLayerPermutation[i]]; 
      } 
      mPermutation = newPermutation; 

      newPermutation = new int[27]; 
      for (int i = 0; i < 27; i++) { 
       newPermutation[i] = mPermutation[mCurrentLayerPermutation[i]]; 
      } 
      mPermutation = newPermutation; 
      updateLayers(); 

     }