Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 61b217a5

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

    
20
package org.distorted.objects;
21

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

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

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

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

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

    
50
  static final float SIN54    = (SQ5+1)/4;
51
  static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
52
  static final float SIN18    = (SQ5-1)/4;
53
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
54
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
55
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
56

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

    
60
  static final float MINX_SC  = 0.5f;
61

    
62
  private static final int IVY_N = 8;
63

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

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

    
69
  private FactoryCubit()
70
    {
71

    
72
    }
73

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

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

    
80
    return mThis;
81
    }
82

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
188
    return bands;
189
    }
190

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
265
    return new MeshJoined(meshes);
266
    }
267

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

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

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

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

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

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

    
297
    return new MeshJoined(meshes);
298
    }
299

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

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

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

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

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

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

    
325
    return new MeshJoined(meshes);
326
    }
327

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

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

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

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

    
356
    return new MeshJoined(meshes);
357
    }
358

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

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

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

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

    
379
    return new MeshJoined(meshes);
380
    }
381

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

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

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

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

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

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

    
406
    return new MeshJoined(meshes);
407
    }
408

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

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

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

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

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

    
437
    return new MeshJoined(meshes);
438
    }
439

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

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

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

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

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

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

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

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

    
468
    return new MeshJoined(meshes);
469
    }
470

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

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

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

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

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

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

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

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

    
503
    return new MeshJoined(meshes);
504
    }
505

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

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

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

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

    
523
    float F = 0.5f;
524
    float X = 0.5f;
525
    float G = 0.72f;
526
    float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F };
527
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
528

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

    
536
    return new MeshJoined(meshes);
537
    }
538

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

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

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

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

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

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

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

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

    
583
    return new MeshJoined(meshes);
584
    }
585

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

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

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

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

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

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

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

    
615
    return new MeshJoined(meshes);
616
    }
617

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

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

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

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

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

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

    
639
    return new MeshJoined(meshes);
640
    }
641

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

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

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

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

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

    
658
    return new MeshJoined(meshes);
659
    }
660

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

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

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

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

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

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

    
690
    return new MeshJoined(meshes);
691
    }
692

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

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

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

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

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

    
725
    return new MeshJoined(meshes);
726
    }
727

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

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

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

    
736
    float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
737

    
738
    int numBands0 = numLayers==3 ? 5 : 3;
739
    int numBands1 = numLayers==3 ? 2 : 2;
740
    float h       = numLayers==3 ? 0.04f : 0.03f;
741
    int   e       = numLayers==3 ? 4 : 1;
742

    
743
    float[] bands0 = computeBands(h    ,34,0.3f,0.2f, numBands0);
744
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f, numBands1);
745

    
746
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
747
    meshes[0].setEffectAssociation(0, 1,0);
748
    meshes[1] = meshes[0].copy(true);
749
    meshes[1].setEffectAssociation(0, 2,0);
750
    meshes[2] = meshes[0].copy(true);
751
    meshes[2].setEffectAssociation(0, 4,0);
752
    meshes[3] = new MeshPolygon(vertices0, bands1, 1, e);
753
    meshes[3].setEffectAssociation(0, 8,0);
754
    meshes[4] = meshes[3].copy(true);
755
    meshes[4].setEffectAssociation(0,16,0);
756
    meshes[5] = meshes[3].copy(true);
757
    meshes[5].setEffectAssociation(0,32,0);
758

    
759
    return new MeshJoined(meshes);
760
    }
761

    
762
///////////////////////////////////////////////////////////////////////////////////////////////////
763

    
764
  MeshBase createFacesMegaminxEdge(int numLayers, float width, float height)
765
    {
766
    MeshBase[] meshes = new MeshPolygon[6];
767

    
768
    float D = height/COS18;
769
    float W = D*SIN18;
770

    
771
    float Y1 = 0.5f*width;
772
    float Y2 = 0.5f*width + W;
773
    float Y3 = 0.5f*width + 2*W;
774
    float X2 = D*SIN54;
775
    float X1 = 0.5f*height;
776
    float Y4 = D*COS54;
777

    
778
    float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
779
    float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 };
780
    float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 };
781

    
782
    int numBands0 = numLayers==3 ? 5 : 3;
783
    int numBands1 = numLayers==3 ? 2 : 2;
784
    float h       = numLayers==3 ? 0.03f : 0.03f;
785

    
786
    float[] bands0 = computeBands(h    ,34,0.2f,0.2f,numBands0);
787
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,numBands1);
788

    
789
    meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0);
790
    meshes[0].setEffectAssociation(0, 1,0);
791
    meshes[1] = meshes[0].copy(true);
792
    meshes[1].setEffectAssociation(0, 2,0);
793
    meshes[2] = new MeshPolygon(vertices1, bands1, 0, 0);
794
    meshes[2].setEffectAssociation(0, 4,0);
795
    meshes[3] = meshes[2].copy(true);
796
    meshes[3].setEffectAssociation(0, 8,0);
797
    meshes[4] = new MeshPolygon(vertices2, bands1, 0, 0);
798
    meshes[4].setEffectAssociation(0,16,0);
799
    meshes[5] = meshes[4].copy(true);
800
    meshes[5].setEffectAssociation(0,32,0);
801

    
802
    return new MeshJoined(meshes);
803
    }
804

    
805
///////////////////////////////////////////////////////////////////////////////////////////////////
806

    
807
  MeshBase createFacesMegaminxCenter(int numLayers)
808
    {
809
    MeshBase[] meshes = new MeshPolygon[2];
810

    
811
    float R  = 0.5f;
812
    float X1 = R*COS54;
813
    float Y1 = R*SIN54;
814
    float X2 = R*COS18;
815
    float Y2 = R*SIN18;
816

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

    
819
    int numBands0 = numLayers==3 ? 4 : 3;
820
    int numBands1 = numLayers==3 ? 2 : 2;
821
    float h       = numLayers==3 ? 0.04f : 0.04f;
822

    
823
    float[] bands0 = computeBands( h    ,45, R/3,0.2f, numBands0);
824
    float[] bands1 = computeBands( 0.00f,34, R/3,0.2f, numBands1);
825

    
826
    meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0);
827
    meshes[0].setEffectAssociation(0,1,0);
828
    meshes[1] = new MeshPolygon(vertices0, bands1, 0, 0);
829
    meshes[1].setEffectAssociation(0,2,0);
830

    
831
    return new MeshJoined(meshes);
832
    }
833

    
834
///////////////////////////////////////////////////////////////////////////////////////////////////
835
// EFFECTS
836
///////////////////////////////////////////////////////////////////////////////////////////////////
837

    
838
  VertexEffect[] createVertexEffectsCube()
839
    {
840
    Static3D axisY   = new Static3D(0,1,0);
841
    Static3D axisX   = new Static3D(1,0,0);
842
    Static3D center  = new Static3D(0,0,0);
843
    Static1D angle90 = new Static1D(90);
844
    Static1D angle180= new Static1D(180);
845
    Static1D angle270= new Static1D(270);
846

    
847
    VertexEffect[] effect = new VertexEffect[6];
848

    
849
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
850
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
851
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
852
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
853
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
854
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
855

    
856
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
857
    effect[1].setMeshAssociation(32,-1);  // back
858
    effect[2].setMeshAssociation( 8,-1);  // bottom
859
    effect[3].setMeshAssociation( 4,-1);  // top
860
    effect[4].setMeshAssociation( 2,-1);  // left
861
    effect[5].setMeshAssociation( 1,-1);  // right
862

    
863
    return effect;
864
    }
865

    
866
///////////////////////////////////////////////////////////////////////////////////////////////////
867

    
868
  VertexEffect[] createVertexEffectsSkewbCorner()
869
    {
870
    float E = 0.5f;
871

    
872
    Static3D axisX  = new Static3D(1,0,0);
873
    Static3D axisY  = new Static3D(0,1,0);
874
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
875
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
876
    Static1D angle1 = new Static1D(+90);
877
    Static1D angle2 = new Static1D(-90);
878
    Static1D angle3 = new Static1D(-15);
879
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
880
    Static1D angle5 = new Static1D(120);
881
    Static1D angle6 = new Static1D(240);
882
    Static3D center1= new Static3D(0,0,0);
883
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
884
    Static3D move1  = new Static3D(-E/4,-E/4,0);
885
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
886

    
887
    VertexEffect[] effect = new VertexEffect[10];
888

    
889
    effect[0] = new VertexEffectMove(move1);
890
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
891
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
892
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
893
    effect[4] = new VertexEffectMove(move2);
894
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
895
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
896
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
897
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
898
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
899

    
900
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
901
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
902
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
903
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
904
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
905
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
906
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
907
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
908
    effect[8].setMeshAssociation(16,-1);  // mesh 4
909
    effect[9].setMeshAssociation(32,-1);  // mesh 5
910

    
911
    return effect;
912
    }
913

    
914
///////////////////////////////////////////////////////////////////////////////////////////////////
915

    
916
  VertexEffect[] createVertexEffectsSkewbFace()
917
    {
918
    Static3D center = new Static3D(0,0,0);
919
    Static3D axisX  = new Static3D(1,0,0);
920
    Static3D axisZ  = new Static3D(0,0,1);
921
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
922

    
923
    VertexEffect[] effect = new VertexEffect[6];
924

    
925
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
926
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
927
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
928
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
929
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
930
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
931

    
932
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
933
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
934
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
935
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
936
    effect[4].setMeshAssociation(16,-1);  // mesh 4
937
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
938

    
939
    return effect;
940
    }
941

    
942
///////////////////////////////////////////////////////////////////////////////////////////////////
943

    
944
  VertexEffect[] createVertexEffectsOcta()
945
    {
946
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
947
    Static1D angle1= new Static1D( 90);
948
    Static1D angle2= new Static1D(180);
949
    Static1D angle3= new Static1D(270);
950
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
951
    Static3D axisX = new Static3D(1,0,0);
952
    Static3D axisY = new Static3D(0,1,0);
953
    Static3D cent0 = new Static3D(0,0,0);
954
    Static3D cent1 = new Static3D(0,SQ2/2,0);
955
    Static3D flipY = new Static3D( 1,-1, 1);
956
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
957

    
958
    VertexEffect[] effect = new VertexEffect[7];
959

    
960
    effect[0] = new VertexEffectScale(scale);
961
    effect[1] = new VertexEffectMove(move1);
962
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
963
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
964
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
965
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
966
    effect[6] = new VertexEffectScale(flipY);
967

    
968
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
969
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
970
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
971
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
972

    
973
    return effect;
974
    }
975

    
976
///////////////////////////////////////////////////////////////////////////////////////////////////
977

    
978
  VertexEffect[] createVertexEffectsTetra()
979
    {
980
    Static3D flipZ = new Static3D( 1, 1,-1);
981
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
982
    Static1D angle1= new Static1D( 90);
983
    Static1D angle2= new Static1D(180);
984
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
985
    Static3D axisX = new Static3D(1,0,0);
986
    Static3D axisY = new Static3D(0,1,0);
987
    Static3D axisZ = new Static3D(0,0,1);
988
    Static3D cent0 = new Static3D(0,0,0);
989
    Static3D cent1 = new Static3D(0,SQ2/4,0);
990
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
991

    
992
    VertexEffect[] effect = new VertexEffect[7];
993

    
994
    effect[0] = new VertexEffectScale(scale);
995
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
996
    effect[2] = new VertexEffectMove(move1);
997
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
998
    effect[4] = new VertexEffectScale(flipZ);
999
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
1000
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
1001

    
1002
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
1003
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
1004
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
1005

    
1006
    return effect;
1007
    }
1008

    
1009
///////////////////////////////////////////////////////////////////////////////////////////////////
1010

    
1011
  VertexEffect[] createVertexEffectsDino()
1012
    {
1013
    float E = 0.5f*SQ2;
1014
    float F = 0.5f;
1015
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
1016

    
1017
    Static1D angle1 = new Static1D(-ANGLE);
1018
    Static1D angle2 = new Static1D(+ANGLE);
1019
    Static3D axisX  = new Static3D(1,0,0);
1020
    Static3D axisY  = new Static3D(0,1,0);
1021
    Static3D axisZ  = new Static3D(0,-1,1);
1022
    Static3D center0= new Static3D(0,0,0);
1023
    Static3D center1= new Static3D(0,-3*F,0);
1024

    
1025
    VertexEffect[] effect = new VertexEffect[10];
1026

    
1027
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
1028
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
1029
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
1030
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
1031
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
1032
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
1033
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
1034
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
1035
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
1036
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
1037

    
1038
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
1039
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
1040
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
1041
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
1042
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
1043
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
1044
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1045
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
1046
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
1047
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
1048

    
1049
    return effect;
1050
    }
1051

    
1052
///////////////////////////////////////////////////////////////////////////////////////////////////
1053

    
1054
  VertexEffect[] createVertexEffectsHelicopterCorner()
1055
    {
1056
    float E = 0.5f;
1057

    
1058
    Static3D axisX  = new Static3D(1,0,0);
1059
    Static3D axisY  = new Static3D(0,1,0);
1060
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
1061
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
1062
    Static1D angle1 = new Static1D(+90);
1063
    Static1D angle2 = new Static1D(-90);
1064
    Static1D angle3 = new Static1D(-135);
1065
    Static1D angle4 = new Static1D(90);
1066
    Static1D angle5 = new Static1D(120);
1067
    Static1D angle6 = new Static1D(240);
1068
    Static3D center1= new Static3D(0,0,0);
1069
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
1070
    Static3D move1  = new Static3D(-E/4,-E/4,0);
1071
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
1072

    
1073
    VertexEffect[] effect = new VertexEffect[10];
1074

    
1075
    effect[0] = new VertexEffectMove(move1);
1076
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
1077
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
1078
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
1079
    effect[4] = new VertexEffectMove(move2);
1080
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
1081
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1082
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1083
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1084
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1085

    
1086
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1087
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1088
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1089
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1090
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1091
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1092
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1093
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1094
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1095
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1096

    
1097
    return effect;
1098
    }
1099

    
1100
///////////////////////////////////////////////////////////////////////////////////////////////////
1101

    
1102
  VertexEffect[] createVertexEffectsHelicopterFace()
1103
    {
1104
    float E = 0.5f;
1105
    float F = SQ2/4;
1106

    
1107
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1108
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1109
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1110
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1111
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1112
    Static1D angle1 = new Static1D(135);
1113
    Static1D angle2 = new Static1D(90);
1114
    Static1D angle3 = new Static1D(-90);
1115
    Static1D angle4 = new Static1D(-135);
1116
    Static3D axisX  = new Static3D(1,0,0);
1117
    Static3D axisY  = new Static3D(0,1,0);
1118
    Static3D axisZ  = new Static3D(0,0,1);
1119
    Static3D axis1  = new Static3D(1,-1,0);
1120
    Static3D center = new Static3D(0,0,0);
1121
    Static3D center1= new Static3D(-E/2,-E/2,0);
1122

    
1123
    VertexEffect[] effect = new VertexEffect[10];
1124

    
1125
    effect[0] = new VertexEffectMove(move0);
1126
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1127
    effect[2] = new VertexEffectMove(move1);
1128
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1129
    effect[4] = new VertexEffectMove(move2);
1130
    effect[5] = new VertexEffectMove(move3);
1131
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1132
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1133
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1134
    effect[9] = new VertexEffectMove(move4);
1135

    
1136
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1137
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1138
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1139
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1140
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1141
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1142
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1143
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1144
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1145
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1146

    
1147
    return effect;
1148
    }
1149

    
1150
///////////////////////////////////////////////////////////////////////////////////////////////////
1151

    
1152
  VertexEffect[] createVertexEffectsRediEdge()
1153
    {
1154
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1155
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1156
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1157
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1158
    Static3D flipZ = new Static3D(1,1,-1);
1159
    Static3D flipX = new Static3D(-1,1,1);
1160
    Static3D scale = new Static3D(2,2,2);
1161
    Static3D cent0 = new Static3D(0,0, 0);
1162
    Static3D cent1 = new Static3D(0,0, -1.5f);
1163
    Static3D axisX = new Static3D(1,0, 0);
1164
    Static3D axisY = new Static3D(0,1, 0);
1165
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1166
    Static1D angle1= new Static1D(90);
1167
    Static1D angle2= new Static1D(45);
1168
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1169

    
1170
    VertexEffect[] effect = new VertexEffect[12];
1171

    
1172
    effect[0] = new VertexEffectScale(scale);
1173
    effect[1] = new VertexEffectMove(move0);
1174
    effect[2] = new VertexEffectScale(flipZ);
1175
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1176
    effect[4] = new VertexEffectMove(move1);
1177
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1178
    effect[6] = new VertexEffectMove(move2);
1179
    effect[7] = new VertexEffectScale(flipX);
1180
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1181
    effect[9] = new VertexEffectMove(move3);
1182
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1183
    effect[11]= new VertexEffectScale(flipX);
1184

    
1185
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1186
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1187
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1188
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1189
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1190
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1191
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1192
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1193
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1194
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1195
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1196
    effect[11].setMeshAssociation(32,-1); // mesh 5
1197

    
1198
    return effect;
1199
    }
1200

    
1201
///////////////////////////////////////////////////////////////////////////////////////////////////
1202

    
1203
  VertexEffect[] createVertexEffectsRediCorner()
1204
    {
1205
    Static3D axisY   = new Static3D(0,1,0);
1206
    Static3D axisX   = new Static3D(1,0,0);
1207
    Static3D axisZ   = new Static3D(0,0,1);
1208
    Static3D center  = new Static3D(0,0,0);
1209
    Static1D angle90 = new Static1D(90);
1210
    Static1D angle270= new Static1D(270);
1211
    Static1D angle45 = new Static1D(-45);
1212
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1213

    
1214
    VertexEffect[] effect = new VertexEffect[7];
1215

    
1216
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1217
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1218
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1219
    effect[3] = new VertexEffectScale(scale);
1220
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1221
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1222
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1223

    
1224
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1225
    effect[1].setMeshAssociation( 2,-1);  // 1
1226
    effect[2].setMeshAssociation( 4,-1);  // 2
1227
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1228
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1229
    effect[5].setMeshAssociation(16,-1);  // 4
1230
    effect[6].setMeshAssociation(32,-1);  // 5
1231

    
1232
    return effect;
1233
    }
1234

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

    
1237
  VertexEffect[] createVertexEffectsIvyCorner()
1238
    {
1239
    Static3D axisX  = new Static3D(1,0,0);
1240
    Static3D axisY  = new Static3D(0,1,0);
1241
    Static1D angle1 = new Static1D(+90);
1242
    Static1D angle2 = new Static1D(-90);
1243
    Static3D center = new Static3D(0,0,0);
1244
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1245

    
1246
    VertexEffect[] effect = new VertexEffect[5];
1247

    
1248
    effect[0] = new VertexEffectScale(1/IVY_C);
1249
    effect[1] = new VertexEffectMove(move1);
1250
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1251
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1252
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1253

    
1254
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1255
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1256
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1257

    
1258
    return effect;
1259
    }
1260

    
1261
///////////////////////////////////////////////////////////////////////////////////////////////////
1262

    
1263
  VertexEffect[] createVertexEffectsRexEdge()
1264
    {
1265
    float E = 0.5f - REX_D;
1266
    float F = 0.5f;
1267
    float G = (float)Math.sqrt(E*E+F*F);
1268
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1269

    
1270
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1271
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1272

    
1273
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1274
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1275
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1276
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1277
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1278
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1279

    
1280
    Static1D angle180 = new Static1D(180);
1281
    Static1D angle90  = new Static1D( 90);
1282
    Static1D angle270 = new Static1D(270);
1283
    Static1D angle1   = new Static1D(+A);
1284
    Static1D angle2   = new Static1D(-A);
1285

    
1286
    VertexEffect[] effect = new VertexEffect[12];
1287

    
1288
    effect[0] = new VertexEffectMove(move1);
1289
    effect[1] = new VertexEffectMove(move2);
1290
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1291
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1292
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1293
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1294
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1295
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1296
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1297
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1298
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1299
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1300

    
1301
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1302
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1303
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1304
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1305
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1306
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1307
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1308
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1309
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1310
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1311
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1312
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1313

    
1314
    return effect;
1315
    }
1316

    
1317
///////////////////////////////////////////////////////////////////////////////////////////////////
1318

    
1319
  VertexEffect[] createVertexEffectsRexCorner()
1320
    {
1321
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1322
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1323
    Static1D angle = new Static1D(225);
1324

    
1325
    VertexEffect[] effect = new VertexEffect[1];
1326
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1327

    
1328
    return effect;
1329
    }
1330

    
1331
///////////////////////////////////////////////////////////////////////////////////////////////////
1332

    
1333
  VertexEffect[] createVertexEffectsKilominxCorner()
1334
    {
1335
    VertexEffect[] effect = new VertexEffect[10];
1336

    
1337
    float H = 0.5f*(SIN54 /COS54  );
1338
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1339
    float Y2= H/(2*COS_HALFD);
1340
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1341
    float sin18 = SIN18;
1342
    float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18));
1343
    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
1344

    
1345
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1346
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1347
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1348
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H* SIN_HALFD /(COS_HALFD*LEN));
1349

    
1350
    Static3D move1 = new Static3D(0,-Y1,0);
1351
    Static3D move2 = new Static3D(0,-Y2,0);
1352
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1353
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1354

    
1355
    Static1D angle1 = new Static1D(54);
1356
    Static1D angle2 = new Static1D(A/2+18);
1357
    Static1D angle3 = new Static1D(90);
1358
    Static1D angle4 = new Static1D(120);
1359
    Static1D angle5 = new Static1D(240);
1360
    Static1D angle6 = new Static1D(90-A/2);
1361

    
1362
    effect[0] = new VertexEffectMove(move1);
1363
    effect[1] = new VertexEffectScale(1/MINX_SC);
1364
    effect[2] = new VertexEffectMove(move2);
1365
    effect[3] = new VertexEffectRotate(angle1, axisZ, center);
1366
    effect[4] = new VertexEffectRotate(angle2, axisZ, center);
1367
    effect[5] = new VertexEffectRotate(angle3, axisA, center);
1368
    effect[6] = new VertexEffectMove(move3);
1369
    effect[7] = new VertexEffectRotate(angle4, axisC, center);
1370
    effect[8] = new VertexEffectRotate(angle5, axisC, center);
1371
    effect[9] = new VertexEffectRotate(angle6, axisY, center);
1372

    
1373
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1374
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1375
    effect[2].setMeshAssociation(56,-1);  // meshes 3,4,5
1376
    effect[3].setMeshAssociation( 7,-1);  // meshes 0,1,2
1377
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1378
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1379
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1380
    effect[7].setMeshAssociation(18,-1);  // meshes 1,4
1381
    effect[8].setMeshAssociation(36,-1);  // meshes 2,5
1382

    
1383
    return effect;
1384
    }
1385

    
1386
///////////////////////////////////////////////////////////////////////////////////////////////////
1387

    
1388
  VertexEffect[] createVertexEffectsMegaminxCorner(int numLayers)
1389
    {
1390
    VertexEffect[] effect = new VertexEffect[9];
1391

    
1392
    float Y = COS54/(2*SIN54);
1393

    
1394
    float sinA = (2*SIN54*SIN54-1)/COS54;
1395
    float cosA = (float)Math.sqrt(1-sinA*sinA);
1396
    float LEN  = 0.5f/SIN54;
1397
    float scale= (numLayers/3.0f)*(0.5f-MEGA_D)/(LEN*0.5f*(numLayers-1));
1398

    
1399
    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
1400
    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
1401
    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
1402

    
1403
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1404
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1405

    
1406
    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
1407
    Static3D move2= new Static3D(0.0f, Y , 0.0f );
1408

    
1409
    Static1D angleD = new Static1D(DIHEDRAL1);
1410
    Static1D angleE = new Static1D(360-DIHEDRAL1);
1411
    Static1D angleF = new Static1D(DIHEDRAL2);
1412

    
1413
    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
1414
    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
1415
    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
1416
    effect[3] = new VertexEffectMove(move1);
1417
    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
1418
    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
1419
    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
1420
    effect[7] = new VertexEffectMove(move2);
1421
    effect[8] = new VertexEffectScale(scale);
1422

    
1423
    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
1424
    effect[1].setMeshAssociation( 16,-1);  // mesh 4
1425
    effect[2].setMeshAssociation( 32,-1);  // mesh 5
1426
    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
1427
    effect[4].setMeshAssociation(  1,-1);  // mesh 0
1428
    effect[5].setMeshAssociation(  2,-1);  // mesh 1
1429

    
1430
    return effect;
1431
    }
1432

    
1433
///////////////////////////////////////////////////////////////////////////////////////////////////
1434

    
1435
  VertexEffect[] createVertexEffectsMegaminxEdge(float width, float height)
1436
    {
1437
    VertexEffect[] effect = new VertexEffect[11];
1438

    
1439
    float X = 0.5f*height;
1440
    float Y = height*(COS54/COS18) + width*0.5f;
1441
    float Z = 2*height*COS_HALFD;
1442

    
1443
    float alpha = 90-DIHEDRAL1/2;
1444
    float beta  = DIHEDRAL2;
1445

    
1446
    Static1D angle1 = new Static1D(alpha);
1447
    Static1D angle2 = new Static1D(180-alpha);
1448
    Static1D angle3 = new Static1D(beta);
1449

    
1450
    Static3D move1 = new Static3D(X,0,0);
1451
    Static3D move2 = new Static3D(X,0,-Z);
1452
    Static3D move3 = new Static3D(0,+Y,0);
1453
    Static3D move4 = new Static3D(0,-Y,0);
1454
    Static3D scale = new Static3D(+1,+1,-1);
1455

    
1456
    Static3D axisXplus = new Static3D(+1, 0, 0);
1457
    Static3D axisXminus= new Static3D(-1, 0, 0);
1458
    Static3D axisYplus = new Static3D( 0,+1, 0);
1459
    Static3D axisYminus= new Static3D( 0,-1, 0);
1460

    
1461
    Static3D center1= new Static3D( 0, 0, 0);
1462
    Static3D center2= new Static3D( 0, 0,-Z);
1463
    Static3D center3= new Static3D( 0,+width*0.5f, 0);
1464
    Static3D center4= new Static3D( 0,-width*0.5f, 0);
1465

    
1466
    effect[ 0] = new VertexEffectMove(move1);
1467
    effect[ 1] = new VertexEffectMove(move2);
1468
    effect[ 2] = new VertexEffectMove(move3);
1469
    effect[ 3] = new VertexEffectMove(move4);
1470
    effect[ 4] = new VertexEffectScale(scale);
1471
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1472
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1473
    effect[ 7] = new VertexEffectRotate(angle1, axisYminus, center2);
1474
    effect[ 8] = new VertexEffectRotate(angle2, axisYminus, center2);
1475
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center3);
1476
    effect[10] = new VertexEffectRotate(angle3, axisXminus, center4);
1477

    
1478
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1479
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1480
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1481
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1482
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1483
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1484
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1485
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1486
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1487
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1488
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1489

    
1490
    return effect;
1491
    }
1492

    
1493
///////////////////////////////////////////////////////////////////////////////////////////////////
1494

    
1495
  VertexEffect[] createVertexEffectsMegaminxCenter(float width)
1496
    {
1497
    VertexEffect[] effect = new VertexEffect[2];
1498

    
1499
    Static1D angle = new Static1D(DIHEDRAL2);
1500
    Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
1501
    Static3D center= new Static3D( 0, 0, 0);
1502

    
1503
    effect[0] = new VertexEffectScale(width/COS54);
1504
    effect[1] = new VertexEffectRotate(angle, axisX, center);
1505

    
1506
    return effect;
1507
    }
1508

    
1509
///////////////////////////////////////////////////////////////////////////////////////////////////
1510
// OBJECTS
1511
///////////////////////////////////////////////////////////////////////////////////////////////////
1512
// CUBE
1513

    
1514
  MeshBase createCubeMesh(int index)
1515
    {
1516
    MeshBase mesh = createFacesCube(index);
1517
    VertexEffect[] effects = createVertexEffectsCube();
1518
    for( VertexEffect effect : effects ) mesh.apply(effect);
1519

    
1520
    Static3D roundingCenter  = new Static3D(0,0,0);
1521
    Static3D[] vertices = new Static3D[8];
1522
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1523
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1524
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1525
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1526
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1527
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1528
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1529
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1530

    
1531
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1532

    
1533
    mesh.mergeEffComponents();
1534

    
1535
    return mesh;
1536
    }
1537

    
1538
///////////////////////////////////////////////////////////////////////////////////////////////////
1539
// SKEWB
1540

    
1541
  MeshBase createSkewbCornerMesh()
1542
    {
1543
    MeshBase mesh = createFacesSkewbCorner();
1544
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1545
    for( VertexEffect effect : effects ) mesh.apply(effect);
1546

    
1547
    float E = 0.5f;
1548
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1549

    
1550
    Static3D[] verticesType1 = new Static3D[1];
1551
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1552
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1553

    
1554
    Static3D[] verticesType2 = new Static3D[3];
1555
    verticesType2[0] = new Static3D(-E, 0, 0);
1556
    verticesType2[1] = new Static3D( 0,-E, 0);
1557
    verticesType2[2] = new Static3D( 0, 0,-E);
1558
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1559

    
1560
    mesh.mergeEffComponents();
1561

    
1562
    return mesh;
1563
    }
1564

    
1565
///////////////////////////////////////////////////////////////////////////////////////////////////
1566

    
1567
  MeshBase createSkewbFaceMesh()
1568
    {
1569
    MeshBase mesh = createFacesSkewbFace();
1570
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1571
    for( VertexEffect effect : effects ) mesh.apply(effect);
1572

    
1573
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1574
    float E = SQ2/4;
1575
    Static3D[] vertices = new Static3D[4];
1576
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1577
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1578
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1579
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1580
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1581

    
1582
    mesh.mergeEffComponents();
1583
    mesh.addEmptyTexComponent();
1584

    
1585
    return mesh;
1586
    }
1587

    
1588
///////////////////////////////////////////////////////////////////////////////////////////////////
1589
// SKEWB DIAMOND / PYRAMINX
1590

    
1591
  MeshBase createOctaMesh()
1592
    {
1593
    MeshBase mesh = createFacesOcta();
1594
    VertexEffect[] effects = createVertexEffectsOcta();
1595
    for( VertexEffect effect : effects ) mesh.apply(effect);
1596

    
1597
    Static3D roundingCenter = new Static3D(0,0,0);
1598
    Static3D[] vertices = new Static3D[6];
1599
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1600
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1601
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1602
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1603
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1604
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1605

    
1606
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1607

    
1608
    mesh.mergeEffComponents();
1609

    
1610
    return mesh;
1611
    }
1612

    
1613
///////////////////////////////////////////////////////////////////////////////////////////////////
1614

    
1615
  MeshBase createTetraMesh()
1616
    {
1617
    MeshBase mesh = createFacesTetra();
1618
    VertexEffect[] effects = createVertexEffectsTetra();
1619
    for( VertexEffect effect : effects ) mesh.apply(effect);
1620

    
1621
    Static3D roundingCenter = new Static3D(0,0,0);
1622
    Static3D[] verticesRound = new Static3D[4];
1623
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1624
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1625
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1626
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1627
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1628

    
1629
    mesh.mergeEffComponents();
1630
    mesh.addEmptyTexComponent();
1631
    mesh.addEmptyTexComponent();
1632
    mesh.addEmptyTexComponent();
1633
    mesh.addEmptyTexComponent();
1634

    
1635
    return mesh;
1636
    }
1637

    
1638
///////////////////////////////////////////////////////////////////////////////////////////////////
1639
// DINO
1640

    
1641
  MeshBase createDinoMesh()
1642
    {
1643
    MeshBase mesh = createFacesDino();
1644
    VertexEffect[] effects = createVertexEffectsDino();
1645
    for( VertexEffect effect : effects ) mesh.apply(effect);
1646

    
1647
    float F = 0.5f;
1648
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1649
    Static3D[] verticesRound = new Static3D[4];
1650
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1651
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1652
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1653
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1654
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1655

    
1656
    mesh.mergeEffComponents();
1657

    
1658
    return mesh;
1659
    }
1660

    
1661
///////////////////////////////////////////////////////////////////////////////////////////////////
1662
// Helicopter
1663

    
1664
  MeshBase createHelicopterCornerMesh()
1665
    {
1666
    MeshBase mesh = createFacesHelicopterCorner();
1667
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1668
    for( VertexEffect effect : effects ) mesh.apply(effect);
1669

    
1670
    float E = 0.5f;
1671
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1672

    
1673
    Static3D[] verticesType1 = new Static3D[1];
1674
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1675
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1676

    
1677
    Static3D[] verticesType2 = new Static3D[3];
1678
    verticesType2[0] = new Static3D(-E, 0, 0);
1679
    verticesType2[1] = new Static3D( 0,-E, 0);
1680
    verticesType2[2] = new Static3D( 0, 0,-E);
1681
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1682

    
1683
    mesh.mergeEffComponents();
1684

    
1685
    return mesh;
1686
    }
1687

    
1688
///////////////////////////////////////////////////////////////////////////////////////////////////
1689

    
1690
  MeshBase createHelicopterFaceMesh()
1691
    {
1692
    MeshBase mesh = createFacesHelicopterFace();
1693
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1694
    for( VertexEffect effect : effects ) mesh.apply(effect);
1695

    
1696
    float E = 0.5f;
1697
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1698

    
1699
    Static3D[] verticesType1 = new Static3D[1];
1700
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1701
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1702

    
1703
    Static3D[] verticesType2 = new Static3D[2];
1704
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1705
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1706
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1707

    
1708
    mesh.mergeEffComponents();
1709
    mesh.addEmptyTexComponent();
1710
    mesh.addEmptyTexComponent();
1711

    
1712
    return mesh;
1713
    }
1714

    
1715
///////////////////////////////////////////////////////////////////////////////////////////////////
1716
// Redi cube
1717

    
1718
  MeshBase createRediEdgeMesh()
1719
    {
1720
    MeshBase mesh = createFacesRediEdge();
1721
    VertexEffect[] effects = createVertexEffectsRediEdge();
1722
    for( VertexEffect effect : effects ) mesh.apply(effect);
1723

    
1724
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1725
    Static3D[] vertices = new Static3D[2];
1726
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1727
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1728
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1729

    
1730
    mesh.mergeEffComponents();
1731

    
1732
    return mesh;
1733
    }
1734

    
1735
///////////////////////////////////////////////////////////////////////////////////////////////////
1736

    
1737
  MeshBase createRediCornerMesh()
1738
    {
1739
    MeshBase mesh = createFacesRediCorner();
1740
    VertexEffect[] effects = createVertexEffectsRediCorner();
1741
    for( VertexEffect effect : effects ) mesh.apply(effect);
1742

    
1743
    Static3D center = new Static3D(0,0,0);
1744
    Static3D[] vertices = new Static3D[8];
1745
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1746
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1747
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1748
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1749
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1750
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1751
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1752
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1753

    
1754
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1755

    
1756
    mesh.mergeEffComponents();
1757

    
1758
    return mesh;
1759
    }
1760

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

    
1763
  MeshBase createIvyCornerMesh()
1764
    {
1765
    MeshBase mesh = createFacesIvyCorner();
1766
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1767
    for( VertexEffect effect : effects ) mesh.apply(effect);
1768

    
1769
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1770
    Static3D[] vertices = new Static3D[4];
1771
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1772
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1773
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1774
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1775

    
1776
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1777

    
1778
    mesh.mergeEffComponents();
1779

    
1780
    return mesh;
1781
    }
1782

    
1783
///////////////////////////////////////////////////////////////////////////////////////////////////
1784

    
1785
  MeshBase createIvyFaceMesh()
1786
    {
1787
    MeshBase mesh = createFacesIvyFace();
1788

    
1789
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1790
    Static3D[] vertices = new Static3D[2];
1791
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1792
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1793

    
1794
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1795

    
1796
    mesh.mergeEffComponents();
1797
    mesh.addEmptyTexComponent();
1798
    mesh.addEmptyTexComponent();
1799
    mesh.addEmptyTexComponent();
1800
    mesh.addEmptyTexComponent();
1801

    
1802
    return mesh;
1803
    }
1804

    
1805
///////////////////////////////////////////////////////////////////////////////////////////////////
1806

    
1807
  MeshBase createRexCornerMesh()
1808
    {
1809
    MeshBase mesh = createFacesRexCorner();
1810
    VertexEffect[] effects = createVertexEffectsRexCorner();
1811
    for( VertexEffect effect : effects ) mesh.apply(effect);
1812

    
1813
    final float G = (1-REX_D)/3;
1814
    Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
1815
    Static3D[] vertices = new Static3D[1];
1816
    vertices[0] = new Static3D(+G,-G,+0.0f);
1817
    roundCorners(mesh,center,vertices,0.10f,0.10f);
1818

    
1819
    mesh.mergeEffComponents();
1820
    mesh.addEmptyTexComponent();
1821
    mesh.addEmptyTexComponent();
1822
    mesh.addEmptyTexComponent();
1823
    mesh.addEmptyTexComponent();
1824

    
1825
    return mesh;
1826
    }
1827

    
1828
///////////////////////////////////////////////////////////////////////////////////////////////////
1829

    
1830
  MeshBase createRexFaceMesh()
1831
    {
1832
    MeshBase mesh = createFacesRexFace();
1833

    
1834
    mesh.mergeEffComponents();
1835
    mesh.addEmptyTexComponent();
1836
    mesh.addEmptyTexComponent();
1837
    mesh.addEmptyTexComponent();
1838
    mesh.addEmptyTexComponent();
1839

    
1840
    return mesh;
1841
    }
1842

    
1843
///////////////////////////////////////////////////////////////////////////////////////////////////
1844

    
1845
  MeshBase createRexEdgeMesh()
1846
    {
1847
    MeshBase mesh = createFacesRexEdge();
1848
    VertexEffect[] effects = createVertexEffectsRexEdge();
1849
    for( VertexEffect effect : effects ) mesh.apply(effect);
1850

    
1851
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1852
    Static3D[] vertices = new Static3D[2];
1853
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1854
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1855
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1856

    
1857
    mesh.mergeEffComponents();
1858

    
1859
    return mesh;
1860
    }
1861

    
1862
///////////////////////////////////////////////////////////////////////////////////////////////////
1863

    
1864
  MeshBase createKilominxCornerMesh()
1865
    {
1866
    MeshBase mesh = createFacesKilominxCorner();
1867
    VertexEffect[] effects = createVertexEffectsKilominxCorner();
1868
    for( VertexEffect effect : effects ) mesh.apply(effect);
1869

    
1870
    float A = (2*SQ3/3)* SIN54;
1871
    float B = 0.4f;
1872
    float X = SIN_HALFD * SIN54 *COS54  ;
1873
    float Y = SIN54 * SIN54 - 0.5f;
1874
    float Z = COS_HALFD* SIN54 *COS54  ;
1875

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

    
1878
    Static3D[] vertices = new Static3D[4];
1879
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1880
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1881
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1882
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1883

    
1884
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1885

    
1886
    mesh.mergeEffComponents();
1887

    
1888
    return mesh;
1889
    }
1890

    
1891
///////////////////////////////////////////////////////////////////////////////////////////////////
1892

    
1893
  MeshBase createMegaminxCornerMesh(int numLayers)
1894
    {
1895
    MeshBase mesh = createFacesMegaminxCorner(numLayers);
1896
    VertexEffect[] effects = createVertexEffectsMegaminxCorner(numLayers);
1897
    for( VertexEffect effect : effects ) mesh.apply(effect);
1898

    
1899
    float A = (2*SQ3/3)* SIN54;
1900
    float B = 0.4f;
1901
    float X = SIN_HALFD* SIN54 * COS54;
1902
    float Y = SIN54 * SIN54 - 0.5f;
1903
    float Z = COS_HALFD* SIN54 * COS54;
1904
    float S = 2*SIN54*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
1905

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

    
1908
    Static3D[] vertices = new Static3D[4];
1909
    vertices[0] = new Static3D( 0.0f, 0.0f  , 0.0f);
1910
    vertices[1] = new Static3D( 0.0f,-0.5f*S, 0.0f);
1911
    vertices[2] = new Static3D(-X*S , Y*S   ,-Z*S );
1912
    vertices[3] = new Static3D(+X*S , Y*S   ,-Z*S );
1913

    
1914
    roundCorners(mesh,center,vertices,0.04f,0.10f);
1915

    
1916
    mesh.mergeEffComponents();
1917

    
1918
    return mesh;
1919
    }
1920

    
1921
///////////////////////////////////////////////////////////////////////////////////////////////////
1922
// numLayers==3 --> index=0; numLayers=5 --> index=1 ...
1923
// type: 0,1,... 0 --> edge, 1 --> 1 layer deeper, etc
1924

    
1925
  MeshBase createMegaminxEdgeMesh(int numLayers, float width, float height)
1926
    {
1927
    MeshBase mesh = createFacesMegaminxEdge(numLayers,width,height);
1928
    VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
1929
    for( VertexEffect effect : effects ) mesh.apply(effect);
1930

    
1931
    mesh.mergeEffComponents();
1932

    
1933
    return mesh;
1934
    }
1935

    
1936
///////////////////////////////////////////////////////////////////////////////////////////////////
1937

    
1938
  MeshBase createMegaminxCenterMesh(int numLayers, float width)
1939
    {
1940
    MeshBase mesh = createFacesMegaminxCenter(numLayers);
1941
    VertexEffect[] effects = createVertexEffectsMegaminxCenter(width);
1942
    for( VertexEffect effect : effects ) mesh.apply(effect);
1943

    
1944
    mesh.mergeEffComponents();
1945
    mesh.addEmptyTexComponent();
1946
    mesh.addEmptyTexComponent();
1947
    mesh.addEmptyTexComponent();
1948
    mesh.addEmptyTexComponent();
1949

    
1950
    return mesh;
1951
    }
1952
  }
(2-2/30)