Project

General

Profile

Download (63 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 28b54fe3

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objects;
21

    
22
import org.distorted.library.effect.VertexEffect;
23
import org.distorted.library.effect.VertexEffectDeform;
24
import org.distorted.library.effect.VertexEffectMove;
25
import org.distorted.library.effect.VertexEffectRotate;
26
import org.distorted.library.effect.VertexEffectScale;
27
import org.distorted.library.mesh.MeshBase;
28
import org.distorted.library.mesh.MeshJoined;
29
import org.distorted.library.mesh.MeshPolygon;
30
import org.distorted.library.type.Static1D;
31
import org.distorted.library.type.Static3D;
32
import org.distorted.library.type.Static4D;
33

    
34
import static org.distorted.objects.TwistyMegaminx.MEGA_D;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
class FactoryCubit
39
  {
40
  static final float IVY_D = 0.003f;
41
  static final float IVY_C = 0.59f;
42
  static final float IVY_M = 0.35f;
43
  static final float REX_D = 0.2f;
44

    
45
  private static final float SQ2 = (float)Math.sqrt(2);
46
  private static final float SQ3 = (float)Math.sqrt(3);
47
  private static final float SQ5 = (float)Math.sqrt(5);
48
  private static final float SQ6 = (float)Math.sqrt(6);
49

    
50
  static final float SIN54   = (SQ5+1)/4;                         // sin(54 deg)
51
  static final float COS54   = (float)(Math.sqrt(10-2*SQ5)/4);    // cos(54 deg)
52

    
53
  static final float MINX_C0  = (SQ5-1)/4;
54
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
55
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
56
  static final float MINX_SC  = 0.5f;
57

    
58
  private static final int IVY_N = 8;
59

    
60
  private static final Static1D RADIUS = new Static1D(1);
61
  private static FactoryCubit mThis;
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

    
65
  private FactoryCubit()
66
    {
67

    
68
    }
69

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

    
72
  public static FactoryCubit getInstance()
73
    {
74
    if( mThis==null ) mThis = new FactoryCubit();
75

    
76
    return mThis;
77
    }
78

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80
// H - height of the band in the middle
81
// alpha - angle of the edge  [0,90]
82
// dist - often in a polygon the distance from edge to center is not 1, but something else.
83
// This is the distance.
84
// K - where to begin the second, much more flat part of the band. [0,1]
85
// N - number of bands. N>=3
86
//
87
// theory: two distinct parts to the band:
88
// 1) (0,B) - steep
89
// 2) (B,1) - flat
90
//
91
// In first part, we have y = g(x) ; in second - y = g(f(x)) where
92
//
93
// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha)
94
// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B)
95
// h(x) = R*(sin(alpha) - sin(x))
96
// R = H/(1-cos(alpha))
97
// D = H*sin(alpha)
98
// B = h(K*alpha)
99
//
100
// The N points are taken at:
101
//
102
// 1) in the second part, there are K2 = (N-3)/3 such points
103
// 2) in the first - K1 = (N-3) - K2
104
// 3) also, the 3 points 0,B,1
105
//
106
// so we have the sequence A[i] of N points
107
//
108
// 0
109
// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1)
110
// B
111
// (1-B)*(i+1)/(K2+1) + B   (i=0,i,...,K2-1)
112
// 1
113

    
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115

    
116
  private float f(float D, float B, float x)
117
    {
118
    return ((D-B)*x + B*(1-D))/(1-B);
119
    }
120

    
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122

    
123
  private float g(float R, float D, float x, float cosAlpha)
124
    {
125
    float d = x-D;
126
    return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
127
    }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

    
131
  private float h(float R, float sinAlpha, float x)
132
    {
133
    return R*(sinAlpha-(float)Math.sin(x));
134
    }
135

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

    
138
  private float[] computeBands(float H, int alpha, float dist, float K, int N)
139
    {
140
    float[] bands = new float[2*N];
141

    
142
    bands[0] = 1.0f;
143
    bands[1] = 0.0f;
144

    
145
    float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
146
    float sinBeta = (float)Math.sin(beta);
147
    float cosBeta = (float)Math.cos(beta);
148
    float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
149
    float D = R*sinBeta;
150
    float B = h(R,sinBeta,K*beta);
151

    
152
    if( D>1.0f )
153
      {
154
      for(int i=1; i<N; i++)
155
        {
156
        bands[2*i  ] = (float)(N-1-i)/(N-1);
157
        bands[2*i+1] = H*(1-bands[2*i]);
158
        }
159
      }
160
    else
161
      {
162
      int K2 = (int)((N-3)*K);
163
      int K1 = (N-3)-K2;
164

    
165
      for(int i=0; i<=K1; i++)
166
        {
167
        float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
168
        float x = h(R,sinBeta,angle);
169
        bands[2*i+2] = 1.0f - x;
170
        bands[2*i+3] = g(R,D,x,cosBeta);
171
        }
172

    
173
      for(int i=0; i<=K2; i++)
174
        {
175
        float x = (1-B)*(i+1)/(K2+1) + B;
176
        bands[2*K1+2 + 2*i+2] = 1.0f - x;
177
        bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
178
        }
179
      }
180

    
181
    bands[2*N-2] = 0.0f;
182
    bands[2*N-1] =    H;
183

    
184
    return bands;
185
    }
186

    
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

    
189
  private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
190
    {
191
    Static4D reg= new Static4D(0,0,0,regionRadius);
192

    
193
    float centX = center.get0();
194
    float centY = center.get1();
195
    float centZ = center.get2();
196

    
197
    for (Static3D vertex : vertices)
198
      {
199
      float x = strength*(centX - vertex.get0());
200
      float y = strength*(centY - vertex.get1());
201
      float z = strength*(centZ - vertex.get2());
202

    
203
      VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
204
      mesh.apply(effect);
205
      }
206
    }
207

    
208
///////////////////////////////////////////////////////////////////////////////////////////////////
209
// Compute (rx,ry) - coords of a point which is the result of rotation by angle 'radians' of the
210
// point (px,py) along axis Z. Center of rotation: (cx,cy). Rotation is counterclockwise!
211
// Write (rx,ry) to array[index] and array[index+1].
212

    
213
  private void writeVertex( float cx, float cy, float px, float py, float radians, float[] array, int index)
214
    {
215
    float vx = px-cx;
216
    float vy = py-cy;
217

    
218
    float sinA = (float)Math.sin(radians);
219
    float cosA = (float)Math.cos(radians);
220

    
221
    float rvx = vx*cosA - vy*sinA;
222
    float rvy = vx*sinA + vy*cosA;
223

    
224
    array[index  ] = rvx + cx;
225
    array[index+1] = rvy + cy;
226
    }
227

    
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

    
230
  MeshBase createFacesCube(int sizeIndex)
231
    {
232
    MeshBase[] meshes = new MeshPolygon[6];
233

    
234
    float E = 0.5f;
235
    int extraI, extraV, num;
236

    
237
    switch(sizeIndex)
238
      {
239
      case 0 : num = 6; extraI = 2; extraV = 2; break;
240
      case 1 : num = 5; extraI = 2; extraV = 2; break;
241
      case 2 : num = 5; extraI = 1; extraV = 2; break;
242
      default: num = 4; extraI = 1; extraV = 1; break;
243
      }
244

    
245
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
246
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
247

    
248
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
249
    meshes[0].setEffectAssociation(0,1,0);
250
    meshes[1] = meshes[0].copy(true);
251
    meshes[1].setEffectAssociation(0,2,0);
252
    meshes[2] = meshes[0].copy(true);
253
    meshes[2].setEffectAssociation(0,4,0);
254
    meshes[3] = meshes[0].copy(true);
255
    meshes[3].setEffectAssociation(0,8,0);
256
    meshes[4] = meshes[0].copy(true);
257
    meshes[4].setEffectAssociation(0,16,0);
258
    meshes[5] = meshes[0].copy(true);
259
    meshes[5].setEffectAssociation(0,32,0);
260

    
261
    return new MeshJoined(meshes);
262
    }
263

    
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265

    
266
  MeshBase createFacesSkewbCorner()
267
    {
268
    MeshBase[] meshes = new MeshBase[6];
269

    
270
    float E = 0.5f;
271
    float F = SQ2/2;
272
    float G = SQ6/16;
273
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
274
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
275

    
276
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
277
    meshes[0].setEffectAssociation(0,1,0);
278
    meshes[1] = meshes[0].copy(true);
279
    meshes[1].setEffectAssociation(0,2,0);
280
    meshes[2] = meshes[0].copy(true);
281
    meshes[2].setEffectAssociation(0,4,0);
282

    
283
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
284
    float[] bands1 = computeBands(0,0,1,0,3);
285

    
286
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
287
    meshes[3].setEffectAssociation(0,8,0);
288
    meshes[4] = meshes[3].copy(true);
289
    meshes[4].setEffectAssociation(0,16,0);
290
    meshes[5] = meshes[3].copy(true);
291
    meshes[5].setEffectAssociation(0,32,0);
292

    
293
    return new MeshJoined(meshes);
294
    }
295

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

    
298
  MeshBase createFacesSkewbFace()
299
    {
300
    MeshBase[] meshes = new MeshBase[5];
301

    
302
    float E = SQ2/4;
303
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
304
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
305

    
306
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
307
    meshes[0].setEffectAssociation(0,1,0);
308

    
309
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
310
    float[] bands1 = computeBands(0,0,1,0,3);
311

    
312
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
313
    meshes[1].setEffectAssociation(0,2,0);
314
    meshes[2] = meshes[1].copy(true);
315
    meshes[2].setEffectAssociation(0,4,0);
316
    meshes[3] = meshes[1].copy(true);
317
    meshes[3].setEffectAssociation(0,8,0);
318
    meshes[4] = meshes[1].copy(true);
319
    meshes[4].setEffectAssociation(0,16,0);
320

    
321
    return new MeshJoined(meshes);
322
    }
323

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

    
326
  MeshBase createFacesOcta()
327
    {
328
    MeshBase[] meshes = new MeshPolygon[8];
329

    
330
    float E = 0.75f;
331
    float F = 0.5f;
332
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
333
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
334

    
335
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
336
    meshes[0].setEffectAssociation(0,1,0);
337
    meshes[1] = meshes[0].copy(true);
338
    meshes[1].setEffectAssociation(0,2,0);
339
    meshes[2] = meshes[0].copy(true);
340
    meshes[2].setEffectAssociation(0,4,0);
341
    meshes[3] = meshes[0].copy(true);
342
    meshes[3].setEffectAssociation(0,8,0);
343
    meshes[4] = meshes[0].copy(true);
344
    meshes[4].setEffectAssociation(0,16,0);
345
    meshes[5] = meshes[0].copy(true);
346
    meshes[5].setEffectAssociation(0,32,0);
347
    meshes[6] = meshes[0].copy(true);
348
    meshes[6].setEffectAssociation(0,64,0);
349
    meshes[7] = meshes[0].copy(true);
350
    meshes[7].setEffectAssociation(0,128,0);
351

    
352
    return new MeshJoined(meshes);
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  MeshBase createFacesTetra()
358
    {
359
    MeshBase[] meshes = new MeshBase[4];
360

    
361
    float E = 0.75f;
362
    float F = 0.5f;
363
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
364
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
365

    
366
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
367
    meshes[0].setEffectAssociation(0,1,0);
368
    meshes[1] = meshes[0].copy(true);
369
    meshes[1].setEffectAssociation(0,2,0);
370
    meshes[2] = meshes[0].copy(true);
371
    meshes[2].setEffectAssociation(0,4,0);
372
    meshes[3] = meshes[0].copy(true);
373
    meshes[3].setEffectAssociation(0,8,0);
374

    
375
    return new MeshJoined(meshes);
376
    }
377

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

    
380
  MeshBase createFacesDino()
381
    {
382
    MeshBase[] meshes = new MeshPolygon[4];
383

    
384
    float E = 0.5f*SQ2;
385
    float F = 0.5f;
386
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
387
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
388

    
389
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
390
    meshes[0].setEffectAssociation(0,1,0);
391
    meshes[1] = meshes[0].copy(true);
392
    meshes[1].setEffectAssociation(0,2,0);
393

    
394
    float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
395
    float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3);
396

    
397
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
398
    meshes[2].setEffectAssociation(0,4,0);
399
    meshes[3] = meshes[2].copy(true);
400
    meshes[3].setEffectAssociation(0,8,0);
401

    
402
    return new MeshJoined(meshes);
403
    }
404

    
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406

    
407
  MeshBase createFacesHelicopterCorner()
408
    {
409
    MeshBase[] meshes = new MeshBase[6];
410

    
411
    float E = 0.5f;
412
    float F = SQ2/4;
413
    float G = 1.0f/12;
414
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
415
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
416

    
417
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
418
    meshes[0].setEffectAssociation(0,1,0);
419
    meshes[1] = meshes[0].copy(true);
420
    meshes[1].setEffectAssociation(0,2,0);
421
    meshes[2] = meshes[0].copy(true);
422
    meshes[2].setEffectAssociation(0,4,0);
423

    
424
    float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
425
    float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
426
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
427
    meshes[3].setEffectAssociation(0,8,0);
428
    meshes[4] = meshes[3].copy(true);
429
    meshes[4].setEffectAssociation(0,16,0);
430
    meshes[5] = meshes[3].copy(true);
431
    meshes[5].setEffectAssociation(0,32,0);
432

    
433
    return new MeshJoined(meshes);
434
    }
435

    
436
///////////////////////////////////////////////////////////////////////////////////////////////////
437

    
438
  MeshBase createFacesHelicopterFace()
439
    {
440
    MeshBase[] meshes = new MeshBase[4];
441

    
442
    float E = 0.5f;
443
    float F = SQ2/4;
444
    float G = 1.0f/12;
445
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
446
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
447

    
448
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
449
    meshes[0].setEffectAssociation(0,1,0);
450

    
451
    float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
452
    float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
453

    
454
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
455
    meshes[1].setEffectAssociation(0,2,0);
456

    
457
    float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
458

    
459
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
460
    meshes[2].setEffectAssociation(0,4,0);
461
    meshes[3] = meshes[2].copy(true);
462
    meshes[3].setEffectAssociation(0,8,0);
463

    
464
    return new MeshJoined(meshes);
465
    }
466

    
467
///////////////////////////////////////////////////////////////////////////////////////////////////
468

    
469
  MeshBase createFacesRediEdge()
470
    {
471
    MeshBase[] meshes = new MeshPolygon[6];
472

    
473
    float F = 0.25f;
474
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
475
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
476

    
477
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
478
    meshes[0].setEffectAssociation(0,1,0);
479
    meshes[1] = meshes[0].copy(true);
480
    meshes[1].setEffectAssociation(0,2,0);
481

    
482
    float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
483
    float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
484

    
485
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
486
    meshes[2].setEffectAssociation(0,4,0);
487
    meshes[3] = meshes[2].copy(true);
488
    meshes[3].setEffectAssociation(0,8,0);
489

    
490
    float X = 0.25f*SQ2;
491
    float Y = SQ6/16;
492
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
493

    
494
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
495
    meshes[4].setEffectAssociation(0,16,0);
496
    meshes[5] = meshes[4].copy(true);
497
    meshes[5].setEffectAssociation(0,32,0);
498

    
499
    return new MeshJoined(meshes);
500
    }
501

    
502
///////////////////////////////////////////////////////////////////////////////////////////////////
503

    
504
  MeshBase createFacesRediCorner()
505
    {
506
    MeshBase[] meshes = new MeshBase[6];
507

    
508
    float E = 0.5f;
509
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
510
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
511

    
512
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
513
    meshes[0].setEffectAssociation(0,1,0);
514
    meshes[1] = meshes[0].copy(true);
515
    meshes[1].setEffectAssociation(0,2,0);
516
    meshes[2] = meshes[0].copy(true);
517
    meshes[2].setEffectAssociation(0,4,0);
518

    
519
    float F = 0.5f;
520
    float X = 0.5f;
521
    float G = 0.72f;
522
    float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F };
523
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
524

    
525
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
526
    meshes[3].setEffectAssociation(0,8,0);
527
    meshes[4] = meshes[3].copy(true);
528
    meshes[4].setEffectAssociation(0,16,0);
529
    meshes[5] = meshes[3].copy(true);
530
    meshes[5].setEffectAssociation(0,32,0);
531

    
532
    return new MeshJoined(meshes);
533
    }
534

    
535
///////////////////////////////////////////////////////////////////////////////////////////////////
536

    
537
  MeshBase createFacesIvyCorner()
538
    {
539
    MeshBase[] meshes = new MeshBase[6];
540

    
541
    final float angle = (float)Math.PI/(2*IVY_N);
542
    final float CORR  = 1.0f - 2*IVY_D;
543
    final float DIST  = -0.5f*CORR + IVY_D;
544
    float[] vertices  = new float[2*(IVY_N+1)+6];
545

    
546
    vertices[0] = (0.5f-IVY_M) * IVY_C;
547
    vertices[1] = (DIST-IVY_M) * IVY_C;
548
    vertices[2] = (0.5f-IVY_M) * IVY_C;
549
    vertices[3] = (0.5f-IVY_M) * IVY_C;
550
    vertices[4] = (DIST-IVY_M) * IVY_C;
551
    vertices[5] = (0.5f-IVY_M) * IVY_C;
552

    
553
    for(int i=0; i<=IVY_N; i++)
554
      {
555
      float ang = (IVY_N-i)*angle;
556
      float sin = (float)Math.sin(ang);
557
      float cos = (float)Math.cos(ang);
558

    
559
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
560
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
561
      }
562

    
563
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
564
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
565

    
566
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
567
    meshes[0].setEffectAssociation(0,1,0);
568
    meshes[1] = meshes[0].copy(true);
569
    meshes[1].setEffectAssociation(0,2,0);
570
    meshes[2] = meshes[0].copy(true);
571
    meshes[2].setEffectAssociation(0,4,0);
572
    meshes[3] = new MeshPolygon(vertices,bands1,1,2);
573
    meshes[3].setEffectAssociation(0,8,0);
574
    meshes[4] = meshes[3].copy(true);
575
    meshes[4].setEffectAssociation(0,16,0);
576
    meshes[5] = meshes[3].copy(true);
577
    meshes[5].setEffectAssociation(0,32,0);
578

    
579
    return new MeshJoined(meshes);
580
    }
581

    
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583

    
584
  MeshBase createFacesIvyFace()
585
    {
586
    MeshBase[] meshes = new MeshBase[2];
587

    
588
    final float angle = (float)Math.PI/(2*IVY_N);
589
    final float CORR  = 1.0f - 2*IVY_D;
590
    float[] vertices = new float[4*IVY_N];
591

    
592
    for(int i=0; i<IVY_N; i++)
593
      {
594
      float sin = (float)Math.sin(i*angle);
595
      float cos = (float)Math.cos(i*angle);
596

    
597
      vertices[2*i          ] = CORR*(0.5f-cos);
598
      vertices[2*i+1        ] = CORR*(0.5f-sin);
599
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
600
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
601
      }
602

    
603
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
604
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
605

    
606
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
607
    meshes[0].setEffectAssociation(0,1,0);
608
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
609
    meshes[1].setEffectAssociation(0,2,0);
610

    
611
    return new MeshJoined(meshes);
612
    }
613

    
614
///////////////////////////////////////////////////////////////////////////////////////////////////
615

    
616
  MeshBase createFacesRexCorner()
617
    {
618
    MeshBase[] meshes = new MeshBase[2];
619

    
620
    float F = REX_D*SQ2;
621
    float G = (1-REX_D)*SQ2/2;
622
    float H = 0.1f;
623
    float J = +2*G/3 - H*G;
624

    
625
    float[] vertices = { -F/2, -G/3, +F/2, -G/3, H*F/2, J, -H*F/2, J};
626

    
627
    float[] bands0 = computeBands(+0.016f,10,G/3,0.5f,5);
628
    float[] bands1 = computeBands(-0.230f,45,G/3,0.0f,2);
629

    
630
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
631
    meshes[0].setEffectAssociation(0,1,0);
632
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
633
    meshes[1].setEffectAssociation(0,2,0);
634

    
635
    return new MeshJoined(meshes);
636
    }
637

    
638
///////////////////////////////////////////////////////////////////////////////////////////////////
639

    
640
  MeshBase createFacesRexFace()
641
    {
642
    MeshBase[] meshes = new MeshBase[2];
643

    
644
    float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
645

    
646
    float[] bands0 = computeBands(0.016f,10,REX_D/2,0.5f,5);
647
    float[] bands1 = computeBands(0.000f,45,REX_D/2,0.0f,2);
648

    
649
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
650
    meshes[0].setEffectAssociation(0,1,0);
651
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
652
    meshes[1].setEffectAssociation(0,2,0);
653

    
654
    return new MeshJoined(meshes);
655
    }
656

    
657
///////////////////////////////////////////////////////////////////////////////////////////////////
658

    
659
  MeshBase createFacesRexEdge()
660
    {
661
    MeshBase[] meshes = new MeshPolygon[6];
662

    
663
    float E = 0.5f - REX_D;
664
    float F = 0.5f;
665
    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
666
    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
667

    
668
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
669
    meshes[0].setEffectAssociation(0,1,0);
670
    meshes[1] = meshes[0].copy(true);
671
    meshes[1].setEffectAssociation(0,2,0);
672

    
673
    float G = (float)Math.sqrt(E*E+F*F);
674
    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
675
    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
676

    
677
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
678
    meshes[2].setEffectAssociation(0,4,0);
679
    meshes[3] = meshes[2].copy(true);
680
    meshes[3].setEffectAssociation(0,8,0);
681
    meshes[4] = meshes[2].copy(true);
682
    meshes[4].setEffectAssociation(0,16,0);
683
    meshes[5] = meshes[2].copy(true);
684
    meshes[5].setEffectAssociation(0,32,0);
685

    
686
    return new MeshJoined(meshes);
687
    }
688

    
689
///////////////////////////////////////////////////////////////////////////////////////////////////
690

    
691
  MeshBase createFacesKilominxCorner()
692
    {
693
    MeshBase[] meshes = new MeshPolygon[6];
694

    
695
    float X1= (SQ5+1)/8;
696
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
697
    float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
698
    float H = 0.5f* SIN54 /COS54  ;
699
    float X2= MINX_SC*H* SIN_HALFD;
700
    float Y3= MINX_SC*H/(2*COS_HALFD);
701
    float Y4= MINX_SC*H*(1/(2*COS_HALFD) - COS_HALFD);
702

    
703
    float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
704
    float[] bands0 = computeBands(0.04f,17,0.3f,0.2f,5);
705
    float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 };
706
    float[] bands1 = computeBands(0.00f, 0,0.25f,0.5f,5);
707

    
708
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
709
    meshes[0].setEffectAssociation(0, 1,0);
710
    meshes[1] = meshes[0].copy(true);
711
    meshes[1].setEffectAssociation(0, 2,0);
712
    meshes[2] = meshes[0].copy(true);
713
    meshes[2].setEffectAssociation(0, 4,0);
714
    meshes[3] = new MeshPolygon(vertices1, bands1, 1, 1);
715
    meshes[3].setEffectAssociation(0, 8,0);
716
    meshes[4] = meshes[3].copy(true);
717
    meshes[4].setEffectAssociation(0,16,0);
718
    meshes[5] = meshes[3].copy(true);
719
    meshes[5].setEffectAssociation(0,32,0);
720

    
721
    return new MeshJoined(meshes);
722
    }
723

    
724
///////////////////////////////////////////////////////////////////////////////////////////////////
725

    
726
  MeshBase createFacesMegaminxCorner()
727
    {
728
    MeshBase[] meshes = new MeshPolygon[6];
729

    
730
    float Y = COS54/(2*SIN54);
731

    
732
    float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
733
    float[] bands0 = computeBands(0.04f,34,0.3f,0.2f,5);
734
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
735

    
736
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
737
    meshes[0].setEffectAssociation(0, 1,0);
738
    meshes[1] = meshes[0].copy(true);
739
    meshes[1].setEffectAssociation(0, 2,0);
740
    meshes[2] = meshes[0].copy(true);
741
    meshes[2].setEffectAssociation(0, 4,0);
742
    meshes[3] = new MeshPolygon(vertices0, bands1, 1, 4);
743
    meshes[3].setEffectAssociation(0, 8,0);
744
    meshes[4] = meshes[3].copy(true);
745
    meshes[4].setEffectAssociation(0,16,0);
746
    meshes[5] = meshes[3].copy(true);
747
    meshes[5].setEffectAssociation(0,32,0);
748

    
749
    return new MeshJoined(meshes);
750
    }
751

    
752
///////////////////////////////////////////////////////////////////////////////////////////////////
753
// EFFECTS
754
///////////////////////////////////////////////////////////////////////////////////////////////////
755

    
756
  VertexEffect[] createVertexEffectsCube()
757
    {
758
    Static3D axisY   = new Static3D(0,1,0);
759
    Static3D axisX   = new Static3D(1,0,0);
760
    Static3D center  = new Static3D(0,0,0);
761
    Static1D angle90 = new Static1D(90);
762
    Static1D angle180= new Static1D(180);
763
    Static1D angle270= new Static1D(270);
764

    
765
    VertexEffect[] effect = new VertexEffect[6];
766

    
767
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
768
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
769
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
770
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
771
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
772
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
773

    
774
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
775
    effect[1].setMeshAssociation(32,-1);  // back
776
    effect[2].setMeshAssociation( 8,-1);  // bottom
777
    effect[3].setMeshAssociation( 4,-1);  // top
778
    effect[4].setMeshAssociation( 2,-1);  // left
779
    effect[5].setMeshAssociation( 1,-1);  // right
780

    
781
    return effect;
782
    }
783

    
784
///////////////////////////////////////////////////////////////////////////////////////////////////
785

    
786
  VertexEffect[] createVertexEffectsSkewbCorner()
787
    {
788
    float E = 0.5f;
789

    
790
    Static3D axisX  = new Static3D(1,0,0);
791
    Static3D axisY  = new Static3D(0,1,0);
792
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
793
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
794
    Static1D angle1 = new Static1D(+90);
795
    Static1D angle2 = new Static1D(-90);
796
    Static1D angle3 = new Static1D(-15);
797
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
798
    Static1D angle5 = new Static1D(120);
799
    Static1D angle6 = new Static1D(240);
800
    Static3D center1= new Static3D(0,0,0);
801
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
802
    Static3D move1  = new Static3D(-E/4,-E/4,0);
803
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
804

    
805
    VertexEffect[] effect = new VertexEffect[10];
806

    
807
    effect[0] = new VertexEffectMove(move1);
808
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
809
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
810
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
811
    effect[4] = new VertexEffectMove(move2);
812
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
813
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
814
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
815
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
816
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
817

    
818
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
819
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
820
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
821
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
822
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
823
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
824
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
825
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
826
    effect[8].setMeshAssociation(16,-1);  // mesh 4
827
    effect[9].setMeshAssociation(32,-1);  // mesh 5
828

    
829
    return effect;
830
    }
831

    
832
///////////////////////////////////////////////////////////////////////////////////////////////////
833

    
834
  VertexEffect[] createVertexEffectsSkewbFace()
835
    {
836
    Static3D center = new Static3D(0,0,0);
837
    Static3D axisX  = new Static3D(1,0,0);
838
    Static3D axisZ  = new Static3D(0,0,1);
839
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
840

    
841
    VertexEffect[] effect = new VertexEffect[6];
842

    
843
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
844
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
845
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
846
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
847
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
848
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
849

    
850
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
851
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
852
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
853
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
854
    effect[4].setMeshAssociation(16,-1);  // mesh 4
855
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
856

    
857
    return effect;
858
    }
859

    
860
///////////////////////////////////////////////////////////////////////////////////////////////////
861

    
862
  VertexEffect[] createVertexEffectsOcta()
863
    {
864
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
865
    Static1D angle1= new Static1D( 90);
866
    Static1D angle2= new Static1D(180);
867
    Static1D angle3= new Static1D(270);
868
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
869
    Static3D axisX = new Static3D(1,0,0);
870
    Static3D axisY = new Static3D(0,1,0);
871
    Static3D cent0 = new Static3D(0,0,0);
872
    Static3D cent1 = new Static3D(0,SQ2/2,0);
873
    Static3D flipY = new Static3D( 1,-1, 1);
874
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
875

    
876
    VertexEffect[] effect = new VertexEffect[7];
877

    
878
    effect[0] = new VertexEffectScale(scale);
879
    effect[1] = new VertexEffectMove(move1);
880
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
881
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
882
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
883
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
884
    effect[6] = new VertexEffectScale(flipY);
885

    
886
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
887
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
888
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
889
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
890

    
891
    return effect;
892
    }
893

    
894
///////////////////////////////////////////////////////////////////////////////////////////////////
895

    
896
  VertexEffect[] createVertexEffectsTetra()
897
    {
898
    Static3D flipZ = new Static3D( 1, 1,-1);
899
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
900
    Static1D angle1= new Static1D( 90);
901
    Static1D angle2= new Static1D(180);
902
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
903
    Static3D axisX = new Static3D(1,0,0);
904
    Static3D axisY = new Static3D(0,1,0);
905
    Static3D axisZ = new Static3D(0,0,1);
906
    Static3D cent0 = new Static3D(0,0,0);
907
    Static3D cent1 = new Static3D(0,SQ2/4,0);
908
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
909

    
910
    VertexEffect[] effect = new VertexEffect[7];
911

    
912
    effect[0] = new VertexEffectScale(scale);
913
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
914
    effect[2] = new VertexEffectMove(move1);
915
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
916
    effect[4] = new VertexEffectScale(flipZ);
917
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
918
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
919

    
920
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
921
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
922
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
923

    
924
    return effect;
925
    }
926

    
927
///////////////////////////////////////////////////////////////////////////////////////////////////
928

    
929
  VertexEffect[] createVertexEffectsDino()
930
    {
931
    float E = 0.5f*SQ2;
932
    float F = 0.5f;
933
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
934

    
935
    Static1D angle1 = new Static1D(-ANGLE);
936
    Static1D angle2 = new Static1D(+ANGLE);
937
    Static3D axisX  = new Static3D(1,0,0);
938
    Static3D axisY  = new Static3D(0,1,0);
939
    Static3D axisZ  = new Static3D(0,-1,1);
940
    Static3D center0= new Static3D(0,0,0);
941
    Static3D center1= new Static3D(0,-3*F,0);
942

    
943
    VertexEffect[] effect = new VertexEffect[10];
944

    
945
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
946
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
947
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
948
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
949
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
950
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
951
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
952
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
953
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
954
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
955

    
956
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
957
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
958
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
959
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
960
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
961
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
962
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
963
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
964
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
965
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
966

    
967
    return effect;
968
    }
969

    
970
///////////////////////////////////////////////////////////////////////////////////////////////////
971

    
972
  VertexEffect[] createVertexEffectsHelicopterCorner()
973
    {
974
    float E = 0.5f;
975

    
976
    Static3D axisX  = new Static3D(1,0,0);
977
    Static3D axisY  = new Static3D(0,1,0);
978
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
979
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
980
    Static1D angle1 = new Static1D(+90);
981
    Static1D angle2 = new Static1D(-90);
982
    Static1D angle3 = new Static1D(-135);
983
    Static1D angle4 = new Static1D(90);
984
    Static1D angle5 = new Static1D(120);
985
    Static1D angle6 = new Static1D(240);
986
    Static3D center1= new Static3D(0,0,0);
987
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
988
    Static3D move1  = new Static3D(-E/4,-E/4,0);
989
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
990

    
991
    VertexEffect[] effect = new VertexEffect[10];
992

    
993
    effect[0] = new VertexEffectMove(move1);
994
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
995
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
996
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
997
    effect[4] = new VertexEffectMove(move2);
998
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
999
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1000
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1001
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1002
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1003

    
1004
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1005
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1006
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1007
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1008
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1009
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1010
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1011
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1012
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1013
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1014

    
1015
    return effect;
1016
    }
1017

    
1018
///////////////////////////////////////////////////////////////////////////////////////////////////
1019

    
1020
  VertexEffect[] createVertexEffectsHelicopterFace()
1021
    {
1022
    float E = 0.5f;
1023
    float F = SQ2/4;
1024

    
1025
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1026
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1027
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1028
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1029
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1030
    Static1D angle1 = new Static1D(135);
1031
    Static1D angle2 = new Static1D(90);
1032
    Static1D angle3 = new Static1D(-90);
1033
    Static1D angle4 = new Static1D(-135);
1034
    Static3D axisX  = new Static3D(1,0,0);
1035
    Static3D axisY  = new Static3D(0,1,0);
1036
    Static3D axisZ  = new Static3D(0,0,1);
1037
    Static3D axis1  = new Static3D(1,-1,0);
1038
    Static3D center = new Static3D(0,0,0);
1039
    Static3D center1= new Static3D(-E/2,-E/2,0);
1040

    
1041
    VertexEffect[] effect = new VertexEffect[10];
1042

    
1043
    effect[0] = new VertexEffectMove(move0);
1044
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1045
    effect[2] = new VertexEffectMove(move1);
1046
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1047
    effect[4] = new VertexEffectMove(move2);
1048
    effect[5] = new VertexEffectMove(move3);
1049
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1050
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1051
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1052
    effect[9] = new VertexEffectMove(move4);
1053

    
1054
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1055
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1056
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1057
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1058
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1059
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1060
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1061
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1062
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1063
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1064

    
1065
    return effect;
1066
    }
1067

    
1068
///////////////////////////////////////////////////////////////////////////////////////////////////
1069

    
1070
  VertexEffect[] createVertexEffectsRediEdge()
1071
    {
1072
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1073
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1074
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1075
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1076
    Static3D flipZ = new Static3D(1,1,-1);
1077
    Static3D flipX = new Static3D(-1,1,1);
1078
    Static3D scale = new Static3D(2,2,2);
1079
    Static3D cent0 = new Static3D(0,0, 0);
1080
    Static3D cent1 = new Static3D(0,0, -1.5f);
1081
    Static3D axisX = new Static3D(1,0, 0);
1082
    Static3D axisY = new Static3D(0,1, 0);
1083
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1084
    Static1D angle1= new Static1D(90);
1085
    Static1D angle2= new Static1D(45);
1086
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1087

    
1088
    VertexEffect[] effect = new VertexEffect[12];
1089

    
1090
    effect[0] = new VertexEffectScale(scale);
1091
    effect[1] = new VertexEffectMove(move0);
1092
    effect[2] = new VertexEffectScale(flipZ);
1093
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1094
    effect[4] = new VertexEffectMove(move1);
1095
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1096
    effect[6] = new VertexEffectMove(move2);
1097
    effect[7] = new VertexEffectScale(flipX);
1098
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1099
    effect[9] = new VertexEffectMove(move3);
1100
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1101
    effect[11]= new VertexEffectScale(flipX);
1102

    
1103
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1104
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1105
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1106
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1107
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1108
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1109
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1110
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1111
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1112
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1113
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1114
    effect[11].setMeshAssociation(32,-1); // mesh 5
1115

    
1116
    return effect;
1117
    }
1118

    
1119
///////////////////////////////////////////////////////////////////////////////////////////////////
1120

    
1121
  VertexEffect[] createVertexEffectsRediCorner()
1122
    {
1123
    Static3D axisY   = new Static3D(0,1,0);
1124
    Static3D axisX   = new Static3D(1,0,0);
1125
    Static3D axisZ   = new Static3D(0,0,1);
1126
    Static3D center  = new Static3D(0,0,0);
1127
    Static1D angle90 = new Static1D(90);
1128
    Static1D angle270= new Static1D(270);
1129
    Static1D angle45 = new Static1D(-45);
1130
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1131

    
1132
    VertexEffect[] effect = new VertexEffect[7];
1133

    
1134
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1135
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1136
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1137
    effect[3] = new VertexEffectScale(scale);
1138
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1139
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1140
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1141

    
1142
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1143
    effect[1].setMeshAssociation( 2,-1);  // 1
1144
    effect[2].setMeshAssociation( 4,-1);  // 2
1145
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1146
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1147
    effect[5].setMeshAssociation(16,-1);  // 4
1148
    effect[6].setMeshAssociation(32,-1);  // 5
1149

    
1150
    return effect;
1151
    }
1152

    
1153
///////////////////////////////////////////////////////////////////////////////////////////////////
1154

    
1155
  VertexEffect[] createVertexEffectsIvyCorner()
1156
    {
1157
    Static3D axisX  = new Static3D(1,0,0);
1158
    Static3D axisY  = new Static3D(0,1,0);
1159
    Static1D angle1 = new Static1D(+90);
1160
    Static1D angle2 = new Static1D(-90);
1161
    Static3D center = new Static3D(0,0,0);
1162
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1163

    
1164
    VertexEffect[] effect = new VertexEffect[5];
1165

    
1166
    effect[0] = new VertexEffectScale(1/IVY_C);
1167
    effect[1] = new VertexEffectMove(move1);
1168
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1169
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1170
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1171

    
1172
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1173
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1174
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1175

    
1176
    return effect;
1177
    }
1178

    
1179
///////////////////////////////////////////////////////////////////////////////////////////////////
1180

    
1181
  VertexEffect[] createVertexEffectsRexEdge()
1182
    {
1183
    float E = 0.5f - REX_D;
1184
    float F = 0.5f;
1185
    float G = (float)Math.sqrt(E*E+F*F);
1186
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1187

    
1188
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1189
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1190

    
1191
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1192
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1193
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1194
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1195
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1196
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1197

    
1198
    Static1D angle180 = new Static1D(180);
1199
    Static1D angle90  = new Static1D( 90);
1200
    Static1D angle270 = new Static1D(270);
1201
    Static1D angle1   = new Static1D(+A);
1202
    Static1D angle2   = new Static1D(-A);
1203

    
1204
    VertexEffect[] effect = new VertexEffect[12];
1205

    
1206
    effect[0] = new VertexEffectMove(move1);
1207
    effect[1] = new VertexEffectMove(move2);
1208
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1209
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1210
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1211
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1212
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1213
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1214
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1215
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1216
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1217
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1218

    
1219
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1220
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1221
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1222
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1223
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1224
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1225
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1226
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1227
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1228
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1229
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1230
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1231

    
1232
    return effect;
1233
    }
1234

    
1235
///////////////////////////////////////////////////////////////////////////////////////////////////
1236

    
1237
  VertexEffect[] createVertexEffectsRexCorner()
1238
    {
1239
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1240
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1241
    Static1D angle = new Static1D(225);
1242

    
1243
    VertexEffect[] effect = new VertexEffect[1];
1244
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1245

    
1246
    return effect;
1247
    }
1248

    
1249
///////////////////////////////////////////////////////////////////////////////////////////////////
1250

    
1251
  VertexEffect[] createVertexEffectsKilominxCorner()
1252
    {
1253
    VertexEffect[] effect = new VertexEffect[10];
1254

    
1255
    float H = 0.5f*(SIN54 /COS54  );
1256
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1257
    float Y2= H/(2*COS_HALFD);
1258
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1259
    float sin18 = MINX_C0;
1260
    float cos18 = (float)(Math.sqrt(1-MINX_C0*MINX_C0));
1261
    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
1262

    
1263
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1264
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1265
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1266
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H* SIN_HALFD /(COS_HALFD*LEN));
1267

    
1268
    Static3D move1 = new Static3D(0,-Y1,0);
1269
    Static3D move2 = new Static3D(0,-Y2,0);
1270
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1271
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1272

    
1273
    Static1D angle1 = new Static1D(54);
1274
    Static1D angle2 = new Static1D(A/2+18);
1275
    Static1D angle3 = new Static1D(90);
1276
    Static1D angle4 = new Static1D(120);
1277
    Static1D angle5 = new Static1D(240);
1278
    Static1D angle6 = new Static1D(90-A/2);
1279

    
1280
    effect[0] = new VertexEffectMove(move1);
1281
    effect[1] = new VertexEffectScale(1/MINX_SC);
1282
    effect[2] = new VertexEffectMove(move2);
1283
    effect[3] = new VertexEffectRotate(angle1, axisZ, center);
1284
    effect[4] = new VertexEffectRotate(angle2, axisZ, center);
1285
    effect[5] = new VertexEffectRotate(angle3, axisA, center);
1286
    effect[6] = new VertexEffectMove(move3);
1287
    effect[7] = new VertexEffectRotate(angle4, axisC, center);
1288
    effect[8] = new VertexEffectRotate(angle5, axisC, center);
1289
    effect[9] = new VertexEffectRotate(angle6, axisY, center);
1290

    
1291
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1292
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1293
    effect[2].setMeshAssociation(56,-1);  // meshes 3,4,5
1294
    effect[3].setMeshAssociation( 7,-1);  // meshes 0,1,2
1295
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1296
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1297
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1298
    effect[7].setMeshAssociation(18,-1);  // meshes 1,4
1299
    effect[8].setMeshAssociation(36,-1);  // meshes 2,5
1300

    
1301
    return effect;
1302
    }
1303

    
1304
///////////////////////////////////////////////////////////////////////////////////////////////////
1305

    
1306
  VertexEffect[] createVertexEffectsMegaminxCorner(int numLayers)
1307
    {
1308
    VertexEffect[] effect = new VertexEffect[9];
1309

    
1310
    float Y = COS54/(2*SIN54);
1311
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1312

    
1313
    float sinA = (2*SIN54*SIN54-1)/COS54;
1314
    float cosA = (float)Math.sqrt(1-sinA*sinA);
1315
    float LEN  = 0.5f/SIN54;
1316
    float scale= (numLayers/6.0f-MEGA_D)/(LEN*0.5f*(numLayers-1));
1317

    
1318
    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
1319
    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
1320
    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
1321

    
1322
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1323
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1324

    
1325
    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
1326
    Static3D move2= new Static3D(0.0f, Y , 0.0f );
1327

    
1328
    Static1D angleD = new Static1D(A);
1329
    Static1D angleE = new Static1D(360-A);
1330
    Static1D angleF = new Static1D( (float)((180/Math.PI)*Math.asin(sinA) - 90) );
1331

    
1332
    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
1333
    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
1334
    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
1335
    effect[3] = new VertexEffectMove(move1);
1336
    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
1337
    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
1338
    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
1339
    effect[7] = new VertexEffectMove(move2);
1340
    effect[8] = new VertexEffectScale(scale);
1341

    
1342
    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
1343
    effect[1].setMeshAssociation( 16,-1);  // mesh 4
1344
    effect[2].setMeshAssociation( 32,-1);  // mesh 5
1345
    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
1346
    effect[4].setMeshAssociation(  1,-1);  // mesh 0
1347
    effect[5].setMeshAssociation(  2,-1);  // mesh 1
1348

    
1349
    return effect;
1350
    }
1351

    
1352
///////////////////////////////////////////////////////////////////////////////////////////////////
1353
// OBJECTS
1354
///////////////////////////////////////////////////////////////////////////////////////////////////
1355
// CUBE
1356

    
1357
  MeshBase createCubeMesh(int index)
1358
    {
1359
    MeshBase mesh = createFacesCube(index);
1360
    VertexEffect[] effects = createVertexEffectsCube();
1361
    for( VertexEffect effect : effects ) mesh.apply(effect);
1362

    
1363
    Static3D roundingCenter  = new Static3D(0,0,0);
1364
    Static3D[] vertices = new Static3D[8];
1365
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1366
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1367
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1368
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1369
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1370
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1371
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1372
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1373

    
1374
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1375

    
1376
    mesh.mergeEffComponents();
1377

    
1378
    return mesh;
1379
    }
1380

    
1381
///////////////////////////////////////////////////////////////////////////////////////////////////
1382
// SKEWB
1383

    
1384
  MeshBase createSkewbCornerMesh()
1385
    {
1386
    MeshBase mesh = createFacesSkewbCorner();
1387
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1388
    for( VertexEffect effect : effects ) mesh.apply(effect);
1389

    
1390
    float E = 0.5f;
1391
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1392

    
1393
    Static3D[] verticesType1 = new Static3D[1];
1394
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1395
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1396

    
1397
    Static3D[] verticesType2 = new Static3D[3];
1398
    verticesType2[0] = new Static3D(-E, 0, 0);
1399
    verticesType2[1] = new Static3D( 0,-E, 0);
1400
    verticesType2[2] = new Static3D( 0, 0,-E);
1401
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1402

    
1403
    mesh.mergeEffComponents();
1404

    
1405
    return mesh;
1406
    }
1407

    
1408
///////////////////////////////////////////////////////////////////////////////////////////////////
1409

    
1410
  MeshBase createSkewbFaceMesh()
1411
    {
1412
    MeshBase mesh = createFacesSkewbFace();
1413
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1414
    for( VertexEffect effect : effects ) mesh.apply(effect);
1415

    
1416
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1417
    float E = SQ2/4;
1418
    Static3D[] vertices = new Static3D[4];
1419
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1420
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1421
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1422
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1423
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1424

    
1425
    mesh.mergeEffComponents();
1426
    mesh.addEmptyTexComponent();
1427

    
1428
    return mesh;
1429
    }
1430

    
1431
///////////////////////////////////////////////////////////////////////////////////////////////////
1432
// SKEWB DIAMOND / PYRAMINX
1433

    
1434
  MeshBase createOctaMesh()
1435
    {
1436
    MeshBase mesh = createFacesOcta();
1437
    VertexEffect[] effects = createVertexEffectsOcta();
1438
    for( VertexEffect effect : effects ) mesh.apply(effect);
1439

    
1440
    Static3D roundingCenter = new Static3D(0,0,0);
1441
    Static3D[] vertices = new Static3D[6];
1442
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1443
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1444
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1445
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1446
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1447
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1448

    
1449
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1450

    
1451
    mesh.mergeEffComponents();
1452

    
1453
    return mesh;
1454
    }
1455

    
1456
///////////////////////////////////////////////////////////////////////////////////////////////////
1457

    
1458
  MeshBase createTetraMesh()
1459
    {
1460
    MeshBase mesh = createFacesTetra();
1461
    VertexEffect[] effects = createVertexEffectsTetra();
1462
    for( VertexEffect effect : effects ) mesh.apply(effect);
1463

    
1464
    Static3D roundingCenter = new Static3D(0,0,0);
1465
    Static3D[] verticesRound = new Static3D[4];
1466
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1467
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1468
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1469
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1470
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1471

    
1472
    mesh.mergeEffComponents();
1473
    mesh.addEmptyTexComponent();
1474
    mesh.addEmptyTexComponent();
1475
    mesh.addEmptyTexComponent();
1476
    mesh.addEmptyTexComponent();
1477

    
1478
    return mesh;
1479
    }
1480

    
1481
///////////////////////////////////////////////////////////////////////////////////////////////////
1482
// DINO
1483

    
1484
  MeshBase createDinoMesh()
1485
    {
1486
    MeshBase mesh = createFacesDino();
1487
    VertexEffect[] effects = createVertexEffectsDino();
1488
    for( VertexEffect effect : effects ) mesh.apply(effect);
1489

    
1490
    float F = 0.5f;
1491
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1492
    Static3D[] verticesRound = new Static3D[4];
1493
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1494
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1495
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1496
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1497
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1498

    
1499
    mesh.mergeEffComponents();
1500

    
1501
    return mesh;
1502
    }
1503

    
1504
///////////////////////////////////////////////////////////////////////////////////////////////////
1505
// Helicopter
1506

    
1507
  MeshBase createHelicopterCornerMesh()
1508
    {
1509
    MeshBase mesh = createFacesHelicopterCorner();
1510
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1511
    for( VertexEffect effect : effects ) mesh.apply(effect);
1512

    
1513
    float E = 0.5f;
1514
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1515

    
1516
    Static3D[] verticesType1 = new Static3D[1];
1517
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1518
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1519

    
1520
    Static3D[] verticesType2 = new Static3D[3];
1521
    verticesType2[0] = new Static3D(-E, 0, 0);
1522
    verticesType2[1] = new Static3D( 0,-E, 0);
1523
    verticesType2[2] = new Static3D( 0, 0,-E);
1524
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1525

    
1526
    mesh.mergeEffComponents();
1527

    
1528
    return mesh;
1529
    }
1530

    
1531
///////////////////////////////////////////////////////////////////////////////////////////////////
1532

    
1533
  MeshBase createHelicopterFaceMesh()
1534
    {
1535
    MeshBase mesh = createFacesHelicopterFace();
1536
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1537
    for( VertexEffect effect : effects ) mesh.apply(effect);
1538

    
1539
    float E = 0.5f;
1540
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1541

    
1542
    Static3D[] verticesType1 = new Static3D[1];
1543
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1544
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1545

    
1546
    Static3D[] verticesType2 = new Static3D[2];
1547
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1548
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1549
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1550

    
1551
    mesh.mergeEffComponents();
1552
    mesh.addEmptyTexComponent();
1553
    mesh.addEmptyTexComponent();
1554

    
1555
    return mesh;
1556
    }
1557

    
1558
///////////////////////////////////////////////////////////////////////////////////////////////////
1559
// Redi cube
1560

    
1561
  MeshBase createRediEdgeMesh()
1562
    {
1563
    MeshBase mesh = createFacesRediEdge();
1564
    VertexEffect[] effects = createVertexEffectsRediEdge();
1565
    for( VertexEffect effect : effects ) mesh.apply(effect);
1566

    
1567
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1568
    Static3D[] vertices = new Static3D[2];
1569
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1570
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1571
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1572

    
1573
    mesh.mergeEffComponents();
1574

    
1575
    return mesh;
1576
    }
1577

    
1578
///////////////////////////////////////////////////////////////////////////////////////////////////
1579

    
1580
  MeshBase createRediCornerMesh()
1581
    {
1582
    MeshBase mesh = createFacesRediCorner();
1583
    VertexEffect[] effects = createVertexEffectsRediCorner();
1584
    for( VertexEffect effect : effects ) mesh.apply(effect);
1585

    
1586
    Static3D center = new Static3D(0,0,0);
1587
    Static3D[] vertices = new Static3D[8];
1588
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1589
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1590
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1591
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1592
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1593
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1594
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1595
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1596

    
1597
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1598

    
1599
    mesh.mergeEffComponents();
1600

    
1601
    return mesh;
1602
    }
1603

    
1604
///////////////////////////////////////////////////////////////////////////////////////////////////
1605

    
1606
  MeshBase createIvyCornerMesh()
1607
    {
1608
    MeshBase mesh = createFacesIvyCorner();
1609
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1610
    for( VertexEffect effect : effects ) mesh.apply(effect);
1611

    
1612
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1613
    Static3D[] vertices = new Static3D[4];
1614
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1615
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1616
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1617
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1618

    
1619
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1620

    
1621
    mesh.mergeEffComponents();
1622

    
1623
    return mesh;
1624
    }
1625

    
1626
///////////////////////////////////////////////////////////////////////////////////////////////////
1627

    
1628
  MeshBase createIvyFaceMesh()
1629
    {
1630
    MeshBase mesh = createFacesIvyFace();
1631

    
1632
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1633
    Static3D[] vertices = new Static3D[2];
1634
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1635
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1636

    
1637
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1638

    
1639
    mesh.mergeEffComponents();
1640
    mesh.addEmptyTexComponent();
1641
    mesh.addEmptyTexComponent();
1642
    mesh.addEmptyTexComponent();
1643
    mesh.addEmptyTexComponent();
1644

    
1645
    return mesh;
1646
    }
1647

    
1648
///////////////////////////////////////////////////////////////////////////////////////////////////
1649

    
1650
  MeshBase createRexCornerMesh()
1651
    {
1652
    MeshBase mesh = createFacesRexCorner();
1653
    VertexEffect[] effects = createVertexEffectsRexCorner();
1654
    for( VertexEffect effect : effects ) mesh.apply(effect);
1655

    
1656
    final float G = (1-REX_D)/3;
1657
    Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
1658
    Static3D[] vertices = new Static3D[1];
1659
    vertices[0] = new Static3D(+G,-G,+0.0f);
1660
    roundCorners(mesh,center,vertices,0.10f,0.10f);
1661

    
1662
    mesh.mergeEffComponents();
1663
    mesh.addEmptyTexComponent();
1664
    mesh.addEmptyTexComponent();
1665
    mesh.addEmptyTexComponent();
1666
    mesh.addEmptyTexComponent();
1667

    
1668
    return mesh;
1669
    }
1670

    
1671
///////////////////////////////////////////////////////////////////////////////////////////////////
1672

    
1673
  MeshBase createRexFaceMesh()
1674
    {
1675
    MeshBase mesh = createFacesRexFace();
1676

    
1677
    mesh.mergeEffComponents();
1678
    mesh.addEmptyTexComponent();
1679
    mesh.addEmptyTexComponent();
1680
    mesh.addEmptyTexComponent();
1681
    mesh.addEmptyTexComponent();
1682

    
1683
    return mesh;
1684
    }
1685

    
1686
///////////////////////////////////////////////////////////////////////////////////////////////////
1687

    
1688
  MeshBase createRexEdgeMesh()
1689
    {
1690
    MeshBase mesh = createFacesRexEdge();
1691
    VertexEffect[] effects = createVertexEffectsRexEdge();
1692
    for( VertexEffect effect : effects ) mesh.apply(effect);
1693

    
1694
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1695
    Static3D[] vertices = new Static3D[2];
1696
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1697
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1698
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1699

    
1700
    mesh.mergeEffComponents();
1701

    
1702
    return mesh;
1703
    }
1704

    
1705
///////////////////////////////////////////////////////////////////////////////////////////////////
1706

    
1707
  MeshBase createKilominxCornerMesh()
1708
    {
1709
    MeshBase mesh = createFacesKilominxCorner();
1710
    VertexEffect[] effects = createVertexEffectsKilominxCorner();
1711
    for( VertexEffect effect : effects ) mesh.apply(effect);
1712

    
1713
    float A = (2*SQ3/3)* SIN54;
1714
    float B = 0.4f;
1715
    float X = SIN_HALFD * SIN54 *COS54  ;
1716
    float Y = SIN54 * SIN54 - 0.5f;
1717
    float Z = COS_HALFD* SIN54 *COS54  ;
1718

    
1719
    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
1720

    
1721
    Static3D[] vertices = new Static3D[4];
1722
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1723
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1724
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1725
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1726

    
1727
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1728

    
1729
    mesh.mergeEffComponents();
1730

    
1731
    return mesh;
1732
    }
1733

    
1734
///////////////////////////////////////////////////////////////////////////////////////////////////
1735

    
1736
  MeshBase createMegaminxCornerMesh(int numLayers)
1737
    {
1738
    MeshBase mesh = createFacesMegaminxCorner();
1739
    VertexEffect[] effects = createVertexEffectsMegaminxCorner(numLayers);
1740
    for( VertexEffect effect : effects ) mesh.apply(effect);
1741

    
1742
    float A = (2*SQ3/3)* SIN54;
1743
    float B = 0.4f;
1744
    float X = SIN_HALFD* SIN54 * COS54;
1745
    float Y = SIN54 * SIN54 - 0.5f;
1746
    float Z = COS_HALFD* SIN54 * COS54;
1747
    float S = 2*SIN54*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
1748

    
1749
    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
1750

    
1751
    Static3D[] vertices = new Static3D[4];
1752
    vertices[0] = new Static3D( 0.0f, 0.0f  , 0.0f);
1753
    vertices[1] = new Static3D( 0.0f,-0.5f*S, 0.0f);
1754
    vertices[2] = new Static3D(-X*S , Y*S   ,-Z*S );
1755
    vertices[3] = new Static3D(+X*S , Y*S   ,-Z*S );
1756

    
1757
    roundCorners(mesh,center,vertices,0.04f,0.10f);
1758

    
1759
    mesh.mergeEffComponents();
1760

    
1761
    return mesh;
1762
    }
1763
  }
(2-2/30)