Project

General

Profile

« Previous | Next » 

Revision ead91342

Added by Leszek Koltunski about 3 years ago

Progress with any size Kilominx.

View differences:

src/main/java/org/distorted/objects/TwistyMinx.java
35 35
{
36 36
  private static final int FACES_PER_CUBIT =6;
37 37

  
38
  static final int NUM_CORNERS = 20;
39
  static final int NUM_CENTERS = 12;
40
  static final int NUM_EDGES   = 30;
41

  
38 42
  static final float C0 = (SQ5-1)/4;                       // cos(72 deg)
39 43
  static final float C1 = (SQ5+1)/4;                       // cos(36 deg)
40 44
  static final float C2 = (SQ5+3)/4;
......
206 210
          {false,  true,  true,  true,  true, false}
207 211
      };
208 212

  
213
  // the quadruple ( vertex1, vertex2, face1, face2 ) defining an edge.
214
  // In fact the 2 vertices already define it, the faces only provide easy
215
  // way to get to know the colors. Order: arbitrary. Face1 arbitrarily on
216
  // the 'left' or right of vector vertex1 --> vertex2, according to Quat.
217
  static final int[][] mEdgeMap =
218
         {
219
           {  0, 12,  0,  8},
220
           { 12,  4,  0,  9},
221
           {  4, 14,  0,  4},
222
           { 14,  2,  0, 11},
223
           {  2,  0,  0,  1},
224
           { 14,  9,  4, 11},
225
           {  9, 11,  3, 11},
226
           { 11, 18,  2, 11},
227
           { 18,  2,  1, 11},
228
           { 18,  6,  1,  2},
229
           {  6, 16,  1,  7},
230
           { 16,  0,  8,  1},
231
           { 16, 10,  7,  8},
232
           { 10,  8, 10,  8},
233
           {  8, 12,  9,  8},
234
           {  8, 13,  9, 10},
235
           { 13,  5,  9,  5},
236
           {  5,  4,  9,  4},
237
           {  5, 15,  5,  4},
238
           { 15,  9,  3,  4},
239
           { 11, 19,  2,  3},
240
           { 19,  7,  2,  6},
241
           {  7,  6,  2,  7},
242
           {  7, 17,  7,  6},
243
           { 17, 10,  7, 10},
244
           { 17,  1, 10,  6},
245
           {  1,  3,  5,  6},
246
           {  3, 19,  3,  6},
247
           {  1, 13, 10,  5},
248
           {  3, 15,  3,  5},
249
         };
250

  
251
  // the five vertices that form a given face. Order: the same as colors
252
  // of the faces in TwistyMinx.
253
  static final int[][] mCenterMap =
254
         {
255
           { 0, 12,  4, 14,  2},
256
           { 0,  2, 18,  6, 16},
257
           { 6, 18, 11, 19,  7},
258
           { 3, 15,  9, 11, 19},
259
           { 4,  5, 15,  9, 14},
260
           { 1, 13,  5, 15,  3},
261
           { 1,  3, 19,  7, 17},
262
           {10, 16,  6,  7, 17},
263
           { 0, 12,  8, 10, 16},
264
           { 8, 13,  5,  4, 12},
265
           { 1, 13,  8, 10, 17},
266
           { 2, 14,  9, 11, 18},
267
         };
268

  
269
  static final float[][] mCenterCoords = new float[NUM_CENTERS][3];
270

  
271
  static
272
    {
273
    for(int center=0; center<NUM_CENTERS; center++)
274
      {
275
      int[] map = mCenterMap[center];
276

  
277
      float x = CORNERS[map[0]][0] +
278
                CORNERS[map[1]][0] +
279
                CORNERS[map[2]][0] +
280
                CORNERS[map[3]][0] +
281
                CORNERS[map[4]][0] ;
282

  
283
      float y = CORNERS[map[0]][1] +
284
                CORNERS[map[1]][1] +
285
                CORNERS[map[2]][1] +
286
                CORNERS[map[3]][1] +
287
                CORNERS[map[4]][1] ;
288

  
289
      float z = CORNERS[map[0]][2] +
290
                CORNERS[map[1]][2] +
291
                CORNERS[map[2]][2] +
292
                CORNERS[map[3]][2] +
293
                CORNERS[map[4]][2] ;
294

  
295
      mCenterCoords[center][0] = x/5;
296
      mCenterCoords[center][1] = y/5;
297
      mCenterCoords[center][2] = z/5;
298
      }
299
    }
300

  
301
  static final Static4D[] mBasicCornerV, mCurrCornerV;
302

  
303
  static
304
    {
305
    mBasicCornerV = new Static4D[3];
306
    mCurrCornerV  = new Static4D[3];
307

  
308
    mBasicCornerV[0] = new Static4D( (SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
309
    mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.125f, (SQ5-1)*0.125f, -0.250f, 0.0f );
310
    mBasicCornerV[2] = new Static4D(              0,        -0.500f,    0.0f, 0.0f );
311
    }
312

  
313

  
209 314
///////////////////////////////////////////////////////////////////////////////////////////////////
210 315

  
211 316
  TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh,

Also available in: Unified diff