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/TwistyIvy.java
27 27
import org.distorted.library.type.Static3D;
28 28
import org.distorted.library.type.Static4D;
29 29

  
30
import org.distorted.objectlib.helpers.ObjectFaceShape;
30 31
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
31 32
import org.distorted.objectlib.main.ObjectControl;
32 33
import org.distorted.objectlib.main.ObjectType;
......
229 230
      final float angle = (float)Math.PI/(2*IVY_N);
230 231
      final float CORR  = 1-2*IVY_D;
231 232

  
232
      float[][] centers  = new float[][] { {-1.0f,-1.0f,-1.0f} };
233
      float[][] corners  = new float[][] { {0.05f,0.20f}, {0.04f,0.20f} };
234 233
      float[][] vertices = new float[3*(IVY_N+1)+4][3];
235
      int[] cornerIndices= new int[3*(IVY_N+1)+4];
236
      int[] centerIndices= new int[3*(IVY_N+1)+4];
237 234
      int[][] vertIndices= new int[6][IVY_N+4];
238
      int[] bandIndices  = new int[] { 0,0,0,1,1,1 };
239

  
240
      float[][] bands =
241
        {
242
          {+0.015f,20,0.2f,0.5f,7,1,2},
243
          {-0.100f,20,0.2f,0.0f,2,1,2}
244
        };
245

  
246
      for(int i=0; i<3*(IVY_N+1); i++)
247
        {
248
        cornerIndices[i+4] = -1;
249
        centerIndices[i+4] = -1;
250
        }
251

  
252
      cornerIndices[0] = 1;
253
      cornerIndices[1] = 0;
254
      cornerIndices[2] = 0;
255
      cornerIndices[3] = 0;
256

  
257
      centerIndices[0] = 0;
258
      centerIndices[1] = 0;
259
      centerIndices[2] = 0;
260
      centerIndices[3] = 0;
261 235

  
262 236
      vertices[0][0] = 0;
263 237
      vertices[0][1] = 0;
......
324 298
        vertIndices[5][i+3] = N3 + i;
325 299
        }
326 300

  
327
      float C = 1-SQ2/2;
328
      float[] convexCenter = new float[] {-C,-C,-C};
329
      return new ObjectShape(vertices,vertIndices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), convexCenter, 3);
301
      return new ObjectShape(vertices,vertIndices,getNumCubitFaces(),3);
330 302
      }
331 303
    else
332 304
      {
......
335 307
      float[][] vertices = new float[2*IVY_N][3];
336 308
      int[][] vert_indices = new int[2][2*IVY_N];
337 309

  
338
      int[] bandIndices= new int[] { 0,1 };
339
      int[] indexes    = new int[2*IVY_N];
340
      float[][] corners= new float[][] { {0.05f,0.20f} };
341
      float[][] centers= new float[][] { {-0.0f,-0.0f,-1.0f} };
342

  
343 310
      for(int i=0; i<IVY_N; i++)
344 311
        {
345 312
        float sin = (float)Math.sin(i*angle);
......
359 326
        vert_indices[1][i] = i;
360 327
        }
361 328

  
362
      for(int i=0; i<2*IVY_N; i++)
329
      return new ObjectShape(vertices,vert_indices,getNumCubitFaces(), 1);
330
      }
331
    }
332

  
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

  
335
  public ObjectFaceShape getObjectFaceShape(int variant)
336
    {
337
    if( variant==0 )
338
      {
339
      int[] cornerIndices= new int[3*(IVY_N+1)+4];
340
      int[] centerIndices= new int[3*(IVY_N+1)+4];
341
      float[][] centers  = { {-1.0f,-1.0f,-1.0f} };
342
      float[][] corners  = { {0.05f,0.20f}, {0.04f,0.20f} };
343
      int[] bandIndices  = { 0,0,0,1,1,1 };
344
      float[][] bands    = { {+0.015f,20,0.2f,0.5f,7,1,2}, {-0.100f,20,0.2f,0.0f,2,1,2} };
345

  
346
      for(int i=0; i<3*(IVY_N+1); i++)
363 347
        {
364
        indexes[i] = -1;
348
        cornerIndices[i+4] = -1;
349
        centerIndices[i+4] = -1;
365 350
        }
366
      indexes[0] = indexes[IVY_N] = 0;
367 351

  
368
      float[][] bands =
369
        {
370
          {+0.03f,35,0.5f,0.5f,5,0,0},
371
          {-0.10f,45,0.5f,0.0f,2,0,0}
372
        };
352
      cornerIndices[0] = 1;
353
      cornerIndices[1] = 0;
354
      cornerIndices[2] = 0;
355
      cornerIndices[3] = 0;
356

  
357
      centerIndices[0] = 0;
358
      centerIndices[1] = 0;
359
      centerIndices[2] = 0;
360
      centerIndices[3] = 0;
361

  
362
      float C = 1-SQ2/2;
363
      float[] convexCenter = new float[] {-C,-C,-C};
364
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,convexCenter);
365
      }
366
    else
367
      {
368
      int[] bandIndices= new int[] { 0,1 };
369
      int[] indexes    = new int[2*IVY_N];
370
      float[][] corners= new float[][] { {0.05f,0.20f} };
371
      float[][] centers= new float[][] { {-0.0f,-0.0f,-1.0f} };
372
      float[][] bands  = { {+0.03f,35,0.5f,0.5f,5,0,0}, {-0.10f,45,0.5f,0.0f,2,0,0} };
373

  
374
      for(int i=0; i<2*IVY_N; i++) indexes[i] = -1;
375
      indexes[0] = indexes[IVY_N] = 0;
373 376

  
374
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,indexes,centers,indexes,getNumCubitFaces(), null, 1);
377
      return new ObjectFaceShape(bands,bandIndices,corners,indexes,centers,indexes, null);
375 378
      }
376 379
    }
377 380

  

Also available in: Unified diff