Project

General

Profile

« Previous | Next » 

Revision 8da6b1c9

Added by Leszek Koltunski over 2 years ago

Changes to the Cube cubits; new cube meshes.

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyCube.java
186 186
    return status<0 ? null : buildSolvedQuats(Movement6.FACE_AXIS[status], mQuats);
187 187
    }
188 188

  
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

  
191
  private int getNumCornersAndEdges(int numLayers)
192
    {
193
    return numLayers==1 ? 1 : 12*(numLayers-2) + 8;
194
    }
195

  
189 196
///////////////////////////////////////////////////////////////////////////////////////////////////
190 197

  
191 198
  protected ObjectShape getObjectShape(int cubit, int numLayers)
......
233 240
    return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
234 241
    }
235 242

  
243
///////////////////////////////////////////////////////////////////////////////////////////////////
244

  
245
  protected float[][] getCubitPositions(int numLayers)
246
    {
247
    if( numLayers==1 ) return new float[][] {{ 0.0f, 0.0f, 0.0f }};
248

  
249
    int numCubits = getNumCornersAndEdges(numLayers) + 6*(numLayers-2)*(numLayers-2);
250
    float[][] tmp = new float[numCubits][];
251

  
252
    final float LEN = 0.5f*(numLayers-1);
253
    int currentPosition = 0;
254

  
255
    tmp[currentPosition++] = new float[] {-LEN,-LEN,-LEN};
256
    tmp[currentPosition++] = new float[] {-LEN,-LEN,+LEN};
257
    tmp[currentPosition++] = new float[] {-LEN,+LEN,-LEN};
258
    tmp[currentPosition++] = new float[] {-LEN,+LEN,+LEN};
259
    tmp[currentPosition++] = new float[] {+LEN,-LEN,-LEN};
260
    tmp[currentPosition++] = new float[] {+LEN,-LEN,+LEN};
261
    tmp[currentPosition++] = new float[] {+LEN,+LEN,-LEN};
262
    tmp[currentPosition++] = new float[] {+LEN,+LEN,+LEN};
263

  
264
    for(int i=1; i<numLayers-1; i++)
265
      tmp[currentPosition++] = new float[] { i-LEN,  -LEN,  -LEN };
266
    for(int i=1; i<numLayers-1; i++)
267
      tmp[currentPosition++] = new float[] { i-LEN,  -LEN,  +LEN };
268
    for(int i=1; i<numLayers-1; i++)
269
      tmp[currentPosition++] = new float[] { i-LEN,  +LEN,  -LEN };
270
    for(int i=1; i<numLayers-1; i++)
271
      tmp[currentPosition++] = new float[] { i-LEN,  +LEN,  +LEN };
272
    for(int i=1; i<numLayers-1; i++)
273
      tmp[currentPosition++] = new float[] {  -LEN, i-LEN,  -LEN };
274
    for(int i=1; i<numLayers-1; i++)
275
      tmp[currentPosition++] = new float[] {  -LEN, i-LEN,  +LEN };
276
    for(int i=1; i<numLayers-1; i++)
277
      tmp[currentPosition++] = new float[] {  +LEN, i-LEN,  -LEN };
278
    for(int i=1; i<numLayers-1; i++)
279
      tmp[currentPosition++] = new float[] {  +LEN, i-LEN,  +LEN };
280
    for(int i=1; i<numLayers-1; i++)
281
      tmp[currentPosition++] = new float[] {  -LEN,  -LEN, i-LEN };
282
    for(int i=1; i<numLayers-1; i++)
283
      tmp[currentPosition++] = new float[] {  -LEN,  +LEN, i-LEN };
284
    for(int i=1; i<numLayers-1; i++)
285
      tmp[currentPosition++] = new float[] {  +LEN,  -LEN, i-LEN };
286
    for(int i=1; i<numLayers-1; i++)
287
      tmp[currentPosition++] = new float[] {  +LEN,  +LEN, i-LEN };
288

  
289
    for(int y=1; y<numLayers-1; y++)
290
      for(int z=1; z<numLayers-1; z++)
291
        tmp[currentPosition++] = new float[] {+LEN,y-LEN,z-LEN};
292

  
293
    for(int y=1; y<numLayers-1; y++)
294
      for(int z=1; z<numLayers-1; z++)
295
        tmp[currentPosition++] = new float[] {-LEN,y-LEN,z-LEN};
296

  
297
    for(int x=1; x<numLayers-1; x++)
298
      for(int z=1; z<numLayers-1; z++)
299
        tmp[currentPosition++] = new float[] {x-LEN,+LEN,z-LEN};
300

  
301
    for(int x=1; x<numLayers-1; x++)
302
      for(int z=1; z<numLayers-1; z++)
303
        tmp[currentPosition++] = new float[] {x-LEN,-LEN,z-LEN};
304

  
305
    for(int x=1; x<numLayers-1; x++)
306
      for(int y=1; y<numLayers-1; y++)
307
        tmp[currentPosition++] = new float[] {x-LEN,y-LEN,+LEN};
308

  
309
    for(int x=1; x<numLayers-1; x++)
310
      for(int y=1; y<numLayers-1; y++)
311
        tmp[currentPosition++] = new float[] {x-LEN,y-LEN,-LEN};
312

  
313
    return tmp;
314
    }
315

  
236 316
///////////////////////////////////////////////////////////////////////////////////////////////////
237 317

  
238 318
  protected Static4D getQuat(int cubit, int numLayers)
239 319
    {
240 320
    if( mQuats ==null ) initializeQuats();
321

  
322
    int num = cubit - getNumCornersAndEdges(numLayers);
323

  
324
    if( num>=0 )
325
      {
326
      int face = num/((numLayers-2)*(numLayers-2));
327

  
328
      switch(face)
329
        {
330
        case 0: return mQuats[13];
331
        case 1: return mQuats[12];
332
        case 2: return mQuats[ 8];
333
        case 3: return mQuats[ 9];
334
        case 4: return mQuats[ 0];
335
        case 5: return mQuats[ 1];
336
        }
337
      }
338

  
241 339
    return mQuats[0];
242 340
    }
243 341

  
......
245 343

  
246 344
  protected int getNumCubitVariants(int numLayers)
247 345
    {
248
    return 1;
346
    return numLayers>2 ? 2:1;
249 347
    }
250 348

  
251 349
///////////////////////////////////////////////////////////////////////////////////////////////////
252 350

  
253 351
  protected int getCubitVariant(int cubit, int numLayers)
254 352
    {
255
    return 0;
353
    return cubit < getNumCornersAndEdges(numLayers) ? 0 : 1;
354
    }
355

  
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

  
358
  protected int getFaceColor(int cubit, int cubitface, int numLayers)
359
    {
360
    int cornersAndEdges = getNumCornersAndEdges(numLayers);
361

  
362
    if( cubit<cornersAndEdges )
363
      {
364
      return CUBITS[cubit].getRotRow(cubitface/2) == (cubitface%2==0 ? (1<<(numLayers-1)):1) ? cubitface : NUM_TEXTURES;
365
      }
366
    else
367
      {
368
      int numCentersPerFace = (numLayers-2)*(numLayers-2);
369
      return cubitface == 4 ? (cubit-cornersAndEdges)/numCentersPerFace : NUM_TEXTURES;
370
      }
256 371
    }
257 372

  
258 373
///////////////////////////////////////////////////////////////////////////////////////////////////
......
284 399
    return mStickers[face/NUM_FACE_COLORS];
285 400
    }
286 401

  
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288

  
289
  protected float[][] getCubitPositions(int numLayers)
290
    {
291
    int numCubits = numLayers>1 ? 6*numLayers*numLayers - 12*numLayers + 8 : 1;
292
    float[][] tmp = new float[numCubits][];
293

  
294
    float diff = 0.5f*(numLayers-1);
295
    int currentPosition = 0;
296

  
297
    for(int x = 0; x<numLayers; x++)
298
      for(int y = 0; y<numLayers; y++)
299
        for(int z = 0; z<numLayers; z++)
300
          if( x==0 || x==numLayers-1 || y==0 || y==numLayers-1 || z==0 || z==numLayers-1 )
301
            {
302
            tmp[currentPosition++] = new float[] {x-diff,y-diff,z-diff};
303
            }
304

  
305
    return tmp;
306
    }
307

  
308 402
///////////////////////////////////////////////////////////////////////////////////////////////////
309 403

  
310 404
  protected Static4D[] getQuats()
......
370 464
    return 6;
371 465
    }
372 466

  
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

  
375
  protected int getFaceColor(int cubit, int cubitface, int numLayers)
376
    {
377
    return CUBITS[cubit].getRotRow(cubitface/2) == (cubitface%2==0 ? (1<<(numLayers-1)):1) ? cubitface : NUM_TEXTURES;
378
    }
379

  
380 467
///////////////////////////////////////////////////////////////////////////////////////////////////
381 468
// PUBLIC API
382 469

  

Also available in: Unified diff