Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 3d8237cc

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;
51
  static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
52
  static final float SIN18    = (SQ5-1)/4;
53
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
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

    
57
  static final float DIHEDRAL1= (float)(Math.acos(-SQ5/5)*180/Math.PI);
58
  static final float DIHEDRAL2= (float)((180/Math.PI)*Math.asin((2*SIN54*SIN54-1)/COS54) - 90);
59

    
60
  static final float MINX_SC  = 0.5f;
61

    
62
  private static final int IVY_N = 8;
63

    
64
  private static final Static1D RADIUS = new Static1D(1);
65
  private static FactoryCubit mThis;
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  private FactoryCubit()
70
    {
71

    
72
    }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75

    
76
  public static FactoryCubit getInstance()
77
    {
78
    if( mThis==null ) mThis = new FactoryCubit();
79

    
80
    return mThis;
81
    }
82

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

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

    
120
  private float f(float D, float B, float x)
121
    {
122
    return ((D-B)*x + B*(1-D))/(1-B);
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
  private float g(float R, float D, float x, float cosAlpha)
128
    {
129
    float d = x-D;
130
    return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  private float h(float R, float sinAlpha, float x)
136
    {
137
    return R*(sinAlpha-(float)Math.sin(x));
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
  private float[] computeBands(float H, int alpha, float dist, float K, int N)
143
    {
144
    float[] bands = new float[2*N];
145

    
146
    bands[0] = 1.0f;
147
    bands[1] = 0.0f;
148

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

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

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

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

    
185
    bands[2*N-2] = 0.0f;
186
    bands[2*N-1] =    H;
187

    
188
    return bands;
189
    }
190

    
191
///////////////////////////////////////////////////////////////////////////////////////////////////
192

    
193
  private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
194
    {
195
    Static4D reg= new Static4D(0,0,0,regionRadius);
196

    
197
    float centX = center.get0();
198
    float centY = center.get1();
199
    float centZ = center.get2();
200

    
201
    for (Static3D vertex : vertices)
202
      {
203
      float x = strength*(centX - vertex.get0());
204
      float y = strength*(centY - vertex.get1());
205
      float z = strength*(centZ - vertex.get2());
206

    
207
      VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
208
      mesh.apply(effect);
209
      }
210
    }
211

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

    
217
  private void writeVertex( float cx, float cy, float px, float py, float radians, float[] array, int index)
218
    {
219
    float vx = px-cx;
220
    float vy = py-cy;
221

    
222
    float sinA = (float)Math.sin(radians);
223
    float cosA = (float)Math.cos(radians);
224

    
225
    float rvx = vx*cosA - vy*sinA;
226
    float rvy = vx*sinA + vy*cosA;
227

    
228
    array[index  ] = rvx + cx;
229
    array[index+1] = rvy + cy;
230
    }
231

    
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233

    
234
  MeshBase createFacesCube(int sizeIndex)
235
    {
236
    MeshBase[] meshes = new MeshPolygon[6];
237

    
238
    float E = 0.5f;
239
    int extraI, extraV, num;
240

    
241
    switch(sizeIndex)
242
      {
243
      case 0 : num = 6; extraI = 2; extraV = 2; break;
244
      case 1 : num = 5; extraI = 2; extraV = 2; break;
245
      case 2 : num = 5; extraI = 1; extraV = 2; break;
246
      default: num = 4; extraI = 1; extraV = 1; break;
247
      }
248

    
249
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
250
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
251

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

    
265
    return new MeshJoined(meshes);
266
    }
267

    
268
///////////////////////////////////////////////////////////////////////////////////////////////////
269

    
270
  MeshBase createFacesSkewbCorner()
271
    {
272
    MeshBase[] meshes = new MeshBase[6];
273

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

    
280
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
281
    meshes[0].setEffectAssociation(0,1,0);
282
    meshes[1] = meshes[0].copy(true);
283
    meshes[1].setEffectAssociation(0,2,0);
284
    meshes[2] = meshes[0].copy(true);
285
    meshes[2].setEffectAssociation(0,4,0);
286

    
287
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
288
    float[] bands1 = computeBands(0,0,1,0,3);
289

    
290
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
291
    meshes[3].setEffectAssociation(0,8,0);
292
    meshes[4] = meshes[3].copy(true);
293
    meshes[4].setEffectAssociation(0,16,0);
294
    meshes[5] = meshes[3].copy(true);
295
    meshes[5].setEffectAssociation(0,32,0);
296

    
297
    return new MeshJoined(meshes);
298
    }
299

    
300
///////////////////////////////////////////////////////////////////////////////////////////////////
301

    
302
  MeshBase createFacesSkewbFace()
303
    {
304
    MeshBase[] meshes = new MeshBase[5];
305

    
306
    float E = SQ2/4;
307
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
308
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
309

    
310
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
311
    meshes[0].setEffectAssociation(0,1,0);
312

    
313
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
314
    float[] bands1 = computeBands(0,0,1,0,3);
315

    
316
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
317
    meshes[1].setEffectAssociation(0,2,0);
318
    meshes[2] = meshes[1].copy(true);
319
    meshes[2].setEffectAssociation(0,4,0);
320
    meshes[3] = meshes[1].copy(true);
321
    meshes[3].setEffectAssociation(0,8,0);
322
    meshes[4] = meshes[1].copy(true);
323
    meshes[4].setEffectAssociation(0,16,0);
324

    
325
    return new MeshJoined(meshes);
326
    }
327

    
328
///////////////////////////////////////////////////////////////////////////////////////////////////
329

    
330
  MeshBase createFacesOcta()
331
    {
332
    MeshBase[] meshes = new MeshPolygon[8];
333

    
334
    float E = 0.75f;
335
    float F = 0.5f;
336
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
337
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
338

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

    
356
    return new MeshJoined(meshes);
357
    }
358

    
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360

    
361
  MeshBase createFacesTetra()
362
    {
363
    MeshBase[] meshes = new MeshBase[4];
364

    
365
    float E = 0.75f;
366
    float F = 0.5f;
367
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
368
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
369

    
370
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
371
    meshes[0].setEffectAssociation(0,1,0);
372
    meshes[1] = meshes[0].copy(true);
373
    meshes[1].setEffectAssociation(0,2,0);
374
    meshes[2] = meshes[0].copy(true);
375
    meshes[2].setEffectAssociation(0,4,0);
376
    meshes[3] = meshes[0].copy(true);
377
    meshes[3].setEffectAssociation(0,8,0);
378

    
379
    return new MeshJoined(meshes);
380
    }
381

    
382
///////////////////////////////////////////////////////////////////////////////////////////////////
383

    
384
  MeshBase createFacesDino()
385
    {
386
    MeshBase[] meshes = new MeshPolygon[4];
387

    
388
    float E = 0.5f*SQ2;
389
    float F = 0.5f;
390
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
391
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
392

    
393
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
394
    meshes[0].setEffectAssociation(0,1,0);
395
    meshes[1] = meshes[0].copy(true);
396
    meshes[1].setEffectAssociation(0,2,0);
397

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

    
401
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
402
    meshes[2].setEffectAssociation(0,4,0);
403
    meshes[3] = meshes[2].copy(true);
404
    meshes[3].setEffectAssociation(0,8,0);
405

    
406
    return new MeshJoined(meshes);
407
    }
408

    
409
///////////////////////////////////////////////////////////////////////////////////////////////////
410

    
411
  MeshBase createFacesHelicopterCorner()
412
    {
413
    MeshBase[] meshes = new MeshBase[6];
414

    
415
    float E = 0.5f;
416
    float F = SQ2/4;
417
    float G = 1.0f/12;
418
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
419
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
420

    
421
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
422
    meshes[0].setEffectAssociation(0,1,0);
423
    meshes[1] = meshes[0].copy(true);
424
    meshes[1].setEffectAssociation(0,2,0);
425
    meshes[2] = meshes[0].copy(true);
426
    meshes[2].setEffectAssociation(0,4,0);
427

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

    
437
    return new MeshJoined(meshes);
438
    }
439

    
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441

    
442
  MeshBase createFacesHelicopterFace()
443
    {
444
    MeshBase[] meshes = new MeshBase[4];
445

    
446
    float E = 0.5f;
447
    float F = SQ2/4;
448
    float G = 1.0f/12;
449
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
450
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
451

    
452
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
453
    meshes[0].setEffectAssociation(0,1,0);
454

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

    
458
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
459
    meshes[1].setEffectAssociation(0,2,0);
460

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

    
463
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
464
    meshes[2].setEffectAssociation(0,4,0);
465
    meshes[3] = meshes[2].copy(true);
466
    meshes[3].setEffectAssociation(0,8,0);
467

    
468
    return new MeshJoined(meshes);
469
    }
470

    
471
///////////////////////////////////////////////////////////////////////////////////////////////////
472

    
473
  MeshBase createFacesRediEdge()
474
    {
475
    MeshBase[] meshes = new MeshPolygon[6];
476

    
477
    float F = 0.25f;
478
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
479
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
480

    
481
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
482
    meshes[0].setEffectAssociation(0,1,0);
483
    meshes[1] = meshes[0].copy(true);
484
    meshes[1].setEffectAssociation(0,2,0);
485

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

    
489
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
490
    meshes[2].setEffectAssociation(0,4,0);
491
    meshes[3] = meshes[2].copy(true);
492
    meshes[3].setEffectAssociation(0,8,0);
493

    
494
    float X = 0.25f*SQ2;
495
    float Y = SQ6/16;
496
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
497

    
498
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
499
    meshes[4].setEffectAssociation(0,16,0);
500
    meshes[5] = meshes[4].copy(true);
501
    meshes[5].setEffectAssociation(0,32,0);
502

    
503
    return new MeshJoined(meshes);
504
    }
505

    
506
///////////////////////////////////////////////////////////////////////////////////////////////////
507

    
508
  MeshBase createFacesRediCorner()
509
    {
510
    MeshBase[] meshes = new MeshBase[6];
511

    
512
    float E = 0.5f;
513
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
514
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
515

    
516
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
517
    meshes[0].setEffectAssociation(0,1,0);
518
    meshes[1] = meshes[0].copy(true);
519
    meshes[1].setEffectAssociation(0,2,0);
520
    meshes[2] = meshes[0].copy(true);
521
    meshes[2].setEffectAssociation(0,4,0);
522

    
523
    float F = 0.5f;
524
    float X = 0.5f;
525
    float G = 0.72f;
526
    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 };
527
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
528

    
529
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
530
    meshes[3].setEffectAssociation(0,8,0);
531
    meshes[4] = meshes[3].copy(true);
532
    meshes[4].setEffectAssociation(0,16,0);
533
    meshes[5] = meshes[3].copy(true);
534
    meshes[5].setEffectAssociation(0,32,0);
535

    
536
    return new MeshJoined(meshes);
537
    }
538

    
539
///////////////////////////////////////////////////////////////////////////////////////////////////
540

    
541
  MeshBase createFacesIvyCorner()
542
    {
543
    MeshBase[] meshes = new MeshBase[6];
544

    
545
    final float angle = (float)Math.PI/(2*IVY_N);
546
    final float CORR  = 1.0f - 2*IVY_D;
547
    final float DIST  = -0.5f*CORR + IVY_D;
548
    float[] vertices  = new float[2*(IVY_N+1)+6];
549

    
550
    vertices[0] = (0.5f-IVY_M) * IVY_C;
551
    vertices[1] = (DIST-IVY_M) * IVY_C;
552
    vertices[2] = (0.5f-IVY_M) * IVY_C;
553
    vertices[3] = (0.5f-IVY_M) * IVY_C;
554
    vertices[4] = (DIST-IVY_M) * IVY_C;
555
    vertices[5] = (0.5f-IVY_M) * IVY_C;
556

    
557
    for(int i=0; i<=IVY_N; i++)
558
      {
559
      float ang = (IVY_N-i)*angle;
560
      float sin = (float)Math.sin(ang);
561
      float cos = (float)Math.cos(ang);
562

    
563
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
564
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
565
      }
566

    
567
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
568
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
569

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

    
583
    return new MeshJoined(meshes);
584
    }
585

    
586
///////////////////////////////////////////////////////////////////////////////////////////////////
587

    
588
  MeshBase createFacesIvyFace()
589
    {
590
    MeshBase[] meshes = new MeshBase[2];
591

    
592
    final float angle = (float)Math.PI/(2*IVY_N);
593
    final float CORR  = 1.0f - 2*IVY_D;
594
    float[] vertices = new float[4*IVY_N];
595

    
596
    for(int i=0; i<IVY_N; i++)
597
      {
598
      float sin = (float)Math.sin(i*angle);
599
      float cos = (float)Math.cos(i*angle);
600

    
601
      vertices[2*i          ] = CORR*(0.5f-cos);
602
      vertices[2*i+1        ] = CORR*(0.5f-sin);
603
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
604
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
605
      }
606

    
607
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
608
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
609

    
610
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
611
    meshes[0].setEffectAssociation(0,1,0);
612
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
613
    meshes[1].setEffectAssociation(0,2,0);
614

    
615
    return new MeshJoined(meshes);
616
    }
617

    
618
///////////////////////////////////////////////////////////////////////////////////////////////////
619

    
620
  MeshBase createFacesRexCorner()
621
    {
622
    MeshBase[] meshes = new MeshBase[2];
623

    
624
    float F = REX_D*SQ2;
625
    float G = (1-REX_D)*SQ2/2;
626
    float H = 0.1f;
627
    float J = +2*G/3 - H*G;
628

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

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

    
634
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
635
    meshes[0].setEffectAssociation(0,1,0);
636
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
637
    meshes[1].setEffectAssociation(0,2,0);
638

    
639
    return new MeshJoined(meshes);
640
    }
641

    
642
///////////////////////////////////////////////////////////////////////////////////////////////////
643

    
644
  MeshBase createFacesRexFace()
645
    {
646
    MeshBase[] meshes = new MeshBase[2];
647

    
648
    float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
649

    
650
    float[] bands0 = computeBands(0.016f,10,REX_D/2,0.5f,5);
651
    float[] bands1 = computeBands(0.000f,45,REX_D/2,0.0f,2);
652

    
653
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
654
    meshes[0].setEffectAssociation(0,1,0);
655
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
656
    meshes[1].setEffectAssociation(0,2,0);
657

    
658
    return new MeshJoined(meshes);
659
    }
660

    
661
///////////////////////////////////////////////////////////////////////////////////////////////////
662

    
663
  MeshBase createFacesRexEdge()
664
    {
665
    MeshBase[] meshes = new MeshPolygon[6];
666

    
667
    float E = 0.5f - REX_D;
668
    float F = 0.5f;
669
    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
670
    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
671

    
672
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
673
    meshes[0].setEffectAssociation(0,1,0);
674
    meshes[1] = meshes[0].copy(true);
675
    meshes[1].setEffectAssociation(0,2,0);
676

    
677
    float G = (float)Math.sqrt(E*E+F*F);
678
    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
679
    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
680

    
681
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
682
    meshes[2].setEffectAssociation(0,4,0);
683
    meshes[3] = meshes[2].copy(true);
684
    meshes[3].setEffectAssociation(0,8,0);
685
    meshes[4] = meshes[2].copy(true);
686
    meshes[4].setEffectAssociation(0,16,0);
687
    meshes[5] = meshes[2].copy(true);
688
    meshes[5].setEffectAssociation(0,32,0);
689

    
690
    return new MeshJoined(meshes);
691
    }
692

    
693
///////////////////////////////////////////////////////////////////////////////////////////////////
694

    
695
  MeshBase createFacesKilominxCorner()
696
    {
697
    MeshBase[] meshes = new MeshPolygon[6];
698

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

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

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

    
725
    return new MeshJoined(meshes);
726
    }
727

    
728
///////////////////////////////////////////////////////////////////////////////////////////////////
729

    
730
  MeshBase createFacesMegaminxCorner()
731
    {
732
    MeshBase[] meshes = new MeshPolygon[6];
733

    
734
    float Y = COS54/(2*SIN54);
735

    
736
    float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
737
    float[] bands0 = computeBands(0.04f,34,0.3f,0.2f,5);
738
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
739

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

    
753
    return new MeshJoined(meshes);
754
    }
755

    
756
///////////////////////////////////////////////////////////////////////////////////////////////////
757

    
758
  MeshBase createFacesMegaminxEdge(float width, float height)
759
    {
760
    MeshBase[] meshes = new MeshPolygon[6];
761

    
762
    float D = height/COS18;
763
    float W = D*SIN18;
764

    
765
    float Y1 = 0.5f*width;
766
    float Y2 = 0.5f*width + W;
767
    float Y3 = 0.5f*width + 2*W;
768
    float X2 = D*SIN54;
769
    float X1 = 0.5f*height;
770
    float Y4 = D*COS54;
771

    
772
    float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
773
    float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 };
774
    float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 };
775

    
776
    float[] bands0 = computeBands(0.04f,34,  X1,0.2f,5);
777
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
778

    
779
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
780
    meshes[0].setEffectAssociation(0, 1,0);
781
    meshes[1] = meshes[0].copy(true);
782
    meshes[1].setEffectAssociation(0, 2,0);
783
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 4);
784
    meshes[2].setEffectAssociation(0, 4,0);
785
    meshes[3] = meshes[2].copy(true);
786
    meshes[3].setEffectAssociation(0, 8,0);
787
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 4);
788
    meshes[4].setEffectAssociation(0,16,0);
789
    meshes[5] = meshes[4].copy(true);
790
    meshes[5].setEffectAssociation(0,32,0);
791

    
792
    return new MeshJoined(meshes);
793
    }
794

    
795
///////////////////////////////////////////////////////////////////////////////////////////////////
796
// EFFECTS
797
///////////////////////////////////////////////////////////////////////////////////////////////////
798

    
799
  VertexEffect[] createVertexEffectsCube()
800
    {
801
    Static3D axisY   = new Static3D(0,1,0);
802
    Static3D axisX   = new Static3D(1,0,0);
803
    Static3D center  = new Static3D(0,0,0);
804
    Static1D angle90 = new Static1D(90);
805
    Static1D angle180= new Static1D(180);
806
    Static1D angle270= new Static1D(270);
807

    
808
    VertexEffect[] effect = new VertexEffect[6];
809

    
810
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
811
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
812
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
813
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
814
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
815
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
816

    
817
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
818
    effect[1].setMeshAssociation(32,-1);  // back
819
    effect[2].setMeshAssociation( 8,-1);  // bottom
820
    effect[3].setMeshAssociation( 4,-1);  // top
821
    effect[4].setMeshAssociation( 2,-1);  // left
822
    effect[5].setMeshAssociation( 1,-1);  // right
823

    
824
    return effect;
825
    }
826

    
827
///////////////////////////////////////////////////////////////////////////////////////////////////
828

    
829
  VertexEffect[] createVertexEffectsSkewbCorner()
830
    {
831
    float E = 0.5f;
832

    
833
    Static3D axisX  = new Static3D(1,0,0);
834
    Static3D axisY  = new Static3D(0,1,0);
835
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
836
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
837
    Static1D angle1 = new Static1D(+90);
838
    Static1D angle2 = new Static1D(-90);
839
    Static1D angle3 = new Static1D(-15);
840
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
841
    Static1D angle5 = new Static1D(120);
842
    Static1D angle6 = new Static1D(240);
843
    Static3D center1= new Static3D(0,0,0);
844
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
845
    Static3D move1  = new Static3D(-E/4,-E/4,0);
846
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
847

    
848
    VertexEffect[] effect = new VertexEffect[10];
849

    
850
    effect[0] = new VertexEffectMove(move1);
851
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
852
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
853
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
854
    effect[4] = new VertexEffectMove(move2);
855
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
856
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
857
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
858
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
859
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
860

    
861
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
862
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
863
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
864
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
865
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
866
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
867
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
868
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
869
    effect[8].setMeshAssociation(16,-1);  // mesh 4
870
    effect[9].setMeshAssociation(32,-1);  // mesh 5
871

    
872
    return effect;
873
    }
874

    
875
///////////////////////////////////////////////////////////////////////////////////////////////////
876

    
877
  VertexEffect[] createVertexEffectsSkewbFace()
878
    {
879
    Static3D center = new Static3D(0,0,0);
880
    Static3D axisX  = new Static3D(1,0,0);
881
    Static3D axisZ  = new Static3D(0,0,1);
882
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
883

    
884
    VertexEffect[] effect = new VertexEffect[6];
885

    
886
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
887
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
888
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
889
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
890
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
891
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
892

    
893
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
894
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
895
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
896
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
897
    effect[4].setMeshAssociation(16,-1);  // mesh 4
898
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
899

    
900
    return effect;
901
    }
902

    
903
///////////////////////////////////////////////////////////////////////////////////////////////////
904

    
905
  VertexEffect[] createVertexEffectsOcta()
906
    {
907
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
908
    Static1D angle1= new Static1D( 90);
909
    Static1D angle2= new Static1D(180);
910
    Static1D angle3= new Static1D(270);
911
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
912
    Static3D axisX = new Static3D(1,0,0);
913
    Static3D axisY = new Static3D(0,1,0);
914
    Static3D cent0 = new Static3D(0,0,0);
915
    Static3D cent1 = new Static3D(0,SQ2/2,0);
916
    Static3D flipY = new Static3D( 1,-1, 1);
917
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
918

    
919
    VertexEffect[] effect = new VertexEffect[7];
920

    
921
    effect[0] = new VertexEffectScale(scale);
922
    effect[1] = new VertexEffectMove(move1);
923
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
924
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
925
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
926
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
927
    effect[6] = new VertexEffectScale(flipY);
928

    
929
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
930
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
931
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
932
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
933

    
934
    return effect;
935
    }
936

    
937
///////////////////////////////////////////////////////////////////////////////////////////////////
938

    
939
  VertexEffect[] createVertexEffectsTetra()
940
    {
941
    Static3D flipZ = new Static3D( 1, 1,-1);
942
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
943
    Static1D angle1= new Static1D( 90);
944
    Static1D angle2= new Static1D(180);
945
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
946
    Static3D axisX = new Static3D(1,0,0);
947
    Static3D axisY = new Static3D(0,1,0);
948
    Static3D axisZ = new Static3D(0,0,1);
949
    Static3D cent0 = new Static3D(0,0,0);
950
    Static3D cent1 = new Static3D(0,SQ2/4,0);
951
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
952

    
953
    VertexEffect[] effect = new VertexEffect[7];
954

    
955
    effect[0] = new VertexEffectScale(scale);
956
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
957
    effect[2] = new VertexEffectMove(move1);
958
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
959
    effect[4] = new VertexEffectScale(flipZ);
960
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
961
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
962

    
963
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
964
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
965
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
966

    
967
    return effect;
968
    }
969

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

    
972
  VertexEffect[] createVertexEffectsDino()
973
    {
974
    float E = 0.5f*SQ2;
975
    float F = 0.5f;
976
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
977

    
978
    Static1D angle1 = new Static1D(-ANGLE);
979
    Static1D angle2 = new Static1D(+ANGLE);
980
    Static3D axisX  = new Static3D(1,0,0);
981
    Static3D axisY  = new Static3D(0,1,0);
982
    Static3D axisZ  = new Static3D(0,-1,1);
983
    Static3D center0= new Static3D(0,0,0);
984
    Static3D center1= new Static3D(0,-3*F,0);
985

    
986
    VertexEffect[] effect = new VertexEffect[10];
987

    
988
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
989
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
990
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
991
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
992
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
993
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
994
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
995
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
996
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
997
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
998

    
999
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
1000
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
1001
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
1002
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
1003
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
1004
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
1005
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1006
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
1007
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
1008
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
1009

    
1010
    return effect;
1011
    }
1012

    
1013
///////////////////////////////////////////////////////////////////////////////////////////////////
1014

    
1015
  VertexEffect[] createVertexEffectsHelicopterCorner()
1016
    {
1017
    float E = 0.5f;
1018

    
1019
    Static3D axisX  = new Static3D(1,0,0);
1020
    Static3D axisY  = new Static3D(0,1,0);
1021
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
1022
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
1023
    Static1D angle1 = new Static1D(+90);
1024
    Static1D angle2 = new Static1D(-90);
1025
    Static1D angle3 = new Static1D(-135);
1026
    Static1D angle4 = new Static1D(90);
1027
    Static1D angle5 = new Static1D(120);
1028
    Static1D angle6 = new Static1D(240);
1029
    Static3D center1= new Static3D(0,0,0);
1030
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
1031
    Static3D move1  = new Static3D(-E/4,-E/4,0);
1032
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
1033

    
1034
    VertexEffect[] effect = new VertexEffect[10];
1035

    
1036
    effect[0] = new VertexEffectMove(move1);
1037
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
1038
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
1039
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
1040
    effect[4] = new VertexEffectMove(move2);
1041
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
1042
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1043
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1044
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1045
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1046

    
1047
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1048
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1049
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1050
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1051
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1052
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1053
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1054
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1055
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1056
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1057

    
1058
    return effect;
1059
    }
1060

    
1061
///////////////////////////////////////////////////////////////////////////////////////////////////
1062

    
1063
  VertexEffect[] createVertexEffectsHelicopterFace()
1064
    {
1065
    float E = 0.5f;
1066
    float F = SQ2/4;
1067

    
1068
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1069
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1070
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1071
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1072
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1073
    Static1D angle1 = new Static1D(135);
1074
    Static1D angle2 = new Static1D(90);
1075
    Static1D angle3 = new Static1D(-90);
1076
    Static1D angle4 = new Static1D(-135);
1077
    Static3D axisX  = new Static3D(1,0,0);
1078
    Static3D axisY  = new Static3D(0,1,0);
1079
    Static3D axisZ  = new Static3D(0,0,1);
1080
    Static3D axis1  = new Static3D(1,-1,0);
1081
    Static3D center = new Static3D(0,0,0);
1082
    Static3D center1= new Static3D(-E/2,-E/2,0);
1083

    
1084
    VertexEffect[] effect = new VertexEffect[10];
1085

    
1086
    effect[0] = new VertexEffectMove(move0);
1087
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1088
    effect[2] = new VertexEffectMove(move1);
1089
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1090
    effect[4] = new VertexEffectMove(move2);
1091
    effect[5] = new VertexEffectMove(move3);
1092
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1093
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1094
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1095
    effect[9] = new VertexEffectMove(move4);
1096

    
1097
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1098
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1099
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1100
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1101
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1102
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1103
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1104
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1105
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1106
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1107

    
1108
    return effect;
1109
    }
1110

    
1111
///////////////////////////////////////////////////////////////////////////////////////////////////
1112

    
1113
  VertexEffect[] createVertexEffectsRediEdge()
1114
    {
1115
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1116
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1117
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1118
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1119
    Static3D flipZ = new Static3D(1,1,-1);
1120
    Static3D flipX = new Static3D(-1,1,1);
1121
    Static3D scale = new Static3D(2,2,2);
1122
    Static3D cent0 = new Static3D(0,0, 0);
1123
    Static3D cent1 = new Static3D(0,0, -1.5f);
1124
    Static3D axisX = new Static3D(1,0, 0);
1125
    Static3D axisY = new Static3D(0,1, 0);
1126
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1127
    Static1D angle1= new Static1D(90);
1128
    Static1D angle2= new Static1D(45);
1129
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1130

    
1131
    VertexEffect[] effect = new VertexEffect[12];
1132

    
1133
    effect[0] = new VertexEffectScale(scale);
1134
    effect[1] = new VertexEffectMove(move0);
1135
    effect[2] = new VertexEffectScale(flipZ);
1136
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1137
    effect[4] = new VertexEffectMove(move1);
1138
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1139
    effect[6] = new VertexEffectMove(move2);
1140
    effect[7] = new VertexEffectScale(flipX);
1141
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1142
    effect[9] = new VertexEffectMove(move3);
1143
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1144
    effect[11]= new VertexEffectScale(flipX);
1145

    
1146
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1147
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1148
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1149
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1150
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1151
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1152
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1153
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1154
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1155
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1156
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1157
    effect[11].setMeshAssociation(32,-1); // mesh 5
1158

    
1159
    return effect;
1160
    }
1161

    
1162
///////////////////////////////////////////////////////////////////////////////////////////////////
1163

    
1164
  VertexEffect[] createVertexEffectsRediCorner()
1165
    {
1166
    Static3D axisY   = new Static3D(0,1,0);
1167
    Static3D axisX   = new Static3D(1,0,0);
1168
    Static3D axisZ   = new Static3D(0,0,1);
1169
    Static3D center  = new Static3D(0,0,0);
1170
    Static1D angle90 = new Static1D(90);
1171
    Static1D angle270= new Static1D(270);
1172
    Static1D angle45 = new Static1D(-45);
1173
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1174

    
1175
    VertexEffect[] effect = new VertexEffect[7];
1176

    
1177
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1178
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1179
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1180
    effect[3] = new VertexEffectScale(scale);
1181
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1182
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1183
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1184

    
1185
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1186
    effect[1].setMeshAssociation( 2,-1);  // 1
1187
    effect[2].setMeshAssociation( 4,-1);  // 2
1188
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1189
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1190
    effect[5].setMeshAssociation(16,-1);  // 4
1191
    effect[6].setMeshAssociation(32,-1);  // 5
1192

    
1193
    return effect;
1194
    }
1195

    
1196
///////////////////////////////////////////////////////////////////////////////////////////////////
1197

    
1198
  VertexEffect[] createVertexEffectsIvyCorner()
1199
    {
1200
    Static3D axisX  = new Static3D(1,0,0);
1201
    Static3D axisY  = new Static3D(0,1,0);
1202
    Static1D angle1 = new Static1D(+90);
1203
    Static1D angle2 = new Static1D(-90);
1204
    Static3D center = new Static3D(0,0,0);
1205
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1206

    
1207
    VertexEffect[] effect = new VertexEffect[5];
1208

    
1209
    effect[0] = new VertexEffectScale(1/IVY_C);
1210
    effect[1] = new VertexEffectMove(move1);
1211
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1212
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1213
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1214

    
1215
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1216
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1217
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1218

    
1219
    return effect;
1220
    }
1221

    
1222
///////////////////////////////////////////////////////////////////////////////////////////////////
1223

    
1224
  VertexEffect[] createVertexEffectsRexEdge()
1225
    {
1226
    float E = 0.5f - REX_D;
1227
    float F = 0.5f;
1228
    float G = (float)Math.sqrt(E*E+F*F);
1229
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1230

    
1231
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1232
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1233

    
1234
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1235
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1236
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1237
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1238
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1239
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1240

    
1241
    Static1D angle180 = new Static1D(180);
1242
    Static1D angle90  = new Static1D( 90);
1243
    Static1D angle270 = new Static1D(270);
1244
    Static1D angle1   = new Static1D(+A);
1245
    Static1D angle2   = new Static1D(-A);
1246

    
1247
    VertexEffect[] effect = new VertexEffect[12];
1248

    
1249
    effect[0] = new VertexEffectMove(move1);
1250
    effect[1] = new VertexEffectMove(move2);
1251
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1252
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1253
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1254
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1255
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1256
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1257
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1258
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1259
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1260
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1261

    
1262
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1263
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1264
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1265
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1266
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1267
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1268
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1269
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1270
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1271
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1272
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1273
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1274

    
1275
    return effect;
1276
    }
1277

    
1278
///////////////////////////////////////////////////////////////////////////////////////////////////
1279

    
1280
  VertexEffect[] createVertexEffectsRexCorner()
1281
    {
1282
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1283
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1284
    Static1D angle = new Static1D(225);
1285

    
1286
    VertexEffect[] effect = new VertexEffect[1];
1287
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1288

    
1289
    return effect;
1290
    }
1291

    
1292
///////////////////////////////////////////////////////////////////////////////////////////////////
1293

    
1294
  VertexEffect[] createVertexEffectsKilominxCorner()
1295
    {
1296
    VertexEffect[] effect = new VertexEffect[10];
1297

    
1298
    float H = 0.5f*(SIN54 /COS54  );
1299
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1300
    float Y2= H/(2*COS_HALFD);
1301
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1302
    float sin18 = SIN18;
1303
    float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18));
1304
    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
1305

    
1306
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1307
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1308
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1309
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H* SIN_HALFD /(COS_HALFD*LEN));
1310

    
1311
    Static3D move1 = new Static3D(0,-Y1,0);
1312
    Static3D move2 = new Static3D(0,-Y2,0);
1313
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1314
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1315

    
1316
    Static1D angle1 = new Static1D(54);
1317
    Static1D angle2 = new Static1D(A/2+18);
1318
    Static1D angle3 = new Static1D(90);
1319
    Static1D angle4 = new Static1D(120);
1320
    Static1D angle5 = new Static1D(240);
1321
    Static1D angle6 = new Static1D(90-A/2);
1322

    
1323
    effect[0] = new VertexEffectMove(move1);
1324
    effect[1] = new VertexEffectScale(1/MINX_SC);
1325
    effect[2] = new VertexEffectMove(move2);
1326
    effect[3] = new VertexEffectRotate(angle1, axisZ, center);
1327
    effect[4] = new VertexEffectRotate(angle2, axisZ, center);
1328
    effect[5] = new VertexEffectRotate(angle3, axisA, center);
1329
    effect[6] = new VertexEffectMove(move3);
1330
    effect[7] = new VertexEffectRotate(angle4, axisC, center);
1331
    effect[8] = new VertexEffectRotate(angle5, axisC, center);
1332
    effect[9] = new VertexEffectRotate(angle6, axisY, center);
1333

    
1334
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1335
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1336
    effect[2].setMeshAssociation(56,-1);  // meshes 3,4,5
1337
    effect[3].setMeshAssociation( 7,-1);  // meshes 0,1,2
1338
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1339
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1340
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1341
    effect[7].setMeshAssociation(18,-1);  // meshes 1,4
1342
    effect[8].setMeshAssociation(36,-1);  // meshes 2,5
1343

    
1344
    return effect;
1345
    }
1346

    
1347
///////////////////////////////////////////////////////////////////////////////////////////////////
1348

    
1349
  VertexEffect[] createVertexEffectsMegaminxCorner(int numLayers)
1350
    {
1351
    VertexEffect[] effect = new VertexEffect[9];
1352

    
1353
    float Y = COS54/(2*SIN54);
1354

    
1355
    float sinA = (2*SIN54*SIN54-1)/COS54;
1356
    float cosA = (float)Math.sqrt(1-sinA*sinA);
1357
    float LEN  = 0.5f/SIN54;
1358
    float scale= (numLayers/3.0f)*(0.5f-MEGA_D)/(LEN*0.5f*(numLayers-1));
1359

    
1360
    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
1361
    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
1362
    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
1363

    
1364
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1365
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1366

    
1367
    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
1368
    Static3D move2= new Static3D(0.0f, Y , 0.0f );
1369

    
1370
    Static1D angleD = new Static1D(DIHEDRAL1);
1371
    Static1D angleE = new Static1D(360-DIHEDRAL1);
1372
    Static1D angleF = new Static1D(DIHEDRAL2);
1373

    
1374
    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
1375
    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
1376
    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
1377
    effect[3] = new VertexEffectMove(move1);
1378
    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
1379
    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
1380
    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
1381
    effect[7] = new VertexEffectMove(move2);
1382
    effect[8] = new VertexEffectScale(scale);
1383

    
1384
    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
1385
    effect[1].setMeshAssociation( 16,-1);  // mesh 4
1386
    effect[2].setMeshAssociation( 32,-1);  // mesh 5
1387
    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
1388
    effect[4].setMeshAssociation(  1,-1);  // mesh 0
1389
    effect[5].setMeshAssociation(  2,-1);  // mesh 1
1390

    
1391
    return effect;
1392
    }
1393

    
1394
///////////////////////////////////////////////////////////////////////////////////////////////////
1395

    
1396
  VertexEffect[] createVertexEffectsMegaminxEdge(float width, float height)
1397
    {
1398
    VertexEffect[] effect = new VertexEffect[11];
1399

    
1400
    float X = 0.5f*height;
1401
    float Y = height*(COS54/COS18) + width*0.5f;
1402
    float Z = 2*height*COS_HALFD;
1403

    
1404
    float alpha = 90-DIHEDRAL1/2;
1405
    float beta  = DIHEDRAL2;
1406

    
1407
    Static1D angle1 = new Static1D(alpha);
1408
    Static1D angle2 = new Static1D(180-alpha);
1409
    Static1D angle3 = new Static1D(beta);
1410

    
1411
    Static3D move1 = new Static3D(X,0,0);
1412
    Static3D move2 = new Static3D(X,0,-Z);
1413
    Static3D move3 = new Static3D(0,+Y,0);
1414
    Static3D move4 = new Static3D(0,-Y,0);
1415
    Static3D scale = new Static3D(+1,+1,-1);
1416

    
1417
    Static3D axisXplus = new Static3D(+1, 0, 0);
1418
    Static3D axisXminus= new Static3D(-1, 0, 0);
1419
    Static3D axisYplus = new Static3D( 0,+1, 0);
1420
    Static3D axisYminus= new Static3D( 0,-1, 0);
1421

    
1422
    Static3D center1= new Static3D( 0, 0, 0);
1423
    Static3D center2= new Static3D( 0, 0,-Z);
1424
    Static3D center3= new Static3D( 0,+width*0.5f, 0);
1425
    Static3D center4= new Static3D( 0,-width*0.5f, 0);
1426

    
1427
    effect[ 0] = new VertexEffectMove(move1);
1428
    effect[ 1] = new VertexEffectMove(move2);
1429
    effect[ 2] = new VertexEffectMove(move3);
1430
    effect[ 3] = new VertexEffectMove(move4);
1431
    effect[ 4] = new VertexEffectScale(scale);
1432
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1433
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1434
    effect[ 7] = new VertexEffectRotate(angle1, axisYminus, center2);
1435
    effect[ 8] = new VertexEffectRotate(angle2, axisYminus, center2);
1436
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center3);
1437
    effect[10] = new VertexEffectRotate(angle3, axisXminus, center4);
1438

    
1439
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1440
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1441
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1442
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1443
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1444
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1445
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1446
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1447
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1448
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1449
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1450

    
1451
    return effect;
1452
    }
1453

    
1454
///////////////////////////////////////////////////////////////////////////////////////////////////
1455
// OBJECTS
1456
///////////////////////////////////////////////////////////////////////////////////////////////////
1457
// CUBE
1458

    
1459
  MeshBase createCubeMesh(int index)
1460
    {
1461
    MeshBase mesh = createFacesCube(index);
1462
    VertexEffect[] effects = createVertexEffectsCube();
1463
    for( VertexEffect effect : effects ) mesh.apply(effect);
1464

    
1465
    Static3D roundingCenter  = new Static3D(0,0,0);
1466
    Static3D[] vertices = new Static3D[8];
1467
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1468
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1469
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1470
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1471
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1472
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1473
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1474
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1475

    
1476
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1477

    
1478
    mesh.mergeEffComponents();
1479

    
1480
    return mesh;
1481
    }
1482

    
1483
///////////////////////////////////////////////////////////////////////////////////////////////////
1484
// SKEWB
1485

    
1486
  MeshBase createSkewbCornerMesh()
1487
    {
1488
    MeshBase mesh = createFacesSkewbCorner();
1489
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1490
    for( VertexEffect effect : effects ) mesh.apply(effect);
1491

    
1492
    float E = 0.5f;
1493
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1494

    
1495
    Static3D[] verticesType1 = new Static3D[1];
1496
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1497
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1498

    
1499
    Static3D[] verticesType2 = new Static3D[3];
1500
    verticesType2[0] = new Static3D(-E, 0, 0);
1501
    verticesType2[1] = new Static3D( 0,-E, 0);
1502
    verticesType2[2] = new Static3D( 0, 0,-E);
1503
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1504

    
1505
    mesh.mergeEffComponents();
1506

    
1507
    return mesh;
1508
    }
1509

    
1510
///////////////////////////////////////////////////////////////////////////////////////////////////
1511

    
1512
  MeshBase createSkewbFaceMesh()
1513
    {
1514
    MeshBase mesh = createFacesSkewbFace();
1515
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1516
    for( VertexEffect effect : effects ) mesh.apply(effect);
1517

    
1518
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1519
    float E = SQ2/4;
1520
    Static3D[] vertices = new Static3D[4];
1521
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1522
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1523
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1524
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1525
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1526

    
1527
    mesh.mergeEffComponents();
1528
    mesh.addEmptyTexComponent();
1529

    
1530
    return mesh;
1531
    }
1532

    
1533
///////////////////////////////////////////////////////////////////////////////////////////////////
1534
// SKEWB DIAMOND / PYRAMINX
1535

    
1536
  MeshBase createOctaMesh()
1537
    {
1538
    MeshBase mesh = createFacesOcta();
1539
    VertexEffect[] effects = createVertexEffectsOcta();
1540
    for( VertexEffect effect : effects ) mesh.apply(effect);
1541

    
1542
    Static3D roundingCenter = new Static3D(0,0,0);
1543
    Static3D[] vertices = new Static3D[6];
1544
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1545
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1546
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1547
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1548
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1549
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1550

    
1551
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1552

    
1553
    mesh.mergeEffComponents();
1554

    
1555
    return mesh;
1556
    }
1557

    
1558
///////////////////////////////////////////////////////////////////////////////////////////////////
1559

    
1560
  MeshBase createTetraMesh()
1561
    {
1562
    MeshBase mesh = createFacesTetra();
1563
    VertexEffect[] effects = createVertexEffectsTetra();
1564
    for( VertexEffect effect : effects ) mesh.apply(effect);
1565

    
1566
    Static3D roundingCenter = new Static3D(0,0,0);
1567
    Static3D[] verticesRound = new Static3D[4];
1568
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1569
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1570
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1571
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1572
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1573

    
1574
    mesh.mergeEffComponents();
1575
    mesh.addEmptyTexComponent();
1576
    mesh.addEmptyTexComponent();
1577
    mesh.addEmptyTexComponent();
1578
    mesh.addEmptyTexComponent();
1579

    
1580
    return mesh;
1581
    }
1582

    
1583
///////////////////////////////////////////////////////////////////////////////////////////////////
1584
// DINO
1585

    
1586
  MeshBase createDinoMesh()
1587
    {
1588
    MeshBase mesh = createFacesDino();
1589
    VertexEffect[] effects = createVertexEffectsDino();
1590
    for( VertexEffect effect : effects ) mesh.apply(effect);
1591

    
1592
    float F = 0.5f;
1593
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1594
    Static3D[] verticesRound = new Static3D[4];
1595
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1596
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1597
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1598
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1599
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1600

    
1601
    mesh.mergeEffComponents();
1602

    
1603
    return mesh;
1604
    }
1605

    
1606
///////////////////////////////////////////////////////////////////////////////////////////////////
1607
// Helicopter
1608

    
1609
  MeshBase createHelicopterCornerMesh()
1610
    {
1611
    MeshBase mesh = createFacesHelicopterCorner();
1612
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1613
    for( VertexEffect effect : effects ) mesh.apply(effect);
1614

    
1615
    float E = 0.5f;
1616
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1617

    
1618
    Static3D[] verticesType1 = new Static3D[1];
1619
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1620
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1621

    
1622
    Static3D[] verticesType2 = new Static3D[3];
1623
    verticesType2[0] = new Static3D(-E, 0, 0);
1624
    verticesType2[1] = new Static3D( 0,-E, 0);
1625
    verticesType2[2] = new Static3D( 0, 0,-E);
1626
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1627

    
1628
    mesh.mergeEffComponents();
1629

    
1630
    return mesh;
1631
    }
1632

    
1633
///////////////////////////////////////////////////////////////////////////////////////////////////
1634

    
1635
  MeshBase createHelicopterFaceMesh()
1636
    {
1637
    MeshBase mesh = createFacesHelicopterFace();
1638
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1639
    for( VertexEffect effect : effects ) mesh.apply(effect);
1640

    
1641
    float E = 0.5f;
1642
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1643

    
1644
    Static3D[] verticesType1 = new Static3D[1];
1645
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1646
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1647

    
1648
    Static3D[] verticesType2 = new Static3D[2];
1649
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1650
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1651
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1652

    
1653
    mesh.mergeEffComponents();
1654
    mesh.addEmptyTexComponent();
1655
    mesh.addEmptyTexComponent();
1656

    
1657
    return mesh;
1658
    }
1659

    
1660
///////////////////////////////////////////////////////////////////////////////////////////////////
1661
// Redi cube
1662

    
1663
  MeshBase createRediEdgeMesh()
1664
    {
1665
    MeshBase mesh = createFacesRediEdge();
1666
    VertexEffect[] effects = createVertexEffectsRediEdge();
1667
    for( VertexEffect effect : effects ) mesh.apply(effect);
1668

    
1669
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1670
    Static3D[] vertices = new Static3D[2];
1671
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1672
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1673
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1674

    
1675
    mesh.mergeEffComponents();
1676

    
1677
    return mesh;
1678
    }
1679

    
1680
///////////////////////////////////////////////////////////////////////////////////////////////////
1681

    
1682
  MeshBase createRediCornerMesh()
1683
    {
1684
    MeshBase mesh = createFacesRediCorner();
1685
    VertexEffect[] effects = createVertexEffectsRediCorner();
1686
    for( VertexEffect effect : effects ) mesh.apply(effect);
1687

    
1688
    Static3D center = new Static3D(0,0,0);
1689
    Static3D[] vertices = new Static3D[8];
1690
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1691
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1692
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1693
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1694
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1695
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1696
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1697
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1698

    
1699
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1700

    
1701
    mesh.mergeEffComponents();
1702

    
1703
    return mesh;
1704
    }
1705

    
1706
///////////////////////////////////////////////////////////////////////////////////////////////////
1707

    
1708
  MeshBase createIvyCornerMesh()
1709
    {
1710
    MeshBase mesh = createFacesIvyCorner();
1711
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1712
    for( VertexEffect effect : effects ) mesh.apply(effect);
1713

    
1714
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1715
    Static3D[] vertices = new Static3D[4];
1716
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1717
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1718
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1719
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1720

    
1721
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1722

    
1723
    mesh.mergeEffComponents();
1724

    
1725
    return mesh;
1726
    }
1727

    
1728
///////////////////////////////////////////////////////////////////////////////////////////////////
1729

    
1730
  MeshBase createIvyFaceMesh()
1731
    {
1732
    MeshBase mesh = createFacesIvyFace();
1733

    
1734
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1735
    Static3D[] vertices = new Static3D[2];
1736
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1737
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1738

    
1739
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1740

    
1741
    mesh.mergeEffComponents();
1742
    mesh.addEmptyTexComponent();
1743
    mesh.addEmptyTexComponent();
1744
    mesh.addEmptyTexComponent();
1745
    mesh.addEmptyTexComponent();
1746

    
1747
    return mesh;
1748
    }
1749

    
1750
///////////////////////////////////////////////////////////////////////////////////////////////////
1751

    
1752
  MeshBase createRexCornerMesh()
1753
    {
1754
    MeshBase mesh = createFacesRexCorner();
1755
    VertexEffect[] effects = createVertexEffectsRexCorner();
1756
    for( VertexEffect effect : effects ) mesh.apply(effect);
1757

    
1758
    final float G = (1-REX_D)/3;
1759
    Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
1760
    Static3D[] vertices = new Static3D[1];
1761
    vertices[0] = new Static3D(+G,-G,+0.0f);
1762
    roundCorners(mesh,center,vertices,0.10f,0.10f);
1763

    
1764
    mesh.mergeEffComponents();
1765
    mesh.addEmptyTexComponent();
1766
    mesh.addEmptyTexComponent();
1767
    mesh.addEmptyTexComponent();
1768
    mesh.addEmptyTexComponent();
1769

    
1770
    return mesh;
1771
    }
1772

    
1773
///////////////////////////////////////////////////////////////////////////////////////////////////
1774

    
1775
  MeshBase createRexFaceMesh()
1776
    {
1777
    MeshBase mesh = createFacesRexFace();
1778

    
1779
    mesh.mergeEffComponents();
1780
    mesh.addEmptyTexComponent();
1781
    mesh.addEmptyTexComponent();
1782
    mesh.addEmptyTexComponent();
1783
    mesh.addEmptyTexComponent();
1784

    
1785
    return mesh;
1786
    }
1787

    
1788
///////////////////////////////////////////////////////////////////////////////////////////////////
1789

    
1790
  MeshBase createRexEdgeMesh()
1791
    {
1792
    MeshBase mesh = createFacesRexEdge();
1793
    VertexEffect[] effects = createVertexEffectsRexEdge();
1794
    for( VertexEffect effect : effects ) mesh.apply(effect);
1795

    
1796
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1797
    Static3D[] vertices = new Static3D[2];
1798
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1799
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1800
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1801

    
1802
    mesh.mergeEffComponents();
1803

    
1804
    return mesh;
1805
    }
1806

    
1807
///////////////////////////////////////////////////////////////////////////////////////////////////
1808

    
1809
  MeshBase createKilominxCornerMesh()
1810
    {
1811
    MeshBase mesh = createFacesKilominxCorner();
1812
    VertexEffect[] effects = createVertexEffectsKilominxCorner();
1813
    for( VertexEffect effect : effects ) mesh.apply(effect);
1814

    
1815
    float A = (2*SQ3/3)* SIN54;
1816
    float B = 0.4f;
1817
    float X = SIN_HALFD * SIN54 *COS54  ;
1818
    float Y = SIN54 * SIN54 - 0.5f;
1819
    float Z = COS_HALFD* SIN54 *COS54  ;
1820

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

    
1823
    Static3D[] vertices = new Static3D[4];
1824
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1825
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1826
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1827
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1828

    
1829
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1830

    
1831
    mesh.mergeEffComponents();
1832

    
1833
    return mesh;
1834
    }
1835

    
1836
///////////////////////////////////////////////////////////////////////////////////////////////////
1837

    
1838
  MeshBase createMegaminxCornerMesh(int numLayers)
1839
    {
1840
    MeshBase mesh = createFacesMegaminxCorner();
1841
    VertexEffect[] effects = createVertexEffectsMegaminxCorner(numLayers);
1842
    for( VertexEffect effect : effects ) mesh.apply(effect);
1843

    
1844
    float A = (2*SQ3/3)* SIN54;
1845
    float B = 0.4f;
1846
    float X = SIN_HALFD* SIN54 * COS54;
1847
    float Y = SIN54 * SIN54 - 0.5f;
1848
    float Z = COS_HALFD* SIN54 * COS54;
1849
    float S = 2*SIN54*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
1850

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

    
1853
    Static3D[] vertices = new Static3D[4];
1854
    vertices[0] = new Static3D( 0.0f, 0.0f  , 0.0f);
1855
    vertices[1] = new Static3D( 0.0f,-0.5f*S, 0.0f);
1856
    vertices[2] = new Static3D(-X*S , Y*S   ,-Z*S );
1857
    vertices[3] = new Static3D(+X*S , Y*S   ,-Z*S );
1858

    
1859
    roundCorners(mesh,center,vertices,0.04f,0.10f);
1860

    
1861
    mesh.mergeEffComponents();
1862

    
1863
    return mesh;
1864
    }
1865

    
1866
///////////////////////////////////////////////////////////////////////////////////////////////////
1867
// numLayers==3 --> index=0; numLayers=5 --> index=1 ...
1868
// type: 0,1,... 0 --> edge, 1 --> 1 layer deeper, etc
1869

    
1870
  MeshBase createMegaminxEdgeMesh(float width, float height)
1871
    {
1872
    MeshBase mesh = createFacesMegaminxEdge(width,height);
1873
    VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
1874
    for( VertexEffect effect : effects ) mesh.apply(effect);
1875

    
1876
    mesh.mergeEffComponents();
1877

    
1878
    return mesh;
1879
    }
1880
  }
(2-2/30)