Project

General

Profile

« Previous | Next » 

Revision 3ee1d662

Added by Leszek Koltunski over 2 years ago

Split ObjectShape into ObjectShape and ObjectFaceShape

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyMegaminx.java
28 28
import org.distorted.library.type.Static4D;
29 29
import org.distorted.library.main.QuatHelper;
30 30

  
31
import org.distorted.objectlib.helpers.ObjectFaceShape;
31 32
import org.distorted.objectlib.main.ObjectControl;
32 33
import org.distorted.objectlib.main.ObjectType;
33 34
import org.distorted.objectlib.helpers.ObjectShape;
......
249 250
    int[] numLayers = getNumLayers();
250 251
    int numVariants = getNumCubitVariants(numLayers);
251 252
    int numL        = numLayers[0];
252
    boolean small   = numL<=3;
253 253

  
254 254
    if( variant==0 )
255 255
      {
256 256
      float width = numL*(0.5f-MEGA_D)/(0.5f*(numL-1));
257
      float A = (2*SQ3/3)*SIN54;
258
      float B = 0.4f;
259 257
      float X = width*COS18*SIN_HALFD;
260 258
      float Y = width*SIN18;
261 259
      float Z = width*COS18*COS_HALFD;
......
282 280
            {7,6,2,3}
283 281
        };
284 282

  
285
      float[][] bands    = new float[][]
286
        {
287
         {0.04f,34,0.3f,0.2f, 3, 0, 0},
288
         {0.00f, 0,0.0f,0.0f, 2, 0, 0}
289
        };
290

  
291
      int[] bandIndices   = new int[] { 0,0,0,1,1,1};
292
      float[][] corners   = new float[][] { {0.04f,0.10f} };
293
      int[] cornerIndices = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
294
      float[][] centers   = new float[][] { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
295
      int[] centerIndices = new int[] { 0,-1,-1,-1,-1,-1,-1,-1 };
296

  
297
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 3);
283
      return new ObjectShape(vertices,vertIndexes,getNumCubitFaces(),3);
298 284
      }
299 285
    if( variant<numVariants-1 )
300 286
      {
......
329 315
            {4,5,6,7}
330 316
        };
331 317

  
332
      int N = small ? 5 : 3;
333

  
334
      float[][] bands = new float[][]
335
        {
336
         {0.04f,34,0.2f,0.2f,N,0,0},
337
         {0.00f,34,0.3f,0.2f,2,0,0}
338
        };
339
      int[] bandIndices   = new int[] { 0,0,1,1,1,1};
340
      float[][] corners   = new float[][] { {0.04f,0.10f} };
341
      int[] cornerIndices = new int[] { -1,-1,-1,-1, -1,-1,-1,-1 };
342
      float[][] centers   = new float[][] { {0.0f, 0.0f, -2*Z} };
343
      int[] centerIndices = new int[] { -1,-1,-1,-1, -1,-1,-1,-1 };
344

  
345
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 2);
318
      return new ObjectShape(vertices,vertIndexes,getNumCubitFaces(),2);
346 319
      }
347 320
    else
348 321
      {
......
377 350
          {4,0,5}
378 351
        };
379 352

  
353
      return new ObjectShape(vertices,vertIndexes,getNumCubitFaces(),1);
354
      }
355
    }
356

  
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358

  
359
  public ObjectFaceShape getObjectFaceShape(int variant)
360
    {
361
    int[] numLayers = getNumLayers();
362
    int numVariants = getNumCubitVariants(numLayers);
363
    int numL        = numLayers[0];
364
    boolean small   = numL<=3;
365

  
366
    if( variant==0 )
367
      {
368
      float A = (2*SQ3/3)*SIN54;
369
      float B = 0.4f;
370

  
371
      float[][] bands     = { {0.04f,34,0.3f,0.2f, 3, 0, 0}, {0.00f, 0,0.0f,0.0f, 2, 0, 0} };
372
      int[] bandIndices   = { 0,0,0,1,1,1};
373
      float[][] corners   = { {0.04f,0.10f} };
374
      int[] cornerIndices = { 0,-1,-1,-1,-1,-1,-1,-1 };
375
      float[][] centers   = { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
376
      int[] centerIndices = { 0,-1,-1,-1,-1,-1,-1,-1 };
377

  
378
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
379
      }
380
    if( variant<numVariants-1 )
381
      {
382
      float height= numL*(0.5f-MEGA_D)*COS18/((numL-1)*0.5f);
383
      float Z = height*COS_HALFD;
384
      int N = small ? 5 : 3;
385

  
386
      float[][] bands     = { {0.04f,34,0.2f,0.2f,N,0,0},{0.00f,34,0.3f,0.2f,2,0,0} };
387
      int[] bandIndices   = { 0,0,1,1,1,1};
388
      float[][] corners   = { {0.04f,0.10f} };
389
      int[] cornerIndices = { -1,-1,-1,-1, -1,-1,-1,-1 };
390
      float[][] centers   = { {0.0f, 0.0f, -2*Z} };
391
      int[] centerIndices = { -1,-1,-1,-1, -1,-1,-1,-1 };
392

  
393
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
394
      }
395
    else
396
      {
397
      float width = 2*numL*(MEGA_D+(0.5f-MEGA_D)*SIN18);
398
      float R  = 0.5f*width/COS54;
380 399
      int N = small ? 4 : 3;
381 400
      float h = small ? 0.04f : 0.015f;
382 401

  
383
      float[][] bands = new float[][]
384
        {
385
         {    h,45, R/3,0.2f,N,0,0},
386
         {0.00f,45, R/3,0.2f,2,0,0}
387
        };
388

  
389
      int[] bandIndices   = new int[] { 0,1,1,1,1,1 };
390
      float[][] corners   = new float[][] { {0.04f,0.10f} };
391
      int[] cornerIndices = new int[] { -1,-1,-1,-1, -1,-1 };
392
      float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
393
      int[] centerIndices = new int[] { -1,-1,-1,-1, -1,-1 };
402
      float[][] bands     = { { h,45, R/3,0.2f,N,0,0},{0.00f,45, R/3,0.2f,2,0,0} };
403
      int[] bandIndices   = { 0,1,1,1,1,1 };
404
      float[][] corners   = { {0.04f,0.10f} };
405
      int[] cornerIndices = { -1,-1,-1,-1, -1,-1 };
406
      float[][] centers   = { {0.0f, 0.0f, 0.0f} };
407
      int[] centerIndices = { -1,-1,-1,-1, -1,-1 };
394 408

  
395
      return new ObjectShape(vertices,vertIndexes,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null, 1);
409
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
396 410
      }
397 411
    }
398 412

  

Also available in: Unified diff