Project

General

Profile

« Previous | Next » 

Revision 68ce0d53

Added by Leszek Koltunski over 3 years ago

Simplify the 'bandaged' class API.

View differences:

src/main/java/org/distorted/objects/TwistyBandaged2Bar.java
33 33

  
34 34
class TwistyBandaged2Bar extends TwistyBandagedAbstract
35 35
{
36
  TwistyBandaged2Bar(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
37
                     DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
38
    {
39
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN2, res, scrWidth);
40
    }
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  int getCubitVariant(int cubit)
45
    {
46
    return cubit<=1 ? 2:0;
47
    }
36
  private static final float[][] POSITIONS = new float[][]
37
      {
38
       { 0.0f, +1.0f,  1.0f, 0.0f, +1.0f,  0.0f, 0.0f, +1.0f, -1.0f},
39
       {-1.0f, -1.0f,  0.0f, 0.0f, -1.0f,  0.0f, 1.0f, -1.0f,  0.0f},
40
       {-1.0f, +1.0f, +1.0f},
41
       {-1.0f, +1.0f,  0.0f},
42
       {-1.0f, +1.0f, -1.0f},
43
       {-1.0f,  0.0f, +1.0f},
44
       {-1.0f,  0.0f,  0.0f},
45
       {-1.0f,  0.0f, -1.0f},
46
       {-1.0f, -1.0f, +1.0f},
47
       {-1.0f, -1.0f, -1.0f},
48
       {+1.0f, +1.0f, +1.0f},
49
       {+1.0f, +1.0f,  0.0f},
50
       {+1.0f, +1.0f, -1.0f},
51
       {+1.0f,  0.0f, +1.0f},
52
       {+1.0f,  0.0f,  0.0f},
53
       {+1.0f,  0.0f, -1.0f},
54
       {+1.0f, -1.0f, +1.0f},
55
       {+1.0f, -1.0f, -1.0f},
56
       { 0.0f,  0.0f, +1.0f},
57
       { 0.0f, -1.0f, +1.0f},
58
       { 0.0f,  0.0f, -1.0f},
59
       { 0.0f, -1.0f, -1.0f}
60
      };
61

  
62
  private static final int[] QUAT_INDICES = new int[] { 2 };
48 63

  
49 64
///////////////////////////////////////////////////////////////////////////////////////////////////
50 65

  
51
  int getNumCubits()
66
  TwistyBandaged2Bar(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
67
                     DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
52 68
    {
53
    return 22;
69
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN2, res, scrWidth);
54 70
    }
55 71

  
56 72
///////////////////////////////////////////////////////////////////////////////////////////////////
57 73

  
58
  float[] getCubitPosition(int cubit)
74
  float[][] getPositions()
59 75
    {
60
    switch(cubit)
61
      {
62
      case  0: return new float[] { 0.0f, +1.0f,  1.0f,
63
                                    0.0f, +1.0f,  0.0f,
64
                                    0.0f, +1.0f, -1.0f};
65
      case  1: return new float[] {-1.0f, -1.0f,  0.0f,
66
                                    0.0f, -1.0f,  0.0f,
67
                                    1.0f, -1.0f,  0.0f};
68
      case  2: return new float[] {-1.0f, +1.0f, +1.0f};
69
      case  3: return new float[] {-1.0f, +1.0f,  0.0f};
70
      case  4: return new float[] {-1.0f, +1.0f, -1.0f};
71
      case  5: return new float[] {-1.0f,  0.0f, +1.0f};
72
      case  6: return new float[] {-1.0f,  0.0f,  0.0f};
73
      case  7: return new float[] {-1.0f,  0.0f, -1.0f};
74
      case  8: return new float[] {-1.0f, -1.0f, +1.0f};
75
      case  9: return new float[] {-1.0f, -1.0f, -1.0f};
76
      case 10: return new float[] {+1.0f, +1.0f, +1.0f};
77
      case 11: return new float[] {+1.0f, +1.0f,  0.0f};
78
      case 12: return new float[] {+1.0f, +1.0f, -1.0f};
79
      case 13: return new float[] {+1.0f,  0.0f, +1.0f};
80
      case 14: return new float[] {+1.0f,  0.0f,  0.0f};
81
      case 15: return new float[] {+1.0f,  0.0f, -1.0f};
82
      case 16: return new float[] {+1.0f, -1.0f, +1.0f};
83
      case 17: return new float[] {+1.0f, -1.0f, -1.0f};
84
      case 18: return new float[] { 0.0f,  0.0f, +1.0f};
85
      case 19: return new float[] { 0.0f, -1.0f, +1.0f};
86
      case 20: return new float[] { 0.0f,  0.0f, -1.0f};
87
      case 21: return new float[] { 0.0f, -1.0f, -1.0f};
88
      }
89

  
90
    return null;
76
    return POSITIONS;
91 77
    }
92 78

  
93 79
///////////////////////////////////////////////////////////////////////////////////////////////////
94 80

  
95
  int getQuatIndex(int cubit)
81
  int[] getQuatIndices()
96 82
    {
97
    return cubit==0 ? 2 : 0;
83
    return QUAT_INDICES;
98 84
    }
99 85

  
100 86
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyBandaged3Plate.java
159 159

  
160 160
///////////////////////////////////////////////////////////////////////////////////////////////////
161 161

  
162
  TwistyBandaged3Plate(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
163
                       DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
164
    {
165
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN3, res, scrWidth);
166
    }
167

  
168
///////////////////////////////////////////////////////////////////////////////////////////////////
162
  private static final float[][] POSITIONS = new float[][]
163
      {
164
       {-1.0f,  1.0f,  1.0f, -1.0f,  0.0f,  1.0f,  0.0f,  1.0f,  1.0f,  0.0f,  0.0f,  1.0f},
165
       { 1.0f,  0.0f, -1.0f,  1.0f,  0.0f,  0.0f,  1.0f,  1.0f, -1.0f,  1.0f,  1.0f,  0.0f},
166
       {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f,  0.0f,  0.0f, -1.0f, -1.0f,  0.0f, -1.0f,  0.0f},
167
       { 1.0f,  1.0f,  1.0f},
168
       { 1.0f,  0.0f,  1.0f},
169
       { 1.0f, -1.0f,  1.0f},
170
       {-1.0f, -1.0f,  1.0f},
171
       { 0.0f, -1.0f,  1.0f},
172
       { 1.0f, -1.0f,  0.0f},
173
       { 1.0f, -1.0f, -1.0f},
174
       {-1.0f,  1.0f, -1.0f},
175
       {-1.0f,  1.0f,  0.0f},
176
       { 0.0f,  1.0f, -1.0f},
177
       { 0.0f,  1.0f,  0.0f},
178
       {-1.0f,  0.0f, -1.0f},
179
       {-1.0f,  0.0f,  0.0f},
180
       { 0.0f,  0.0f, -1.0f}
181
      };
169 182

  
170
  int getCubitVariant(int cubit)
171
    {
172
    return cubit<=2 ? 3:0;
173
    }
183
  private static final int[] QUAT_INDICES = new int[] { 1, 3 };
174 184

  
175 185
///////////////////////////////////////////////////////////////////////////////////////////////////
176 186

  
177
  int getNumCubits()
187
  TwistyBandaged3Plate(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
188
                       DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
178 189
    {
179
    return 17;
190
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN3, res, scrWidth);
180 191
    }
181 192

  
182 193
///////////////////////////////////////////////////////////////////////////////////////////////////
183 194

  
184
  float[] getCubitPosition(int cubit)
195
  float[][] getPositions()
185 196
    {
186
    switch(cubit)
187
      {
188
      case  0: return new float[] {-1.0f,  1.0f,  1.0f,
189
                                   -1.0f,  0.0f,  1.0f,
190
                                    0.0f,  1.0f,  1.0f,
191
                                    0.0f,  0.0f,  1.0f};
192
      case  1: return new float[] { 1.0f,  0.0f, -1.0f,
193
                                    1.0f,  0.0f,  0.0f,
194
                                    1.0f,  1.0f, -1.0f,
195
                                    1.0f,  1.0f,  0.0f};
196
      case  2: return new float[] {-1.0f, -1.0f, -1.0f,
197
                                   -1.0f, -1.0f,  0.0f,
198
                                    0.0f, -1.0f, -1.0f,
199
                                    0.0f, -1.0f,  0.0f};
200
      case  3: return new float[] { 1.0f,  1.0f,  1.0f};
201
      case  4: return new float[] { 1.0f,  0.0f,  1.0f};
202
      case  5: return new float[] { 1.0f, -1.0f,  1.0f};
203
      case  6: return new float[] {-1.0f, -1.0f,  1.0f};
204
      case  7: return new float[] { 0.0f, -1.0f,  1.0f};
205
      case  8: return new float[] { 1.0f, -1.0f,  0.0f};
206
      case  9: return new float[] { 1.0f, -1.0f, -1.0f};
207
      case 10: return new float[] {-1.0f,  1.0f, -1.0f};
208
      case 11: return new float[] {-1.0f,  1.0f,  0.0f};
209
      case 12: return new float[] { 0.0f,  1.0f, -1.0f};
210
      case 13: return new float[] { 0.0f,  1.0f,  0.0f};
211
      case 14: return new float[] {-1.0f,  0.0f, -1.0f};
212
      case 15: return new float[] {-1.0f,  0.0f,  0.0f};
213
      case 16: return new float[] { 0.0f,  0.0f, -1.0f};
214
      }
215

  
216
    return null;
197
    return POSITIONS;
217 198
    }
218 199

  
219 200
///////////////////////////////////////////////////////////////////////////////////////////////////
220 201

  
221
  int getQuatIndex(int cubit)
202
  int[] getQuatIndices()
222 203
    {
223
    switch(cubit)
224
      {
225
      case 0: return 1;
226
      case 1: return 3;
227
      }
228

  
229
    return 0;
204
    return QUAT_INDICES;
230 205
    }
231 206

  
232 207
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java
138 138

  
139 139
///////////////////////////////////////////////////////////////////////////////////////////////////
140 140

  
141
  abstract int getCubitVariant(int cubit);
142
  abstract int getNumCubits();
143
  abstract int getQuatIndex(int cubit);
144
  abstract float[] getCubitPosition(int cubit);
141
  abstract float[][] getPositions();
142
  abstract int[] getQuatIndices();
143

  
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145

  
146
  int getCubitVariant(int cubit)
147
    {
148
    float[][] pos = getPositions();
149

  
150
    if( cubit>=0 && cubit< pos.length )
151
      {
152
      int numPoints = pos[cubit].length/3;
153
      return numPoints==8 ? 4:numPoints;
154
      }
155

  
156
    return 1;
157
    }
158

  
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

  
161
  int getNumCubits()
162
    {
163
    return getPositions().length;
164
    }
165

  
166
///////////////////////////////////////////////////////////////////////////////////////////////////
167

  
168
  float[] getCubitPosition(int cubit)
169
    {
170
    float[][] pos = getPositions();
171

  
172
    return ( cubit>=0 && cubit< pos.length ) ? pos[cubit] : null;
173
    }
174

  
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

  
177
  int getQuatIndex(int cubit)
178
    {
179
    int[] indices = getQuatIndices();
180

  
181
    return ( cubit>=0 && cubit< indices.length ) ? indices[cubit] : 0;
182
    }
145 183

  
146 184
///////////////////////////////////////////////////////////////////////////////////////////////////
147 185

  
src/main/java/org/distorted/objects/TwistyBandagedEvil.java
33 33

  
34 34
class TwistyBandagedEvil extends TwistyBandagedAbstract
35 35
{
36
  TwistyBandagedEvil(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
37
                     DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
38
    {
39
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN4, res, scrWidth);
40
    }
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  int getCubitVariant(int cubit)
45
    {
46
    switch(cubit)
36
  private static final float[][] POSITIONS = new float[][]
47 37
      {
48
      case 0: return 0;
49
      case 1: return 3;
50
      }
51

  
52
    return 1;
53
    }
38
        { 1.0f,  1.0f, -1.0f},
39
        {-1.0f, -1.0f,  0.0f, -1.0f,  0.0f,  0.0f, 0.0f, -1.0f,  0.0f,  0.0f,  0.0f,  0.0f},
40
        {-1.0f,  1.0f, -1.0f,  0.0f,  1.0f, -1.0f},
41
        {-1.0f,  0.0f, -1.0f,  0.0f,  0.0f, -1.0f},
42
        {-1.0f, -1.0f, -1.0f,  0.0f, -1.0f, -1.0f},
43
        {-1.0f,  1.0f,  0.0f, -1.0f,  1.0f,  1.0f},
44
        { 0.0f,  1.0f,  0.0f,  0.0f,  1.0f,  1.0f},
45
        { 1.0f,  1.0f,  0.0f,  1.0f,  1.0f,  1.0f},
46
        {-1.0f, -1.0f,  1.0f, -1.0f,  0.0f,  1.0f},
47
        { 0.0f, -1.0f,  1.0f,  0.0f,  0.0f,  1.0f},
48
        { 1.0f, -1.0f,  1.0f,  1.0f,  0.0f,  1.0f},
49
        { 1.0f, -1.0f,  0.0f,  1.0f,  0.0f,  0.0f},
50
        { 1.0f, -1.0f, -1.0f,  1.0f,  0.0f, -1.0f}
51
      };
52

  
53
  private static final int[] QUAT_INDICES = new int[]
54
      { 0, 1, 0, 0, 0, 2, 2, 2, 3, 3, 3, 3, 3 };
54 55

  
55 56
///////////////////////////////////////////////////////////////////////////////////////////////////
56 57

  
57
  int getNumCubits()
58
  TwistyBandagedEvil(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
59
                     DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
58 60
    {
59
    return 13;
61
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN4, res, scrWidth);
60 62
    }
61 63

  
62 64
///////////////////////////////////////////////////////////////////////////////////////////////////
63 65

  
64
  float[] getCubitPosition(int cubit)
66
  float[][] getPositions()
65 67
    {
66
    switch(cubit)
67
      {
68
      case  0: return new float[] { 1.0f,  1.0f, -1.0f};
69
      case  1: return new float[] {-1.0f, -1.0f,  0.0f,
70
                                   -1.0f,  0.0f,  0.0f,
71
                                    0.0f, -1.0f,  0.0f,
72
                                    0.0f,  0.0f,  0.0f};
73
      case  2: return new float[] {-1.0f,  1.0f, -1.0f,
74
                                    0.0f,  1.0f, -1.0f};
75
      case  3: return new float[] {-1.0f,  0.0f, -1.0f,
76
                                    0.0f,  0.0f, -1.0f};
77
      case  4: return new float[] {-1.0f, -1.0f, -1.0f,
78
                                    0.0f, -1.0f, -1.0f};
79
      case  5: return new float[] {-1.0f,  1.0f,  0.0f,
80
                                   -1.0f,  1.0f,  1.0f};
81
      case  6: return new float[] { 0.0f,  1.0f,  0.0f,
82
                                    0.0f,  1.0f,  1.0f};
83
      case  7: return new float[] { 1.0f,  1.0f,  0.0f,
84
                                    1.0f,  1.0f,  1.0f};
85
      case  8: return new float[] {-1.0f, -1.0f,  1.0f,
86
                                   -1.0f,  0.0f,  1.0f};
87
      case  9: return new float[] { 0.0f, -1.0f,  1.0f,
88
                                    0.0f,  0.0f,  1.0f};
89
      case 10: return new float[] { 1.0f, -1.0f,  1.0f,
90
                                    1.0f,  0.0f,  1.0f};
91
      case 11: return new float[] { 1.0f, -1.0f,  0.0f,
92
                                    1.0f,  0.0f,  0.0f};
93
      case 12: return new float[] { 1.0f, -1.0f, -1.0f,
94
                                    1.0f,  0.0f, -1.0f};
95
      }
96

  
97
    return null;
68
    return POSITIONS;
98 69
    }
99 70

  
100 71
///////////////////////////////////////////////////////////////////////////////////////////////////
101 72

  
102
  int getQuatIndex(int cubit)
73
  int[] getQuatIndices()
103 74
    {
104
    switch(cubit)
105
      {
106
      case 1: return 1;
107
      case 0:
108
      case 2:
109
      case 3:
110
      case 4: return 0;
111
      case 5:
112
      case 6:
113
      case 7: return 2;
114
      default:return 3;
115
      }
75
    return QUAT_INDICES;
116 76
    }
117 77

  
118 78
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyBandagedFused.java
33 33

  
34 34
class TwistyBandagedFused extends TwistyBandagedAbstract
35 35
{
36
  TwistyBandagedFused(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
37
                      DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
38
    {
39
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN1, res, scrWidth);
40
    }
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  int getCubitVariant(int cubit)
45
    {
46
    return cubit==0 ? 4:0;
47
    }
36
  private static final float[][] POSITIONS = new float[][]
37
      {
38
       {-1.0f, -1.0f, +0.0f,
39
        -1.0f, -1.0f, +1.0f,
40
        -1.0f,  0.0f, +0.0f,
41
        -1.0f,  0.0f, +1.0f,
42
         0.0f, -1.0f, +0.0f,
43
         0.0f, -1.0f, +1.0f,
44
         0.0f,  0.0f, +0.0f,
45
         0.0f,  0.0f, +1.0f},
46
       {-1.0f, +1.0f, +1.0f},
47
       {-1.0f, +1.0f, +0.0f},
48
       {-1.0f, +1.0f, -1.0f},
49
       { 0.0f, +1.0f, +1.0f},
50
       { 0.0f, +1.0f, +0.0f},
51
       { 0.0f, +1.0f, -1.0f},
52
       { 1.0f, +1.0f, +1.0f},
53
       { 1.0f, +1.0f, +0.0f},
54
       { 1.0f, +1.0f, -1.0f},
55
       { 1.0f,  0.0f, +1.0f},
56
       { 1.0f,  0.0f, +0.0f},
57
       { 1.0f,  0.0f, -1.0f},
58
       { 1.0f, -1.0f, +1.0f},
59
       { 1.0f, -1.0f, +0.0f},
60
       { 1.0f, -1.0f, -1.0f},
61
       {-1.0f, -1.0f, -1.0f},
62
       {-1.0f,  0.0f, -1.0f},
63
       { 0.0f, -1.0f, -1.0f},
64
       { 0.0f,  0.0f, -1.0f}
65
      };
66

  
67
  private static final int[] QUAT_INDICES = new int[] { 0 };
48 68

  
49 69
///////////////////////////////////////////////////////////////////////////////////////////////////
50 70

  
51
  int getNumCubits()
71
  TwistyBandagedFused(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
72
                      DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
52 73
    {
53
    return 20;
74
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN1, res, scrWidth);
54 75
    }
55 76

  
56 77
///////////////////////////////////////////////////////////////////////////////////////////////////
57 78

  
58
  float[] getCubitPosition(int cubit)
79
  float[][] getPositions()
59 80
    {
60
    switch(cubit)
61
      {
62
      case  0: return new float[] {-1.0f, -1.0f, +0.0f,
63
                                   -1.0f, -1.0f, +1.0f,
64
                                   -1.0f,  0.0f, +0.0f,
65
                                   -1.0f,  0.0f, +1.0f,
66
                                    0.0f, -1.0f, +0.0f,
67
                                    0.0f, -1.0f, +1.0f,
68
                                    0.0f,  0.0f, +0.0f,
69
                                    0.0f,  0.0f, +1.0f};
70
      case  1: return new float[] {-1.0f, +1.0f, +1.0f};
71
      case  2: return new float[] {-1.0f, +1.0f, +0.0f};
72
      case  3: return new float[] {-1.0f, +1.0f, -1.0f};
73
      case  4: return new float[] { 0.0f, +1.0f, +1.0f};
74
      case  5: return new float[] { 0.0f, +1.0f, +0.0f};
75
      case  6: return new float[] { 0.0f, +1.0f, -1.0f};
76
      case  7: return new float[] { 1.0f, +1.0f, +1.0f};
77
      case  8: return new float[] { 1.0f, +1.0f, +0.0f};
78
      case  9: return new float[] { 1.0f, +1.0f, -1.0f};
79
      case 10: return new float[] { 1.0f,  0.0f, +1.0f};
80
      case 11: return new float[] { 1.0f,  0.0f, +0.0f};
81
      case 12: return new float[] { 1.0f,  0.0f, -1.0f};
82
      case 13: return new float[] { 1.0f, -1.0f, +1.0f};
83
      case 14: return new float[] { 1.0f, -1.0f, +0.0f};
84
      case 15: return new float[] { 1.0f, -1.0f, -1.0f};
85
      case 16: return new float[] {-1.0f, -1.0f, -1.0f};
86
      case 17: return new float[] {-1.0f,  0.0f, -1.0f};
87
      case 18: return new float[] { 0.0f, -1.0f, -1.0f};
88
      case 19: return new float[] { 0.0f,  0.0f, -1.0f};
89
      }
90

  
91
    return null;
81
    return POSITIONS;
92 82
    }
93 83

  
94 84
///////////////////////////////////////////////////////////////////////////////////////////////////
95 85

  
96
  int getQuatIndex(int cubit)
86
  int[] getQuatIndices()
97 87
    {
98
    return 0;
88
    return QUAT_INDICES;
99 89
    }
100 90

  
101 91
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff