Project

General

Profile

« Previous | Next » 

Revision 974a0e69

Added by Leszek Koltunski over 2 years ago

Convert Helicopter.

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyHelicopter.java
39 39

  
40 40
public class TwistyHelicopter extends ShapeHexahedron
41 41
{
42
  // the six rotation axis of a Helicopter. Must be normalized.
43 42
  static final Static3D[] ROT_AXIS = new Static3D[]
44 43
         {
45 44
           new Static3D(     0, +SQ2/2, -SQ2/2),
......
52 51

  
53 52
  private ScrambleState[] mStates;
54 53
  private int[] mBasicAngle;
55
  private Static4D[] mQuats;
56 54
  private float[][] mCuts;
57 55
  private float[][] mCenters;
58 56
  private int[] mQuatIndices;
......
91 89
    return mStates;
92 90
    }
93 91

  
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

  
96
  private void initializeQuats()
97
    {
98
    mQuats = new Static4D[]
99
         {
100
         new Static4D( 0.00f,  0.00f,  0.00f,  1.00f ),
101
         new Static4D( 1.00f,  0.00f,  0.00f,  0.00f ),
102
         new Static4D( 0.00f,  1.00f,  0.00f,  0.00f ),
103
         new Static4D( 0.00f,  0.00f,  1.00f,  0.00f ),
104

  
105
         new Static4D( SQ2/2,  SQ2/2,  0.00f,  0.00f ),
106
         new Static4D( SQ2/2, -SQ2/2,  0.00f,  0.00f ),
107
         new Static4D( SQ2/2,  0.00f,  SQ2/2,  0.00f ),
108
         new Static4D( SQ2/2,  0.00f, -SQ2/2,  0.00f ),
109
         new Static4D( SQ2/2,  0.00f,  0.00f,  SQ2/2 ),
110
         new Static4D( SQ2/2,  0.00f,  0.00f, -SQ2/2 ),
111
         new Static4D( 0.00f,  SQ2/2,  SQ2/2,  0.00f ),
112
         new Static4D( 0.00f,  SQ2/2, -SQ2/2,  0.00f ),
113
         new Static4D( 0.00f,  SQ2/2,  0.00f,  SQ2/2 ),
114
         new Static4D( 0.00f,  SQ2/2,  0.00f, -SQ2/2 ),
115
         new Static4D( 0.00f,  0.00f,  SQ2/2,  SQ2/2 ),
116
         new Static4D( 0.00f,  0.00f,  SQ2/2, -SQ2/2 ),
117

  
118
         new Static4D( 0.50f,  0.50f,  0.50f,  0.50f ),
119
         new Static4D( 0.50f,  0.50f,  0.50f, -0.50f ),
120
         new Static4D( 0.50f,  0.50f, -0.50f,  0.50f ),
121
         new Static4D( 0.50f,  0.50f, -0.50f, -0.50f ),
122
         new Static4D( 0.50f, -0.50f,  0.50f,  0.50f ),
123
         new Static4D( 0.50f, -0.50f,  0.50f, -0.50f ),
124
         new Static4D( 0.50f, -0.50f, -0.50f,  0.50f ),
125
         new Static4D( 0.50f, -0.50f, -0.50f, -0.50f )
126
         };
127
    }
128

  
129 92
///////////////////////////////////////////////////////////////////////////////////////////////////
130 93

  
131 94
  public int[] getSolvedQuats(int cubit, int[] numLayers)
132 95
    {
133
    if( mQuats==null ) initializeQuats();
134 96
    int status = retCubitSolvedStatus(cubit,numLayers);
135
    return status<0 ? null : buildSolvedQuats(TouchControlHexahedron.FACE_AXIS[status],mQuats);
136
    }
137

  
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

  
140
  public Static4D[] getQuats()
141
    {
142
    if( mQuats==null ) initializeQuats();
143
    return mQuats;
97
    return status<0 ? null : buildSolvedQuats(TouchControlHexahedron.FACE_AXIS[status],mObjectQuats);
144 98
    }
145 99

  
146 100
///////////////////////////////////////////////////////////////////////////////////////////////////
......
167 121

  
168 122
  public boolean[][] getLayerRotatable(int[] numLayers)
169 123
    {
170
    int numAxis = ROT_AXIS.length;
171 124
    boolean[] tmp = new boolean[] {true,false,true};
172
    boolean[][] layerRotatable = new boolean[numAxis][];
173
    for(int i=0; i<numAxis; i++) layerRotatable[i] = tmp;
174

  
175
    return layerRotatable;
125
    return new boolean[][] { tmp,tmp,tmp,tmp,tmp,tmp };
176 126
    }
177 127

  
178 128
///////////////////////////////////////////////////////////////////////////////////////////////////
......
278 228

  
279 229
  public Static4D getCubitQuats(int cubit, int[] numLayers)
280 230
    {
281
    if( mQuats==null ) initializeQuats();
282
    if( mQuatIndices==null ) mQuatIndices = new int[] { 0,13,14,1,12,2,3,7,20,6,13,17,7,23,18,12,22,10,8,16,11,21,19,9,3,15,14,0,5,2,1,4 };
283
    return mQuats[mQuatIndices[cubit]];
231
    if( mQuatIndices==null ) mQuatIndices = new int[] { 0,19,21,7,18,16,17,3,12,4,19,8,3,9,13,18,11,2,22,10,1,15,14,23,17,20,21,0,5,16,7,6 };
232
    return mObjectQuats[mQuatIndices[cubit]];
284 233
    }
285 234

  
286 235
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff