Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 7764a67a

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

    
214
  MeshBase createFacesCube(int sizeIndex)
215
    {
216
    MeshBase[] meshes = new MeshPolygon[6];
217

    
218
    float E = 0.5f;
219
    int extraI, extraV, num;
220

    
221
    switch(sizeIndex)
222
      {
223
      case 0 : num = 6; extraI = 2; extraV = 2; break;
224
      case 1 : num = 5; extraI = 2; extraV = 2; break;
225
      case 2 : num = 5; extraI = 1; extraV = 2; break;
226
      default: num = 4; extraI = 1; extraV = 1; break;
227
      }
228

    
229
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
230
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
231

    
232
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
233
    meshes[0].setEffectAssociation(0,1,0);
234
    meshes[1] = meshes[0].copy(true);
235
    meshes[1].setEffectAssociation(0,2,0);
236
    meshes[2] = meshes[0].copy(true);
237
    meshes[2].setEffectAssociation(0,4,0);
238
    meshes[3] = meshes[0].copy(true);
239
    meshes[3].setEffectAssociation(0,8,0);
240
    meshes[4] = meshes[0].copy(true);
241
    meshes[4].setEffectAssociation(0,16,0);
242
    meshes[5] = meshes[0].copy(true);
243
    meshes[5].setEffectAssociation(0,32,0);
244

    
245
    return new MeshJoined(meshes);
246
    }
247

    
248
///////////////////////////////////////////////////////////////////////////////////////////////////
249

    
250
  MeshBase createFacesSkewbCorner()
251
    {
252
    MeshBase[] meshes = new MeshBase[6];
253

    
254
    float E = 0.5f;
255
    float F = SQ2/2;
256
    float G = SQ6/16;
257
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
258
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
259

    
260
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
261
    meshes[0].setEffectAssociation(0,1,0);
262
    meshes[1] = meshes[0].copy(true);
263
    meshes[1].setEffectAssociation(0,2,0);
264
    meshes[2] = meshes[0].copy(true);
265
    meshes[2].setEffectAssociation(0,4,0);
266

    
267
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
268
    float[] bands1 = computeBands(0,0,1,0,3);
269

    
270
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
271
    meshes[3].setEffectAssociation(0,8,0);
272
    meshes[4] = meshes[3].copy(true);
273
    meshes[4].setEffectAssociation(0,16,0);
274
    meshes[5] = meshes[3].copy(true);
275
    meshes[5].setEffectAssociation(0,32,0);
276

    
277
    return new MeshJoined(meshes);
278
    }
279

    
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281

    
282
  MeshBase createFacesSkewbFace()
283
    {
284
    MeshBase[] meshes = new MeshBase[5];
285

    
286
    float E = SQ2/4;
287
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
288
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
289

    
290
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
291
    meshes[0].setEffectAssociation(0,1,0);
292

    
293
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
294
    float[] bands1 = computeBands(0,0,1,0,3);
295

    
296
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
297
    meshes[1].setEffectAssociation(0,2,0);
298
    meshes[2] = meshes[1].copy(true);
299
    meshes[2].setEffectAssociation(0,4,0);
300
    meshes[3] = meshes[1].copy(true);
301
    meshes[3].setEffectAssociation(0,8,0);
302
    meshes[4] = meshes[1].copy(true);
303
    meshes[4].setEffectAssociation(0,16,0);
304

    
305
    return new MeshJoined(meshes);
306
    }
307

    
308
///////////////////////////////////////////////////////////////////////////////////////////////////
309

    
310
  MeshBase createFacesOcta()
311
    {
312
    MeshBase[] meshes = new MeshPolygon[8];
313

    
314
    float E = 0.75f;
315
    float F = 0.5f;
316
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
317
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
318

    
319
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
320
    meshes[0].setEffectAssociation(0,1,0);
321
    meshes[1] = meshes[0].copy(true);
322
    meshes[1].setEffectAssociation(0,2,0);
323
    meshes[2] = meshes[0].copy(true);
324
    meshes[2].setEffectAssociation(0,4,0);
325
    meshes[3] = meshes[0].copy(true);
326
    meshes[3].setEffectAssociation(0,8,0);
327
    meshes[4] = meshes[0].copy(true);
328
    meshes[4].setEffectAssociation(0,16,0);
329
    meshes[5] = meshes[0].copy(true);
330
    meshes[5].setEffectAssociation(0,32,0);
331
    meshes[6] = meshes[0].copy(true);
332
    meshes[6].setEffectAssociation(0,64,0);
333
    meshes[7] = meshes[0].copy(true);
334
    meshes[7].setEffectAssociation(0,128,0);
335

    
336
    return new MeshJoined(meshes);
337
    }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

    
341
  MeshBase createFacesTetra()
342
    {
343
    MeshBase[] meshes = new MeshBase[4];
344

    
345
    float E = 0.75f;
346
    float F = 0.5f;
347
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
348
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
349

    
350
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
351
    meshes[0].setEffectAssociation(0,1,0);
352
    meshes[1] = meshes[0].copy(true);
353
    meshes[1].setEffectAssociation(0,2,0);
354
    meshes[2] = meshes[0].copy(true);
355
    meshes[2].setEffectAssociation(0,4,0);
356
    meshes[3] = meshes[0].copy(true);
357
    meshes[3].setEffectAssociation(0,8,0);
358

    
359
    return new MeshJoined(meshes);
360
    }
361

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363

    
364
  MeshBase createFacesDino()
365
    {
366
    MeshBase[] meshes = new MeshPolygon[4];
367

    
368
    float E = 0.5f*SQ2;
369
    float F = 0.5f;
370
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
371
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
372

    
373
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
374
    meshes[0].setEffectAssociation(0,1,0);
375
    meshes[1] = meshes[0].copy(true);
376
    meshes[1].setEffectAssociation(0,2,0);
377

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

    
381
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
382
    meshes[2].setEffectAssociation(0,4,0);
383
    meshes[3] = meshes[2].copy(true);
384
    meshes[3].setEffectAssociation(0,8,0);
385

    
386
    return new MeshJoined(meshes);
387
    }
388

    
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390

    
391
  MeshBase createFacesHelicopterCorner()
392
    {
393
    MeshBase[] meshes = new MeshBase[6];
394

    
395
    float E = 0.5f;
396
    float F = SQ2/4;
397
    float G = 1.0f/12;
398
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
399
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
400

    
401
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
402
    meshes[0].setEffectAssociation(0,1,0);
403
    meshes[1] = meshes[0].copy(true);
404
    meshes[1].setEffectAssociation(0,2,0);
405
    meshes[2] = meshes[0].copy(true);
406
    meshes[2].setEffectAssociation(0,4,0);
407

    
408
    float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
409
    float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
410
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
411
    meshes[3].setEffectAssociation(0,8,0);
412
    meshes[4] = meshes[3].copy(true);
413
    meshes[4].setEffectAssociation(0,16,0);
414
    meshes[5] = meshes[3].copy(true);
415
    meshes[5].setEffectAssociation(0,32,0);
416

    
417
    return new MeshJoined(meshes);
418
    }
419

    
420
///////////////////////////////////////////////////////////////////////////////////////////////////
421

    
422
  MeshBase createFacesHelicopterFace()
423
    {
424
    MeshBase[] meshes = new MeshBase[4];
425

    
426
    float E = 0.5f;
427
    float F = SQ2/4;
428
    float G = 1.0f/12;
429
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
430
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
431

    
432
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
433
    meshes[0].setEffectAssociation(0,1,0);
434

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

    
438
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
439
    meshes[1].setEffectAssociation(0,2,0);
440

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

    
443
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
444
    meshes[2].setEffectAssociation(0,4,0);
445
    meshes[3] = meshes[2].copy(true);
446
    meshes[3].setEffectAssociation(0,8,0);
447

    
448
    return new MeshJoined(meshes);
449
    }
450

    
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452

    
453
  MeshBase createFacesRediEdge()
454
    {
455
    MeshBase[] meshes = new MeshPolygon[6];
456

    
457
    float F = 0.25f;
458
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
459
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
460

    
461
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
462
    meshes[0].setEffectAssociation(0,1,0);
463
    meshes[1] = meshes[0].copy(true);
464
    meshes[1].setEffectAssociation(0,2,0);
465

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

    
469
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
470
    meshes[2].setEffectAssociation(0,4,0);
471
    meshes[3] = meshes[2].copy(true);
472
    meshes[3].setEffectAssociation(0,8,0);
473

    
474
    float X = 0.25f*SQ2;
475
    float Y = SQ6/16;
476
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
477

    
478
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
479
    meshes[4].setEffectAssociation(0,16,0);
480
    meshes[5] = meshes[4].copy(true);
481
    meshes[5].setEffectAssociation(0,32,0);
482

    
483
    return new MeshJoined(meshes);
484
    }
485

    
486
///////////////////////////////////////////////////////////////////////////////////////////////////
487

    
488
  MeshBase createFacesRediCorner()
489
    {
490
    MeshBase[] meshes = new MeshBase[6];
491

    
492
    float E = 0.5f;
493
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
494
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
495

    
496
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
497
    meshes[0].setEffectAssociation(0,1,0);
498
    meshes[1] = meshes[0].copy(true);
499
    meshes[1].setEffectAssociation(0,2,0);
500
    meshes[2] = meshes[0].copy(true);
501
    meshes[2].setEffectAssociation(0,4,0);
502

    
503
    float F = 0.5f;
504
    float X = 0.5f;
505
    float G = 0.72f;
506
    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 };
507
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
508

    
509
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
510
    meshes[3].setEffectAssociation(0,8,0);
511
    meshes[4] = meshes[3].copy(true);
512
    meshes[4].setEffectAssociation(0,16,0);
513
    meshes[5] = meshes[3].copy(true);
514
    meshes[5].setEffectAssociation(0,32,0);
515

    
516
    return new MeshJoined(meshes);
517
    }
518

    
519
///////////////////////////////////////////////////////////////////////////////////////////////////
520

    
521
  MeshBase createFacesIvyCorner()
522
    {
523
    MeshBase[] meshes = new MeshBase[6];
524

    
525
    final float angle = (float)Math.PI/(2*IVY_N);
526
    final float CORR  = 1.0f - 2*IVY_D;
527
    final float DIST  = -0.5f*CORR + IVY_D;
528
    float[] vertices  = new float[2*(IVY_N+1)+6];
529

    
530
    vertices[0] = (0.5f-IVY_M) * IVY_C;
531
    vertices[1] = (DIST-IVY_M) * IVY_C;
532
    vertices[2] = (0.5f-IVY_M) * IVY_C;
533
    vertices[3] = (0.5f-IVY_M) * IVY_C;
534
    vertices[4] = (DIST-IVY_M) * IVY_C;
535
    vertices[5] = (0.5f-IVY_M) * IVY_C;
536

    
537
    for(int i=0; i<=IVY_N; i++)
538
      {
539
      float ang = (IVY_N-i)*angle;
540
      float sin = (float)Math.sin(ang);
541
      float cos = (float)Math.cos(ang);
542

    
543
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
544
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
545
      }
546

    
547
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
548
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
549

    
550
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
551
    meshes[0].setEffectAssociation(0,1,0);
552
    meshes[1] = meshes[0].copy(true);
553
    meshes[1].setEffectAssociation(0,2,0);
554
    meshes[2] = meshes[0].copy(true);
555
    meshes[2].setEffectAssociation(0,4,0);
556
    meshes[3] = new MeshPolygon(vertices,bands1,1,2);
557
    meshes[3].setEffectAssociation(0,8,0);
558
    meshes[4] = meshes[3].copy(true);
559
    meshes[4].setEffectAssociation(0,16,0);
560
    meshes[5] = meshes[3].copy(true);
561
    meshes[5].setEffectAssociation(0,32,0);
562

    
563
    return new MeshJoined(meshes);
564
    }
565

    
566
///////////////////////////////////////////////////////////////////////////////////////////////////
567

    
568
  MeshBase createFacesIvyFace()
569
    {
570
    MeshBase[] meshes = new MeshBase[2];
571

    
572
    final float angle = (float)Math.PI/(2*IVY_N);
573
    final float CORR  = 1.0f - 2*IVY_D;
574
    float[] vertices = new float[4*IVY_N];
575

    
576
    for(int i=0; i<IVY_N; i++)
577
      {
578
      float sin = (float)Math.sin(i*angle);
579
      float cos = (float)Math.cos(i*angle);
580

    
581
      vertices[2*i          ] = CORR*(0.5f-cos);
582
      vertices[2*i+1        ] = CORR*(0.5f-sin);
583
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
584
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
585
      }
586

    
587
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
588
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
589

    
590
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
591
    meshes[0].setEffectAssociation(0,1,0);
592
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
593
    meshes[1].setEffectAssociation(0,2,0);
594

    
595
    return new MeshJoined(meshes);
596
    }
597

    
598
///////////////////////////////////////////////////////////////////////////////////////////////////
599

    
600
  MeshBase createFacesRexCorner()
601
    {
602
    MeshBase[] meshes = new MeshBase[2];
603

    
604
    float F = REX_D*SQ2;
605
    float G = (1-REX_D)*SQ2/2;
606
    float H = 0.1f;
607
    float J = +2*G/3 - H*G;
608

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

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

    
614
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
615
    meshes[0].setEffectAssociation(0,1,0);
616
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
617
    meshes[1].setEffectAssociation(0,2,0);
618

    
619
    return new MeshJoined(meshes);
620
    }
621

    
622
///////////////////////////////////////////////////////////////////////////////////////////////////
623

    
624
  MeshBase createFacesRexFace()
625
    {
626
    MeshBase[] meshes = new MeshBase[2];
627

    
628
    float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
629

    
630
    float[] bands0 = computeBands(0.016f,10,REX_D/2,0.5f,5);
631
    float[] bands1 = computeBands(0.000f,45,REX_D/2,0.0f,2);
632

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

    
638
    return new MeshJoined(meshes);
639
    }
640

    
641
///////////////////////////////////////////////////////////////////////////////////////////////////
642

    
643
  MeshBase createFacesRexEdge()
644
    {
645
    MeshBase[] meshes = new MeshPolygon[6];
646

    
647
    float E = 0.5f - REX_D;
648
    float F = 0.5f;
649
    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
650
    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
651

    
652
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
653
    meshes[0].setEffectAssociation(0,1,0);
654
    meshes[1] = meshes[0].copy(true);
655
    meshes[1].setEffectAssociation(0,2,0);
656

    
657
    float G = (float)Math.sqrt(E*E+F*F);
658
    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
659
    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
660

    
661
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
662
    meshes[2].setEffectAssociation(0,4,0);
663
    meshes[3] = meshes[2].copy(true);
664
    meshes[3].setEffectAssociation(0,8,0);
665
    meshes[4] = meshes[2].copy(true);
666
    meshes[4].setEffectAssociation(0,16,0);
667
    meshes[5] = meshes[2].copy(true);
668
    meshes[5].setEffectAssociation(0,32,0);
669

    
670
    return new MeshJoined(meshes);
671
    }
672

    
673
///////////////////////////////////////////////////////////////////////////////////////////////////
674

    
675
  MeshBase createFacesKilominxCenter()
676
    {
677
    MeshBase[] meshes = new MeshPolygon[6];
678

    
679
    float X1= 0.5f*SIN54;
680
    float Y1= 0.5f*SIN_HALFD;
681
    float Y2= Y1 - 0.5f*COS54;
682
    float H = 0.5f* SIN54 /COS54  ;
683
    float X2= MINX_SC*H* SIN_HALFD;
684
    float Y3= MINX_SC*H/(2*COS_HALFD);
685
    float Y4= MINX_SC*H*(1/(2*COS_HALFD) - COS_HALFD);
686

    
687
    float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
688
    float[] bands0 = computeBands(0.04f,17,0.3f,0.2f,5);
689
    float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 };
690
    float[] bands1 = computeBands(0.00f, 0,0.25f,0.5f,5);
691

    
692
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
693
    meshes[0].setEffectAssociation(0, 1,0);
694
    meshes[1] = meshes[0].copy(true);
695
    meshes[1].setEffectAssociation(0, 2,0);
696
    meshes[2] = meshes[0].copy(true);
697
    meshes[2].setEffectAssociation(0, 4,0);
698
    meshes[3] = new MeshPolygon(vertices1, bands1, 1, 1);
699
    meshes[3].setEffectAssociation(0, 8,0);
700
    meshes[4] = meshes[3].copy(true);
701
    meshes[4].setEffectAssociation(0,16,0);
702
    meshes[5] = meshes[3].copy(true);
703
    meshes[5].setEffectAssociation(0,32,0);
704

    
705
    return new MeshJoined(meshes);
706
    }
707

    
708
///////////////////////////////////////////////////////////////////////////////////////////////////
709

    
710
  MeshBase createFacesMegaminxCorner(int numLayers)
711
    {
712
    MeshBase[] meshes = new MeshPolygon[6];
713

    
714
    float Y = COS54/(2*SIN54);
715

    
716
    float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
717

    
718
    int numBands0 = numLayers==3 ? 5 : 3;
719
    int numBands1 = numLayers==3 ? 2 : 2;
720
    float h       = numLayers==3 ? 0.04f : 0.03f;
721
    int   e       = numLayers==3 ? 4 : 1;
722

    
723
    float[] bands0 = computeBands(h    ,34,0.3f,0.2f, numBands0);
724
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f, numBands1);
725

    
726
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
727
    meshes[0].setEffectAssociation(0, 1,0);
728
    meshes[1] = meshes[0].copy(true);
729
    meshes[1].setEffectAssociation(0, 2,0);
730
    meshes[2] = meshes[0].copy(true);
731
    meshes[2].setEffectAssociation(0, 4,0);
732
    meshes[3] = new MeshPolygon(vertices0, bands1, 1, e);
733
    meshes[3].setEffectAssociation(0, 8,0);
734
    meshes[4] = meshes[3].copy(true);
735
    meshes[4].setEffectAssociation(0,16,0);
736
    meshes[5] = meshes[3].copy(true);
737
    meshes[5].setEffectAssociation(0,32,0);
738

    
739
    return new MeshJoined(meshes);
740
    }
741

    
742
///////////////////////////////////////////////////////////////////////////////////////////////////
743

    
744
  MeshBase createFacesMegaminxEdge(int numLayers, float width, float height)
745
    {
746
    MeshBase[] meshes = new MeshPolygon[6];
747

    
748
    float D = height/COS18;
749
    float W = D*SIN18;
750

    
751
    float Y1 = 0.5f*width;
752
    float Y2 = 0.5f*width + W;
753
    float Y3 = 0.5f*width + 2*W;
754
    float X2 = D*SIN54;
755
    float X1 = 0.5f*height;
756
    float Y4 = D*COS54;
757

    
758
    float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
759
    float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 };
760
    float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 };
761

    
762
    int numBands0 = numLayers==3 ? 5 : 3;
763
    int numBands1 = numLayers==3 ? 2 : 2;
764
    float h       = numLayers==3 ? 0.03f : 0.03f;
765

    
766
    float[] bands0 = computeBands(h    ,34,0.2f,0.2f,numBands0);
767
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,numBands1);
768

    
769
    meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0);
770
    meshes[0].setEffectAssociation(0, 1,0);
771
    meshes[1] = meshes[0].copy(true);
772
    meshes[1].setEffectAssociation(0, 2,0);
773
    meshes[2] = new MeshPolygon(vertices1, bands1, 0, 0);
774
    meshes[2].setEffectAssociation(0, 4,0);
775
    meshes[3] = meshes[2].copy(true);
776
    meshes[3].setEffectAssociation(0, 8,0);
777
    meshes[4] = new MeshPolygon(vertices2, bands1, 0, 0);
778
    meshes[4].setEffectAssociation(0,16,0);
779
    meshes[5] = meshes[4].copy(true);
780
    meshes[5].setEffectAssociation(0,32,0);
781

    
782
    return new MeshJoined(meshes);
783
    }
784

    
785
///////////////////////////////////////////////////////////////////////////////////////////////////
786

    
787
  MeshBase createFacesMegaminxCenter(int numLayers)
788
    {
789
    MeshBase[] meshes = new MeshPolygon[2];
790

    
791
    float R  = 0.5f;
792
    float X1 = R*COS54;
793
    float Y1 = R*SIN54;
794
    float X2 = R*COS18;
795
    float Y2 = R*SIN18;
796

    
797
    float[] vertices0 = { -X1,+Y1, -X2,-Y2, 0.0f,-R, +X2,-Y2, +X1,+Y1 };
798

    
799
    int numBands0 = numLayers==3 ? 4 : 3;
800
    int numBands1 = numLayers==3 ? 2 : 2;
801
    float h       = numLayers==3 ? 0.04f : 0.04f;
802

    
803
    float[] bands0 = computeBands( h    ,45, R/3,0.2f, numBands0);
804
    float[] bands1 = computeBands( 0.00f,34, R/3,0.2f, numBands1);
805

    
806
    meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0);
807
    meshes[0].setEffectAssociation(0,1,0);
808
    meshes[1] = new MeshPolygon(vertices0, bands1, 0, 0);
809
    meshes[1].setEffectAssociation(0,2,0);
810

    
811
    return new MeshJoined(meshes);
812
    }
813

    
814
///////////////////////////////////////////////////////////////////////////////////////////////////
815

    
816
  private float[] createVertices(int A, int B)
817
    {
818
    float E = 0.5f / Math.max(A,B);
819
    return new float[] { -A*E,-B*E, +A*E,-B*E, +A*E,+B*E, -A*E,+B*E };
820
    }
821

    
822
///////////////////////////////////////////////////////////////////////////////////////////////////
823

    
824
  MeshBase createCuboid(int[] dimensions)
825
    {
826
    int X = dimensions[0];
827
    int Y = dimensions[1];
828
    int Z = dimensions[2];
829

    
830
    float[] verticesXY = createVertices(X,Y);
831
    float[] verticesXZ = createVertices(X,Z);
832
    float[] verticesYZ = createVertices(Z,Y);
833

    
834
    float defHeight = 0.048f;
835

    
836
    float[] bandsX = computeBands( defHeight/X,65,0.25f,0.5f,5);
837
    float[] bandsY = computeBands( defHeight/Y,65,0.25f,0.5f,5);
838
    float[] bandsZ = computeBands( defHeight/Z,65,0.25f,0.5f,5);
839

    
840
    MeshBase[] meshes = new MeshPolygon[6];
841

    
842
    meshes[0] = new MeshPolygon(verticesYZ,bandsX,1,2);
843
    meshes[0].setEffectAssociation(0,1,0);
844
    meshes[1] = meshes[0].copy(true);
845
    meshes[1].setEffectAssociation(0,2,0);
846
    meshes[2] = new MeshPolygon(verticesXZ,bandsY,1,2);
847
    meshes[2].setEffectAssociation(0,4,0);
848
    meshes[3] = meshes[2].copy(true);
849
    meshes[3].setEffectAssociation(0,8,0);
850
    meshes[4] = new MeshPolygon(verticesXY,bandsZ,1,2);
851
    meshes[4].setEffectAssociation(0,16,0);
852
    meshes[5] = meshes[4].copy(true);
853
    meshes[5].setEffectAssociation(0,32,0);
854

    
855
    return new MeshJoined(meshes);
856
    }
857

    
858
///////////////////////////////////////////////////////////////////////////////////////////////////
859
// EFFECTS
860
///////////////////////////////////////////////////////////////////////////////////////////////////
861

    
862
  VertexEffect[] createVertexEffectsCube()
863
    {
864
    Static3D axisY   = new Static3D(0,1,0);
865
    Static3D axisX   = new Static3D(1,0,0);
866
    Static3D center  = new Static3D(0,0,0);
867
    Static1D angle90 = new Static1D(90);
868
    Static1D angle180= new Static1D(180);
869
    Static1D angle270= new Static1D(270);
870

    
871
    VertexEffect[] effect = new VertexEffect[6];
872

    
873
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
874
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
875
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
876
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
877
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
878
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
879

    
880
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
881
    effect[1].setMeshAssociation(32,-1);  // back
882
    effect[2].setMeshAssociation( 8,-1);  // bottom
883
    effect[3].setMeshAssociation( 4,-1);  // top
884
    effect[4].setMeshAssociation( 2,-1);  // left
885
    effect[5].setMeshAssociation( 1,-1);  // right
886

    
887
    return effect;
888
    }
889

    
890
///////////////////////////////////////////////////////////////////////////////////////////////////
891

    
892
  VertexEffect[] createVertexEffectsSkewbCorner()
893
    {
894
    float E = 0.5f;
895

    
896
    Static3D axisX  = new Static3D(1,0,0);
897
    Static3D axisY  = new Static3D(0,1,0);
898
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
899
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
900
    Static1D angle1 = new Static1D(+90);
901
    Static1D angle2 = new Static1D(-90);
902
    Static1D angle3 = new Static1D(-15);
903
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
904
    Static1D angle5 = new Static1D(120);
905
    Static1D angle6 = new Static1D(240);
906
    Static3D center1= new Static3D(0,0,0);
907
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
908
    Static3D move1  = new Static3D(-E/4,-E/4,0);
909
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
910

    
911
    VertexEffect[] effect = new VertexEffect[10];
912

    
913
    effect[0] = new VertexEffectMove(move1);
914
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
915
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
916
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
917
    effect[4] = new VertexEffectMove(move2);
918
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
919
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
920
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
921
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
922
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
923

    
924
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
925
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
926
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
927
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
928
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
929
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
930
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
931
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
932
    effect[8].setMeshAssociation(16,-1);  // mesh 4
933
    effect[9].setMeshAssociation(32,-1);  // mesh 5
934

    
935
    return effect;
936
    }
937

    
938
///////////////////////////////////////////////////////////////////////////////////////////////////
939

    
940
  VertexEffect[] createVertexEffectsSkewbFace()
941
    {
942
    Static3D center = new Static3D(0,0,0);
943
    Static3D axisX  = new Static3D(1,0,0);
944
    Static3D axisZ  = new Static3D(0,0,1);
945
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
946

    
947
    VertexEffect[] effect = new VertexEffect[6];
948

    
949
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
950
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
951
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
952
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
953
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
954
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
955

    
956
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
957
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
958
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
959
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
960
    effect[4].setMeshAssociation(16,-1);  // mesh 4
961
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
962

    
963
    return effect;
964
    }
965

    
966
///////////////////////////////////////////////////////////////////////////////////////////////////
967

    
968
  VertexEffect[] createVertexEffectsOcta()
969
    {
970
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
971
    Static1D angle1= new Static1D( 90);
972
    Static1D angle2= new Static1D(180);
973
    Static1D angle3= new Static1D(270);
974
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
975
    Static3D axisX = new Static3D(1,0,0);
976
    Static3D axisY = new Static3D(0,1,0);
977
    Static3D cent0 = new Static3D(0,0,0);
978
    Static3D cent1 = new Static3D(0,SQ2/2,0);
979
    Static3D flipY = new Static3D( 1,-1, 1);
980
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
981

    
982
    VertexEffect[] effect = new VertexEffect[7];
983

    
984
    effect[0] = new VertexEffectScale(scale);
985
    effect[1] = new VertexEffectMove(move1);
986
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
987
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
988
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
989
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
990
    effect[6] = new VertexEffectScale(flipY);
991

    
992
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
993
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
994
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
995
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
996

    
997
    return effect;
998
    }
999

    
1000
///////////////////////////////////////////////////////////////////////////////////////////////////
1001

    
1002
  VertexEffect[] createVertexEffectsTetra()
1003
    {
1004
    Static3D flipZ = new Static3D( 1, 1,-1);
1005
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
1006
    Static1D angle1= new Static1D( 90);
1007
    Static1D angle2= new Static1D(180);
1008
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
1009
    Static3D axisX = new Static3D(1,0,0);
1010
    Static3D axisY = new Static3D(0,1,0);
1011
    Static3D axisZ = new Static3D(0,0,1);
1012
    Static3D cent0 = new Static3D(0,0,0);
1013
    Static3D cent1 = new Static3D(0,SQ2/4,0);
1014
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
1015

    
1016
    VertexEffect[] effect = new VertexEffect[7];
1017

    
1018
    effect[0] = new VertexEffectScale(scale);
1019
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
1020
    effect[2] = new VertexEffectMove(move1);
1021
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
1022
    effect[4] = new VertexEffectScale(flipZ);
1023
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
1024
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
1025

    
1026
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
1027
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
1028
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
1029

    
1030
    return effect;
1031
    }
1032

    
1033
///////////////////////////////////////////////////////////////////////////////////////////////////
1034

    
1035
  VertexEffect[] createVertexEffectsDino()
1036
    {
1037
    float E = 0.5f*SQ2;
1038
    float F = 0.5f;
1039
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
1040

    
1041
    Static1D angle1 = new Static1D(-ANGLE);
1042
    Static1D angle2 = new Static1D(+ANGLE);
1043
    Static3D axisX  = new Static3D(1,0,0);
1044
    Static3D axisY  = new Static3D(0,1,0);
1045
    Static3D axisZ  = new Static3D(0,-1,1);
1046
    Static3D center0= new Static3D(0,0,0);
1047
    Static3D center1= new Static3D(0,-3*F,0);
1048

    
1049
    VertexEffect[] effect = new VertexEffect[10];
1050

    
1051
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
1052
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
1053
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
1054
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
1055
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
1056
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
1057
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
1058
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
1059
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
1060
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
1061

    
1062
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
1063
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
1064
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
1065
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
1066
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
1067
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
1068
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1069
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
1070
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
1071
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
1072

    
1073
    return effect;
1074
    }
1075

    
1076
///////////////////////////////////////////////////////////////////////////////////////////////////
1077

    
1078
  VertexEffect[] createVertexEffectsHelicopterCorner()
1079
    {
1080
    float E = 0.5f;
1081

    
1082
    Static3D axisX  = new Static3D(1,0,0);
1083
    Static3D axisY  = new Static3D(0,1,0);
1084
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
1085
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
1086
    Static1D angle1 = new Static1D(+90);
1087
    Static1D angle2 = new Static1D(-90);
1088
    Static1D angle3 = new Static1D(-135);
1089
    Static1D angle4 = new Static1D(90);
1090
    Static1D angle5 = new Static1D(120);
1091
    Static1D angle6 = new Static1D(240);
1092
    Static3D center1= new Static3D(0,0,0);
1093
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
1094
    Static3D move1  = new Static3D(-E/4,-E/4,0);
1095
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
1096

    
1097
    VertexEffect[] effect = new VertexEffect[10];
1098

    
1099
    effect[0] = new VertexEffectMove(move1);
1100
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
1101
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
1102
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
1103
    effect[4] = new VertexEffectMove(move2);
1104
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
1105
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1106
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1107
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1108
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1109

    
1110
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1111
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1112
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1113
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1114
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1115
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1116
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1117
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1118
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1119
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1120

    
1121
    return effect;
1122
    }
1123

    
1124
///////////////////////////////////////////////////////////////////////////////////////////////////
1125

    
1126
  VertexEffect[] createVertexEffectsHelicopterFace()
1127
    {
1128
    float E = 0.5f;
1129
    float F = SQ2/4;
1130

    
1131
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1132
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1133
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1134
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1135
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1136
    Static1D angle1 = new Static1D(135);
1137
    Static1D angle2 = new Static1D(90);
1138
    Static1D angle3 = new Static1D(-90);
1139
    Static1D angle4 = new Static1D(-135);
1140
    Static3D axisX  = new Static3D(1,0,0);
1141
    Static3D axisY  = new Static3D(0,1,0);
1142
    Static3D axisZ  = new Static3D(0,0,1);
1143
    Static3D axis1  = new Static3D(1,-1,0);
1144
    Static3D center = new Static3D(0,0,0);
1145
    Static3D center1= new Static3D(-E/2,-E/2,0);
1146

    
1147
    VertexEffect[] effect = new VertexEffect[10];
1148

    
1149
    effect[0] = new VertexEffectMove(move0);
1150
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1151
    effect[2] = new VertexEffectMove(move1);
1152
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1153
    effect[4] = new VertexEffectMove(move2);
1154
    effect[5] = new VertexEffectMove(move3);
1155
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1156
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1157
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1158
    effect[9] = new VertexEffectMove(move4);
1159

    
1160
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1161
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1162
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1163
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1164
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1165
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1166
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1167
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1168
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1169
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1170

    
1171
    return effect;
1172
    }
1173

    
1174
///////////////////////////////////////////////////////////////////////////////////////////////////
1175

    
1176
  VertexEffect[] createVertexEffectsRediEdge()
1177
    {
1178
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1179
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1180
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1181
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1182
    Static3D flipZ = new Static3D(1,1,-1);
1183
    Static3D flipX = new Static3D(-1,1,1);
1184
    Static3D scale = new Static3D(2,2,2);
1185
    Static3D cent0 = new Static3D(0,0, 0);
1186
    Static3D cent1 = new Static3D(0,0, -1.5f);
1187
    Static3D axisX = new Static3D(1,0, 0);
1188
    Static3D axisY = new Static3D(0,1, 0);
1189
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1190
    Static1D angle1= new Static1D(90);
1191
    Static1D angle2= new Static1D(45);
1192
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1193

    
1194
    VertexEffect[] effect = new VertexEffect[12];
1195

    
1196
    effect[0] = new VertexEffectScale(scale);
1197
    effect[1] = new VertexEffectMove(move0);
1198
    effect[2] = new VertexEffectScale(flipZ);
1199
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1200
    effect[4] = new VertexEffectMove(move1);
1201
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1202
    effect[6] = new VertexEffectMove(move2);
1203
    effect[7] = new VertexEffectScale(flipX);
1204
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1205
    effect[9] = new VertexEffectMove(move3);
1206
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1207
    effect[11]= new VertexEffectScale(flipX);
1208

    
1209
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1210
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1211
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1212
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1213
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1214
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1215
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1216
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1217
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1218
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1219
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1220
    effect[11].setMeshAssociation(32,-1); // mesh 5
1221

    
1222
    return effect;
1223
    }
1224

    
1225
///////////////////////////////////////////////////////////////////////////////////////////////////
1226

    
1227
  VertexEffect[] createVertexEffectsRediCorner()
1228
    {
1229
    Static3D axisY   = new Static3D(0,1,0);
1230
    Static3D axisX   = new Static3D(1,0,0);
1231
    Static3D axisZ   = new Static3D(0,0,1);
1232
    Static3D center  = new Static3D(0,0,0);
1233
    Static1D angle90 = new Static1D(90);
1234
    Static1D angle270= new Static1D(270);
1235
    Static1D angle45 = new Static1D(-45);
1236
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1237

    
1238
    VertexEffect[] effect = new VertexEffect[7];
1239

    
1240
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1241
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1242
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1243
    effect[3] = new VertexEffectScale(scale);
1244
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1245
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1246
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1247

    
1248
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1249
    effect[1].setMeshAssociation( 2,-1);  // 1
1250
    effect[2].setMeshAssociation( 4,-1);  // 2
1251
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1252
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1253
    effect[5].setMeshAssociation(16,-1);  // 4
1254
    effect[6].setMeshAssociation(32,-1);  // 5
1255

    
1256
    return effect;
1257
    }
1258

    
1259
///////////////////////////////////////////////////////////////////////////////////////////////////
1260

    
1261
  VertexEffect[] createVertexEffectsIvyCorner()
1262
    {
1263
    Static3D axisX  = new Static3D(1,0,0);
1264
    Static3D axisY  = new Static3D(0,1,0);
1265
    Static1D angle1 = new Static1D(+90);
1266
    Static1D angle2 = new Static1D(-90);
1267
    Static3D center = new Static3D(0,0,0);
1268
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1269

    
1270
    VertexEffect[] effect = new VertexEffect[5];
1271

    
1272
    effect[0] = new VertexEffectScale(1/IVY_C);
1273
    effect[1] = new VertexEffectMove(move1);
1274
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1275
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1276
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1277

    
1278
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1279
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1280
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1281

    
1282
    return effect;
1283
    }
1284

    
1285
///////////////////////////////////////////////////////////////////////////////////////////////////
1286

    
1287
  VertexEffect[] createVertexEffectsRexEdge()
1288
    {
1289
    float E = 0.5f - REX_D;
1290
    float F = 0.5f;
1291
    float G = (float)Math.sqrt(E*E+F*F);
1292
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1293

    
1294
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1295
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1296

    
1297
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1298
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1299
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1300
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1301
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1302
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1303

    
1304
    Static1D angle180 = new Static1D(180);
1305
    Static1D angle90  = new Static1D( 90);
1306
    Static1D angle270 = new Static1D(270);
1307
    Static1D angle1   = new Static1D(+A);
1308
    Static1D angle2   = new Static1D(-A);
1309

    
1310
    VertexEffect[] effect = new VertexEffect[12];
1311

    
1312
    effect[0] = new VertexEffectMove(move1);
1313
    effect[1] = new VertexEffectMove(move2);
1314
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1315
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1316
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1317
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1318
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1319
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1320
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1321
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1322
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1323
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1324

    
1325
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1326
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1327
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1328
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1329
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1330
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1331
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1332
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1333
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1334
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1335
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1336
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1337

    
1338
    return effect;
1339
    }
1340

    
1341
///////////////////////////////////////////////////////////////////////////////////////////////////
1342

    
1343
  VertexEffect[] createVertexEffectsRexCorner()
1344
    {
1345
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1346
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1347
    Static1D angle = new Static1D(225);
1348

    
1349
    VertexEffect[] effect = new VertexEffect[1];
1350
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1351

    
1352
    return effect;
1353
    }
1354

    
1355
///////////////////////////////////////////////////////////////////////////////////////////////////
1356

    
1357
  VertexEffect[] createVertexEffectsKilominxCenter(float width)
1358
    {
1359
    VertexEffect[] effect = new VertexEffect[10];
1360

    
1361
    float H = 0.5f*(SIN54/COS54);
1362
    float Y1= 0.5f*SIN_HALFD;
1363
    float Y2= H/(2*COS_HALFD);
1364
    float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18));
1365
    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
1366

    
1367
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1368
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1369
    Static3D axisA = new Static3D(-SIN18, cos18, 0.0f);
1370
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H* SIN_HALFD /(COS_HALFD*LEN));
1371

    
1372
    Static3D move1 = new Static3D(0,-Y1,0);
1373
    Static3D move2 = new Static3D(0,-Y2,0);
1374
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*SIN18,0);
1375
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1376

    
1377
    Static1D angle1 = new Static1D(54);
1378
    Static1D angle2 = new Static1D(DIHEDRAL1/2+18);
1379
    Static1D angle3 = new Static1D(90);
1380
    Static1D angle4 = new Static1D(120);
1381
    Static1D angle5 = new Static1D(240);
1382
    Static1D angle6 = new Static1D(90-DIHEDRAL1/2);
1383

    
1384
    effect[0] = new VertexEffectMove(move1);
1385
    effect[1] = new VertexEffectScale(1/MINX_SC);
1386
    effect[2] = new VertexEffectMove(move2);
1387
    effect[3] = new VertexEffectRotate(angle1, axisZ, center);
1388
    effect[4] = new VertexEffectRotate(angle2, axisZ, center);
1389
    effect[5] = new VertexEffectRotate(angle3, axisA, center);
1390
    effect[6] = new VertexEffectMove(move3);
1391
    effect[7] = new VertexEffectRotate(angle4, axisC, center);
1392
    effect[8] = new VertexEffectRotate(angle5, axisC, center);
1393
    effect[9] = new VertexEffectRotate(angle6, axisY, center);
1394

    
1395
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1396
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1397
    effect[2].setMeshAssociation(56,-1);  // meshes 3,4,5
1398
    effect[3].setMeshAssociation( 7,-1);  // meshes 0,1,2
1399
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1400
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1401
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1402
    effect[7].setMeshAssociation(18,-1);  // meshes 1,4
1403
    effect[8].setMeshAssociation(36,-1);  // meshes 2,5
1404

    
1405
    return effect;
1406
    }
1407

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

    
1410
  VertexEffect[] createVertexEffectsMegaminxCorner(int numLayers)
1411
    {
1412
    VertexEffect[] effect = new VertexEffect[9];
1413

    
1414
    float Y = COS54/(2*SIN54);
1415

    
1416
    float sinA = (2*SIN54*SIN54-1)/COS54;
1417
    float cosA = (float)Math.sqrt(1-sinA*sinA);
1418
    float LEN  = 0.5f/SIN54;
1419
    float scale= (numLayers/3.0f)*(0.5f-MEGA_D)/(LEN*0.5f*(numLayers-1));
1420

    
1421
    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
1422
    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
1423
    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
1424

    
1425
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1426
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1427

    
1428
    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
1429
    Static3D move2= new Static3D(0.0f, Y , 0.0f );
1430

    
1431
    Static1D angleD = new Static1D(DIHEDRAL1);
1432
    Static1D angleE = new Static1D(360-DIHEDRAL1);
1433
    Static1D angleF = new Static1D(DIHEDRAL2);
1434

    
1435
    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
1436
    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
1437
    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
1438
    effect[3] = new VertexEffectMove(move1);
1439
    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
1440
    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
1441
    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
1442
    effect[7] = new VertexEffectMove(move2);
1443
    effect[8] = new VertexEffectScale(scale);
1444

    
1445
    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
1446
    effect[1].setMeshAssociation( 16,-1);  // mesh 4
1447
    effect[2].setMeshAssociation( 32,-1);  // mesh 5
1448
    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
1449
    effect[4].setMeshAssociation(  1,-1);  // mesh 0
1450
    effect[5].setMeshAssociation(  2,-1);  // mesh 1
1451

    
1452
    return effect;
1453
    }
1454

    
1455
///////////////////////////////////////////////////////////////////////////////////////////////////
1456

    
1457
  VertexEffect[] createVertexEffectsMegaminxEdge(float width, float height)
1458
    {
1459
    VertexEffect[] effect = new VertexEffect[11];
1460

    
1461
    float X = 0.5f*height;
1462
    float Y = height*(COS54/COS18) + width*0.5f;
1463
    float Z = 2*height*COS_HALFD;
1464

    
1465
    float alpha = 90-DIHEDRAL1/2;
1466
    float beta  = DIHEDRAL2;
1467

    
1468
    Static1D angle1 = new Static1D(alpha);
1469
    Static1D angle2 = new Static1D(180-alpha);
1470
    Static1D angle3 = new Static1D(beta);
1471

    
1472
    Static3D move1 = new Static3D(X,0,0);
1473
    Static3D move2 = new Static3D(X,0,-Z);
1474
    Static3D move3 = new Static3D(0,+Y,0);
1475
    Static3D move4 = new Static3D(0,-Y,0);
1476
    Static3D scale = new Static3D(+1,+1,-1);
1477

    
1478
    Static3D axisXplus = new Static3D(+1, 0, 0);
1479
    Static3D axisXminus= new Static3D(-1, 0, 0);
1480
    Static3D axisYplus = new Static3D( 0,+1, 0);
1481
    Static3D axisYminus= new Static3D( 0,-1, 0);
1482

    
1483
    Static3D center1= new Static3D( 0, 0, 0);
1484
    Static3D center2= new Static3D( 0, 0,-Z);
1485
    Static3D center3= new Static3D( 0,+width*0.5f, 0);
1486
    Static3D center4= new Static3D( 0,-width*0.5f, 0);
1487

    
1488
    effect[ 0] = new VertexEffectMove(move1);
1489
    effect[ 1] = new VertexEffectMove(move2);
1490
    effect[ 2] = new VertexEffectMove(move3);
1491
    effect[ 3] = new VertexEffectMove(move4);
1492
    effect[ 4] = new VertexEffectScale(scale);
1493
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1494
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1495
    effect[ 7] = new VertexEffectRotate(angle1, axisYminus, center2);
1496
    effect[ 8] = new VertexEffectRotate(angle2, axisYminus, center2);
1497
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center3);
1498
    effect[10] = new VertexEffectRotate(angle3, axisXminus, center4);
1499

    
1500
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1501
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1502
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1503
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1504
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1505
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1506
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1507
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1508
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1509
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1510
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1511

    
1512
    return effect;
1513
    }
1514

    
1515
///////////////////////////////////////////////////////////////////////////////////////////////////
1516

    
1517
  VertexEffect[] createVertexEffectsMegaminxCenter(float width)
1518
    {
1519
    VertexEffect[] effect = new VertexEffect[2];
1520

    
1521
    Static1D angle = new Static1D(DIHEDRAL2);
1522
    Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
1523
    Static3D center= new Static3D( 0, 0, 0);
1524

    
1525
    effect[0] = new VertexEffectScale(width/COS54);
1526
    effect[1] = new VertexEffectRotate(angle, axisX, center);
1527

    
1528
    return effect;
1529
    }
1530

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

    
1533
  VertexEffect[] createCuboidEffects(int[] dimensions)
1534
    {
1535
    float X = dimensions[0];
1536
    float Y = dimensions[1];
1537
    float Z = dimensions[2];
1538

    
1539
    float MAX_XY = Math.max(X,Y);
1540
    float MAX_XZ = Math.max(X,Z);
1541
    float MAX_YZ = Math.max(Z,Y);
1542

    
1543
    Static1D angle = new Static1D(90);
1544
    Static3D move  = new Static3D( 0.0f, 0.0f, 0.5f);
1545
    Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
1546
    Static3D axisY = new Static3D( 0.0f, 1.0f, 0.0f);
1547
    Static3D center= new Static3D( 0.0f, 0.0f, 0.0f);
1548

    
1549
    Static3D scale3 = new Static3D(MAX_XY,MAX_XY,+Z);
1550
    Static3D scale4 = new Static3D(MAX_XY,MAX_XY,-Z);
1551
    Static3D scale5 = new Static3D(MAX_XZ,+Y,MAX_XZ);
1552
    Static3D scale6 = new Static3D(MAX_XZ,-Y,MAX_XZ);
1553
    Static3D scale7 = new Static3D(+X,MAX_YZ,MAX_YZ);
1554
    Static3D scale8 = new Static3D(-X,MAX_YZ,MAX_YZ);
1555

    
1556
    VertexEffect[] effect = new VertexEffect[9];
1557

    
1558
    effect[0] = new VertexEffectMove(move);
1559
    effect[1] = new VertexEffectRotate(angle, axisX, center);
1560
    effect[2] = new VertexEffectRotate(angle, axisY, center);
1561
    effect[3] = new VertexEffectScale(scale3);
1562
    effect[4] = new VertexEffectScale(scale4);
1563
    effect[5] = new VertexEffectScale(scale5);
1564
    effect[6] = new VertexEffectScale(scale6);
1565
    effect[7] = new VertexEffectScale(scale7);
1566
    effect[8] = new VertexEffectScale(scale8);
1567

    
1568
    effect[1].setMeshAssociation(12,-1);  // meshes 2,3
1569
    effect[2].setMeshAssociation( 3,-1);  // meshes 0,1
1570
    effect[3].setMeshAssociation(16,-1);  // mesh 4
1571
    effect[4].setMeshAssociation(32,-1);  // mesh 5
1572
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1573
    effect[6].setMeshAssociation( 4,-1);  // mesh 2
1574
    effect[7].setMeshAssociation( 1,-1);  // mesh 0
1575
    effect[8].setMeshAssociation( 2,-1);  // mesh 1
1576

    
1577
    return effect;
1578
    }
1579

    
1580
///////////////////////////////////////////////////////////////////////////////////////////////////
1581
// OBJECTS
1582
///////////////////////////////////////////////////////////////////////////////////////////////////
1583
// CUBE
1584

    
1585
  MeshBase createCubeMesh(int index)
1586
    {
1587
    MeshBase mesh = createFacesCube(index);
1588
    VertexEffect[] effects = createVertexEffectsCube();
1589
    for( VertexEffect effect : effects ) mesh.apply(effect);
1590

    
1591
    Static3D roundingCenter  = new Static3D(0,0,0);
1592
    Static3D[] vertices = new Static3D[8];
1593
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1594
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1595
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1596
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1597
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1598
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1599
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1600
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1601

    
1602
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1603

    
1604
    mesh.mergeEffComponents();
1605

    
1606
    return mesh;
1607
    }
1608

    
1609
///////////////////////////////////////////////////////////////////////////////////////////////////
1610
// SKEWB
1611

    
1612
  MeshBase createSkewbCornerMesh()
1613
    {
1614
    MeshBase mesh = createFacesSkewbCorner();
1615
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1616
    for( VertexEffect effect : effects ) mesh.apply(effect);
1617

    
1618
    float E = 0.5f;
1619
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1620

    
1621
    Static3D[] verticesType1 = new Static3D[1];
1622
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1623
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1624

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

    
1631
    mesh.mergeEffComponents();
1632

    
1633
    return mesh;
1634
    }
1635

    
1636
///////////////////////////////////////////////////////////////////////////////////////////////////
1637

    
1638
  MeshBase createSkewbFaceMesh()
1639
    {
1640
    MeshBase mesh = createFacesSkewbFace();
1641
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1642
    for( VertexEffect effect : effects ) mesh.apply(effect);
1643

    
1644
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1645
    float E = SQ2/4;
1646
    Static3D[] vertices = new Static3D[4];
1647
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1648
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1649
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1650
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1651
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1652

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

    
1656
    return mesh;
1657
    }
1658

    
1659
///////////////////////////////////////////////////////////////////////////////////////////////////
1660
// SKEWB DIAMOND / PYRAMINX
1661

    
1662
  MeshBase createOctaMesh()
1663
    {
1664
    MeshBase mesh = createFacesOcta();
1665
    VertexEffect[] effects = createVertexEffectsOcta();
1666
    for( VertexEffect effect : effects ) mesh.apply(effect);
1667

    
1668
    Static3D roundingCenter = new Static3D(0,0,0);
1669
    Static3D[] vertices = new Static3D[6];
1670
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1671
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1672
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1673
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1674
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1675
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1676

    
1677
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1678

    
1679
    mesh.mergeEffComponents();
1680

    
1681
    return mesh;
1682
    }
1683

    
1684
///////////////////////////////////////////////////////////////////////////////////////////////////
1685

    
1686
  MeshBase createTetraMesh()
1687
    {
1688
    MeshBase mesh = createFacesTetra();
1689
    VertexEffect[] effects = createVertexEffectsTetra();
1690
    for( VertexEffect effect : effects ) mesh.apply(effect);
1691

    
1692
    Static3D roundingCenter = new Static3D(0,0,0);
1693
    Static3D[] verticesRound = new Static3D[4];
1694
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1695
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1696
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1697
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1698
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1699

    
1700
    mesh.mergeEffComponents();
1701
    mesh.addEmptyTexComponent();
1702
    mesh.addEmptyTexComponent();
1703
    mesh.addEmptyTexComponent();
1704
    mesh.addEmptyTexComponent();
1705

    
1706
    return mesh;
1707
    }
1708

    
1709
///////////////////////////////////////////////////////////////////////////////////////////////////
1710
// DINO
1711

    
1712
  MeshBase createDinoMesh()
1713
    {
1714
    MeshBase mesh = createFacesDino();
1715
    VertexEffect[] effects = createVertexEffectsDino();
1716
    for( VertexEffect effect : effects ) mesh.apply(effect);
1717

    
1718
    float F = 0.5f;
1719
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1720
    Static3D[] verticesRound = new Static3D[4];
1721
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1722
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1723
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1724
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1725
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1726

    
1727
    mesh.mergeEffComponents();
1728

    
1729
    return mesh;
1730
    }
1731

    
1732
///////////////////////////////////////////////////////////////////////////////////////////////////
1733
// Helicopter
1734

    
1735
  MeshBase createHelicopterCornerMesh()
1736
    {
1737
    MeshBase mesh = createFacesHelicopterCorner();
1738
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1739
    for( VertexEffect effect : effects ) mesh.apply(effect);
1740

    
1741
    float E = 0.5f;
1742
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1743

    
1744
    Static3D[] verticesType1 = new Static3D[1];
1745
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1746
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1747

    
1748
    Static3D[] verticesType2 = new Static3D[3];
1749
    verticesType2[0] = new Static3D(-E, 0, 0);
1750
    verticesType2[1] = new Static3D( 0,-E, 0);
1751
    verticesType2[2] = new Static3D( 0, 0,-E);
1752
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1753

    
1754
    mesh.mergeEffComponents();
1755

    
1756
    return mesh;
1757
    }
1758

    
1759
///////////////////////////////////////////////////////////////////////////////////////////////////
1760

    
1761
  MeshBase createHelicopterFaceMesh()
1762
    {
1763
    MeshBase mesh = createFacesHelicopterFace();
1764
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1765
    for( VertexEffect effect : effects ) mesh.apply(effect);
1766

    
1767
    float E = 0.5f;
1768
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1769

    
1770
    Static3D[] verticesType1 = new Static3D[1];
1771
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1772
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1773

    
1774
    Static3D[] verticesType2 = new Static3D[2];
1775
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1776
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1777
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1778

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

    
1783
    return mesh;
1784
    }
1785

    
1786
///////////////////////////////////////////////////////////////////////////////////////////////////
1787
// Redi cube
1788

    
1789
  MeshBase createRediEdgeMesh()
1790
    {
1791
    MeshBase mesh = createFacesRediEdge();
1792
    VertexEffect[] effects = createVertexEffectsRediEdge();
1793
    for( VertexEffect effect : effects ) mesh.apply(effect);
1794

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

    
1801
    mesh.mergeEffComponents();
1802

    
1803
    return mesh;
1804
    }
1805

    
1806
///////////////////////////////////////////////////////////////////////////////////////////////////
1807

    
1808
  MeshBase createRediCornerMesh()
1809
    {
1810
    MeshBase mesh = createFacesRediCorner();
1811
    VertexEffect[] effects = createVertexEffectsRediCorner();
1812
    for( VertexEffect effect : effects ) mesh.apply(effect);
1813

    
1814
    Static3D center = new Static3D(0,0,0);
1815
    Static3D[] vertices = new Static3D[8];
1816
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1817
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1818
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1819
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1820
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1821
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1822
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1823
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1824

    
1825
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1826

    
1827
    mesh.mergeEffComponents();
1828

    
1829
    return mesh;
1830
    }
1831

    
1832
///////////////////////////////////////////////////////////////////////////////////////////////////
1833

    
1834
  MeshBase createIvyCornerMesh()
1835
    {
1836
    MeshBase mesh = createFacesIvyCorner();
1837
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1838
    for( VertexEffect effect : effects ) mesh.apply(effect);
1839

    
1840
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1841
    Static3D[] vertices = new Static3D[4];
1842
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1843
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1844
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1845
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1846

    
1847
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1848

    
1849
    mesh.mergeEffComponents();
1850

    
1851
    return mesh;
1852
    }
1853

    
1854
///////////////////////////////////////////////////////////////////////////////////////////////////
1855

    
1856
  MeshBase createIvyFaceMesh()
1857
    {
1858
    MeshBase mesh = createFacesIvyFace();
1859

    
1860
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1861
    Static3D[] vertices = new Static3D[2];
1862
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1863
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1864

    
1865
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1866

    
1867
    mesh.mergeEffComponents();
1868
    mesh.addEmptyTexComponent();
1869
    mesh.addEmptyTexComponent();
1870
    mesh.addEmptyTexComponent();
1871
    mesh.addEmptyTexComponent();
1872

    
1873
    return mesh;
1874
    }
1875

    
1876
///////////////////////////////////////////////////////////////////////////////////////////////////
1877

    
1878
  MeshBase createRexCornerMesh()
1879
    {
1880
    MeshBase mesh = createFacesRexCorner();
1881
    VertexEffect[] effects = createVertexEffectsRexCorner();
1882
    for( VertexEffect effect : effects ) mesh.apply(effect);
1883

    
1884
    final float G = (1-REX_D)/3;
1885
    Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
1886
    Static3D[] vertices = new Static3D[1];
1887
    vertices[0] = new Static3D(+G,-G,+0.0f);
1888
    roundCorners(mesh,center,vertices,0.10f,0.10f);
1889

    
1890
    mesh.mergeEffComponents();
1891
    mesh.addEmptyTexComponent();
1892
    mesh.addEmptyTexComponent();
1893
    mesh.addEmptyTexComponent();
1894
    mesh.addEmptyTexComponent();
1895

    
1896
    return mesh;
1897
    }
1898

    
1899
///////////////////////////////////////////////////////////////////////////////////////////////////
1900

    
1901
  MeshBase createRexFaceMesh()
1902
    {
1903
    MeshBase mesh = createFacesRexFace();
1904

    
1905
    mesh.mergeEffComponents();
1906
    mesh.addEmptyTexComponent();
1907
    mesh.addEmptyTexComponent();
1908
    mesh.addEmptyTexComponent();
1909
    mesh.addEmptyTexComponent();
1910

    
1911
    return mesh;
1912
    }
1913

    
1914
///////////////////////////////////////////////////////////////////////////////////////////////////
1915

    
1916
  MeshBase createRexEdgeMesh()
1917
    {
1918
    MeshBase mesh = createFacesRexEdge();
1919
    VertexEffect[] effects = createVertexEffectsRexEdge();
1920
    for( VertexEffect effect : effects ) mesh.apply(effect);
1921

    
1922
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1923
    Static3D[] vertices = new Static3D[2];
1924
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1925
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1926
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1927

    
1928
    mesh.mergeEffComponents();
1929

    
1930
    return mesh;
1931
    }
1932

    
1933
///////////////////////////////////////////////////////////////////////////////////////////////////
1934

    
1935
  MeshBase createKilominxCenterMesh(float width)
1936
    {
1937
    MeshBase mesh = createFacesKilominxCenter();
1938
    VertexEffect[] effects = createVertexEffectsKilominxCenter(width);
1939
    for( VertexEffect effect : effects ) mesh.apply(effect);
1940

    
1941
    float A = (2*SQ3/3)* SIN54;
1942
    float B = 0.4f;
1943
    float X = SIN_HALFD * SIN54 *COS54  ;
1944
    float Y = SIN54 * SIN54 - 0.5f;
1945
    float Z = COS_HALFD* SIN54 *COS54  ;
1946

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

    
1949
    Static3D[] vertices = new Static3D[4];
1950
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1951
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1952
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1953
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1954

    
1955
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1956

    
1957
    mesh.mergeEffComponents();
1958

    
1959
    return mesh;
1960
    }
1961

    
1962
///////////////////////////////////////////////////////////////////////////////////////////////////
1963
// numLayers==3 --> index=0; numLayers=5 --> index=1 ...
1964
// type: 0,1,... 0 --> edge, 1 --> 1 layer deeper, etc
1965
// TODO
1966

    
1967
  MeshBase createKilominxEdgeMesh(int numLayers, float width, float height)
1968
    {
1969
    MeshBase mesh = createFacesMegaminxEdge(numLayers,width,height);
1970
    VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
1971
    for( VertexEffect effect : effects ) mesh.apply(effect);
1972

    
1973
    mesh.mergeEffComponents();
1974

    
1975
    return mesh;
1976
    }
1977

    
1978
///////////////////////////////////////////////////////////////////////////////////////////////////
1979

    
1980
  MeshBase createMinxCornerMesh(ObjectList object, int numLayers)
1981
    {
1982
    MeshBase mesh = createFacesMegaminxCorner(numLayers);
1983
    VertexEffect[] effects = createVertexEffectsMegaminxCorner(numLayers);
1984
    for( VertexEffect effect : effects ) mesh.apply(effect);
1985

    
1986
    float A = (2*SQ3/3)* SIN54;
1987
    float B = 0.4f;
1988
    float X = SIN_HALFD* SIN54 * COS54;
1989
    float Y = SIN54 * SIN54 - 0.5f;
1990
    float Z = COS_HALFD* SIN54 * COS54;
1991
    float S = 2*SIN54*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
1992

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

    
1995
    Static3D[] vertices = new Static3D[4];
1996
    vertices[0] = new Static3D( 0.0f, 0.0f  , 0.0f);
1997
    vertices[1] = new Static3D( 0.0f,-0.5f*S, 0.0f);
1998
    vertices[2] = new Static3D(-X*S , Y*S   ,-Z*S );
1999
    vertices[3] = new Static3D(+X*S , Y*S   ,-Z*S );
2000

    
2001
    roundCorners(mesh,center,vertices,0.04f,0.10f);
2002

    
2003
    mesh.mergeEffComponents();
2004

    
2005
    return mesh;
2006
    }
2007

    
2008
///////////////////////////////////////////////////////////////////////////////////////////////////
2009
// numLayers==3 --> index=0; numLayers=5 --> index=1 ...
2010
// type: 0,1,... 0 --> edge, 1 --> 1 layer deeper, etc
2011

    
2012
  MeshBase createMegaminxEdgeMesh(int numLayers, float width, float height)
2013
    {
2014
    MeshBase mesh = createFacesMegaminxEdge(numLayers,width,height);
2015
    VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
2016
    for( VertexEffect effect : effects ) mesh.apply(effect);
2017

    
2018
    mesh.mergeEffComponents();
2019

    
2020
    return mesh;
2021
    }
2022

    
2023
///////////////////////////////////////////////////////////////////////////////////////////////////
2024

    
2025
  MeshBase createMegaminxCenterMesh(int numLayers, float width)
2026
    {
2027
    MeshBase mesh = createFacesMegaminxCenter(numLayers);
2028
    VertexEffect[] effects = createVertexEffectsMegaminxCenter(width);
2029
    for( VertexEffect effect : effects ) mesh.apply(effect);
2030

    
2031
    mesh.mergeEffComponents();
2032
    mesh.addEmptyTexComponent();
2033
    mesh.addEmptyTexComponent();
2034
    mesh.addEmptyTexComponent();
2035
    mesh.addEmptyTexComponent();
2036

    
2037
    return mesh;
2038
    }
2039

    
2040
///////////////////////////////////////////////////////////////////////////////////////////////////
2041

    
2042
  MeshBase createCuboidMesh(int[] dimensions)
2043
    {
2044
    MeshBase mesh = createCuboid(dimensions);
2045
    VertexEffect[] effects = createCuboidEffects(dimensions);
2046
    for( VertexEffect effect : effects ) mesh.apply(effect);
2047

    
2048
    int X = dimensions[0];
2049
    int Y = dimensions[1];
2050
    int Z = dimensions[2];
2051

    
2052
    float strength = 0.04f;
2053
    float radius   = 0.15f;
2054

    
2055
    Static3D[] vertices = new Static3D[1];
2056
    Static3D center;
2057

    
2058
    vertices[0] = new Static3D(+0.5f*X,+0.5f*Y,+0.5f*Z);
2059
    center = new Static3D(+0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1));
2060
    roundCorners(mesh, center, vertices, strength, radius);
2061

    
2062
    vertices[0] = new Static3D(+0.5f*X,+0.5f*Y,-0.5f*Z);
2063
    center = new Static3D(+0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1));
2064
    roundCorners(mesh, center, vertices, strength, radius);
2065

    
2066
    vertices[0] = new Static3D(+0.5f*X,-0.5f*Y,+0.5f*Z);
2067
    center = new Static3D(+0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1));
2068
    roundCorners(mesh, center, vertices, strength, radius);
2069

    
2070
    vertices[0] = new Static3D(+0.5f*X,-0.5f*Y,-0.5f*Z);
2071
    center = new Static3D(+0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1));
2072
    roundCorners(mesh, center, vertices, strength, radius);
2073

    
2074
    vertices[0] = new Static3D(-0.5f*X,+0.5f*Y,+0.5f*Z);
2075
    center = new Static3D(-0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1));
2076
    roundCorners(mesh, center, vertices, strength, radius);
2077

    
2078
    vertices[0] = new Static3D(-0.5f*X,+0.5f*Y,-0.5f*Z);
2079
    center = new Static3D(-0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1));
2080
    roundCorners(mesh, center, vertices, strength, radius);
2081

    
2082
    vertices[0] = new Static3D(-0.5f*X,-0.5f*Y,+0.5f*Z);
2083
    center = new Static3D(-0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1));
2084
    roundCorners(mesh, center, vertices, strength, radius);
2085

    
2086
    vertices[0] = new Static3D(-0.5f*X,-0.5f*Y,-0.5f*Z);
2087
    center = new Static3D(-0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1));
2088
    roundCorners(mesh, center, vertices, strength, radius);
2089

    
2090
    mesh.mergeEffComponents();
2091

    
2092
    return mesh;
2093
    }
2094
  }
(2-2/35)