Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ b5347187

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
  private static final float SQ2 = (float)Math.sqrt(2);
41
  private static final float SQ3 = (float)Math.sqrt(3);
42
  private static final float SQ5 = (float)Math.sqrt(5);
43
  private static final float SQ6 = (float)Math.sqrt(6);
44

    
45
  private static final Static1D RADIUS = new Static1D(1);
46
  private static FactoryCubit mThis;
47

    
48
  // IVY
49
  static final float IVY_D = 0.003f;
50
  static final float IVY_C = 0.59f;
51
  static final float IVY_M = 0.35f;
52
  private static final int IVY_N = 8;
53

    
54
  // REX
55
  static final float REX_D = 0.2f;
56

    
57
  // KILO / MEGAMINX
58
  static final float SIN54    = (SQ5+1)/4;
59
  static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
60
  static final float SIN18    = (SQ5-1)/4;
61
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
62
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
63
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
64
  static final float DIHEDRAL1= (float)(Math.acos(-SQ5/5)*180/Math.PI);
65
  static final float DIHEDRAL2= (float)((180/Math.PI)*Math.asin((2*SIN54*SIN54-1)/COS54) - 90);
66
  static final float MINX_SC  = 0.5f;
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
  private FactoryCubit()
71
    {
72

    
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

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

    
81
    return mThis;
82
    }
83

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

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

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

    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

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

    
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135

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

    
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142

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

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

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

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

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

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

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

    
189
    return bands;
190
    }
191

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

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

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

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

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

    
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214

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

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

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

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

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

    
246
    return new MeshJoined(meshes);
247
    }
248

    
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

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

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

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

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

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

    
278
    return new MeshJoined(meshes);
279
    }
280

    
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

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

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

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

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

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

    
306
    return new MeshJoined(meshes);
307
    }
308

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

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

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

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

    
337
    return new MeshJoined(meshes);
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

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

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

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

    
360
    return new MeshJoined(meshes);
361
    }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

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

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

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

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

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

    
387
    return new MeshJoined(meshes);
388
    }
389

    
390
///////////////////////////////////////////////////////////////////////////////////////////////////
391

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

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

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

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

    
418
    return new MeshJoined(meshes);
419
    }
420

    
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422

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

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

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

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

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

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

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

    
449
    return new MeshJoined(meshes);
450
    }
451

    
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453

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

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

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

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

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

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

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

    
484
    return new MeshJoined(meshes);
485
    }
486

    
487
///////////////////////////////////////////////////////////////////////////////////////////////////
488

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

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

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

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

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

    
517
    return new MeshJoined(meshes);
518
    }
519

    
520
///////////////////////////////////////////////////////////////////////////////////////////////////
521

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

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

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

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

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

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

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

    
564
    return new MeshJoined(meshes);
565
    }
566

    
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568

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

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

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

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

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

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

    
596
    return new MeshJoined(meshes);
597
    }
598

    
599
///////////////////////////////////////////////////////////////////////////////////////////////////
600

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

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

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

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

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

    
620
    return new MeshJoined(meshes);
621
    }
622

    
623
///////////////////////////////////////////////////////////////////////////////////////////////////
624

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

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

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

    
634
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
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 createFacesRexEdge()
645
    {
646
    MeshBase[] meshes = new MeshPolygon[6];
647

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

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

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

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

    
671
    return new MeshJoined(meshes);
672
    }
673

    
674
///////////////////////////////////////////////////////////////////////////////////////////////////
675

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

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

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

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

    
706
    return new MeshJoined(meshes);
707
    }
708

    
709
///////////////////////////////////////////////////////////////////////////////////////////////////
710

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

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

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

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

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

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

    
740
    return new MeshJoined(meshes);
741
    }
742

    
743
///////////////////////////////////////////////////////////////////////////////////////////////////
744

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

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

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

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

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

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

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

    
783
    return new MeshJoined(meshes);
784
    }
785

    
786
///////////////////////////////////////////////////////////////////////////////////////////////////
787

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

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

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

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

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

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

    
812
    return new MeshJoined(meshes);
813
    }
814

    
815
///////////////////////////////////////////////////////////////////////////////////////////////////
816

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

    
823
///////////////////////////////////////////////////////////////////////////////////////////////////
824

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

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

    
835
    float defHeight = 0.048f;
836

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

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

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

    
856
    return new MeshJoined(meshes);
857
    }
858

    
859
///////////////////////////////////////////////////////////////////////////////////////////////////
860
// EFFECTS
861
///////////////////////////////////////////////////////////////////////////////////////////////////
862

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

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

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

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

    
888
    return effect;
889
    }
890

    
891
///////////////////////////////////////////////////////////////////////////////////////////////////
892

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

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

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

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

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

    
936
    return effect;
937
    }
938

    
939
///////////////////////////////////////////////////////////////////////////////////////////////////
940

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

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

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

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

    
964
    return effect;
965
    }
966

    
967
///////////////////////////////////////////////////////////////////////////////////////////////////
968

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

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

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

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

    
998
    return effect;
999
    }
1000

    
1001
///////////////////////////////////////////////////////////////////////////////////////////////////
1002

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

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

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

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

    
1031
    return effect;
1032
    }
1033

    
1034
///////////////////////////////////////////////////////////////////////////////////////////////////
1035

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

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

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

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

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

    
1074
    return effect;
1075
    }
1076

    
1077
///////////////////////////////////////////////////////////////////////////////////////////////////
1078

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

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

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

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

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

    
1122
    return effect;
1123
    }
1124

    
1125
///////////////////////////////////////////////////////////////////////////////////////////////////
1126

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

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

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

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

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

    
1172
    return effect;
1173
    }
1174

    
1175
///////////////////////////////////////////////////////////////////////////////////////////////////
1176

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

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

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

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

    
1223
    return effect;
1224
    }
1225

    
1226
///////////////////////////////////////////////////////////////////////////////////////////////////
1227

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

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

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

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

    
1257
    return effect;
1258
    }
1259

    
1260
///////////////////////////////////////////////////////////////////////////////////////////////////
1261

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

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

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

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

    
1283
    return effect;
1284
    }
1285

    
1286
///////////////////////////////////////////////////////////////////////////////////////////////////
1287

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

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

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

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

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

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

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

    
1339
    return effect;
1340
    }
1341

    
1342
///////////////////////////////////////////////////////////////////////////////////////////////////
1343

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

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

    
1353
    return effect;
1354
    }
1355

    
1356
///////////////////////////////////////////////////////////////////////////////////////////////////
1357

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

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

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

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

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

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

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

    
1407
    return effect;
1408
    }
1409

    
1410
///////////////////////////////////////////////////////////////////////////////////////////////////
1411

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

    
1416
    float Y = COS54/(2*SIN54);
1417

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

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

    
1427
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1428
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1429

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

    
1433
    Static1D angleD = new Static1D(DIHEDRAL1);
1434
    Static1D angleE = new Static1D(360-DIHEDRAL1);
1435
    Static1D angleF = new Static1D(DIHEDRAL2);
1436

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

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

    
1454
    return effect;
1455
    }
1456

    
1457
///////////////////////////////////////////////////////////////////////////////////////////////////
1458

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

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

    
1467
    float alpha = 90-DIHEDRAL1/2;
1468
    float beta  = DIHEDRAL2;
1469

    
1470
    Static1D angle1 = new Static1D(alpha);
1471
    Static1D angle2 = new Static1D(180-alpha);
1472
    Static1D angle3 = new Static1D(beta);
1473

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

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

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

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

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

    
1514
    return effect;
1515
    }
1516

    
1517
///////////////////////////////////////////////////////////////////////////////////////////////////
1518

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

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

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

    
1530
    return effect;
1531
    }
1532

    
1533
///////////////////////////////////////////////////////////////////////////////////////////////////
1534

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

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

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

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

    
1558
    VertexEffect[] effect = new VertexEffect[9];
1559

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

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

    
1579
    return effect;
1580
    }
1581

    
1582
///////////////////////////////////////////////////////////////////////////////////////////////////
1583
// OBJECTS
1584
///////////////////////////////////////////////////////////////////////////////////////////////////
1585
// CUBE
1586

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

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

    
1604
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1605

    
1606
    mesh.mergeEffComponents();
1607

    
1608
    return mesh;
1609
    }
1610

    
1611
///////////////////////////////////////////////////////////////////////////////////////////////////
1612
// SKEWB
1613

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

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

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

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

    
1633
    mesh.mergeEffComponents();
1634

    
1635
    return mesh;
1636
    }
1637

    
1638
///////////////////////////////////////////////////////////////////////////////////////////////////
1639

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

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

    
1655
    mesh.mergeEffComponents();
1656
    mesh.addEmptyTexComponent();
1657

    
1658
    return mesh;
1659
    }
1660

    
1661
///////////////////////////////////////////////////////////////////////////////////////////////////
1662
// SKEWB DIAMOND / PYRAMINX
1663

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

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

    
1679
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1680

    
1681
    mesh.mergeEffComponents();
1682

    
1683
    return mesh;
1684
    }
1685

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

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

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

    
1702
    mesh.mergeEffComponents();
1703
    mesh.addEmptyTexComponent();
1704
    mesh.addEmptyTexComponent();
1705
    mesh.addEmptyTexComponent();
1706
    mesh.addEmptyTexComponent();
1707

    
1708
    return mesh;
1709
    }
1710

    
1711
///////////////////////////////////////////////////////////////////////////////////////////////////
1712
// DINO
1713

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

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

    
1729
    mesh.mergeEffComponents();
1730

    
1731
    return mesh;
1732
    }
1733

    
1734
///////////////////////////////////////////////////////////////////////////////////////////////////
1735
// Helicopter
1736

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

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

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

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

    
1756
    mesh.mergeEffComponents();
1757

    
1758
    return mesh;
1759
    }
1760

    
1761
///////////////////////////////////////////////////////////////////////////////////////////////////
1762

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

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

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

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

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

    
1785
    return mesh;
1786
    }
1787

    
1788
///////////////////////////////////////////////////////////////////////////////////////////////////
1789
// Redi cube
1790

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

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

    
1803
    mesh.mergeEffComponents();
1804

    
1805
    return mesh;
1806
    }
1807

    
1808
///////////////////////////////////////////////////////////////////////////////////////////////////
1809

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

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

    
1827
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1828

    
1829
    mesh.mergeEffComponents();
1830

    
1831
    return mesh;
1832
    }
1833

    
1834
///////////////////////////////////////////////////////////////////////////////////////////////////
1835

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

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

    
1849
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1850

    
1851
    mesh.mergeEffComponents();
1852

    
1853
    return mesh;
1854
    }
1855

    
1856
///////////////////////////////////////////////////////////////////////////////////////////////////
1857

    
1858
  MeshBase createIvyFaceMesh()
1859
    {
1860
    MeshBase mesh = createFacesIvyFace();
1861

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

    
1867
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1868

    
1869
    mesh.mergeEffComponents();
1870
    mesh.addEmptyTexComponent();
1871
    mesh.addEmptyTexComponent();
1872
    mesh.addEmptyTexComponent();
1873
    mesh.addEmptyTexComponent();
1874

    
1875
    return mesh;
1876
    }
1877

    
1878
///////////////////////////////////////////////////////////////////////////////////////////////////
1879

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

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

    
1892
    mesh.mergeEffComponents();
1893
    mesh.addEmptyTexComponent();
1894
    mesh.addEmptyTexComponent();
1895
    mesh.addEmptyTexComponent();
1896
    mesh.addEmptyTexComponent();
1897

    
1898
    return mesh;
1899
    }
1900

    
1901
///////////////////////////////////////////////////////////////////////////////////////////////////
1902

    
1903
  MeshBase createRexFaceMesh()
1904
    {
1905
    MeshBase mesh = createFacesRexFace();
1906

    
1907
    mesh.mergeEffComponents();
1908
    mesh.addEmptyTexComponent();
1909
    mesh.addEmptyTexComponent();
1910
    mesh.addEmptyTexComponent();
1911
    mesh.addEmptyTexComponent();
1912

    
1913
    return mesh;
1914
    }
1915

    
1916
///////////////////////////////////////////////////////////////////////////////////////////////////
1917

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

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

    
1930
    mesh.mergeEffComponents();
1931

    
1932
    return mesh;
1933
    }
1934

    
1935
///////////////////////////////////////////////////////////////////////////////////////////////////
1936

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

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

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

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

    
1957
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1958

    
1959
    mesh.mergeEffComponents();
1960

    
1961
    return mesh;
1962
    }
1963

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

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

    
1975
    mesh.mergeEffComponents();
1976

    
1977
    return mesh;
1978
    }
1979

    
1980
///////////////////////////////////////////////////////////////////////////////////////////////////
1981

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

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

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

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

    
2003
    roundCorners(mesh,center,vertices,0.04f,0.10f);
2004

    
2005
    mesh.mergeEffComponents();
2006

    
2007
    return mesh;
2008
    }
2009

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

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

    
2020
    mesh.mergeEffComponents();
2021

    
2022
    return mesh;
2023
    }
2024

    
2025
///////////////////////////////////////////////////////////////////////////////////////////////////
2026

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

    
2033
    mesh.mergeEffComponents();
2034
    mesh.addEmptyTexComponent();
2035
    mesh.addEmptyTexComponent();
2036
    mesh.addEmptyTexComponent();
2037
    mesh.addEmptyTexComponent();
2038

    
2039
    return mesh;
2040
    }
2041

    
2042
///////////////////////////////////////////////////////////////////////////////////////////////////
2043

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

    
2050
    int X = dimensions[0];
2051
    int Y = dimensions[1];
2052
    int Z = dimensions[2];
2053

    
2054
    float strength = 0.04f;
2055
    float radius   = 0.15f;
2056

    
2057
    Static3D[] vertices = new Static3D[1];
2058
    Static3D center;
2059

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

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

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

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

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

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

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

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

    
2092
    mesh.mergeEffComponents();
2093

    
2094
    return mesh;
2095
    }
2096
  }
(2-2/35)