Project

General

Profile

Download (71.8 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / meshfile / FactoryCubit.java @ a65604a7

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.examples.meshfile;
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
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
class FactoryCubit
37
  {
38
  private static final float SQ2 = (float)Math.sqrt(2);
39
  private static final float SQ3 = (float)Math.sqrt(3);
40
  private static final float SQ5 = (float)Math.sqrt(5);
41
  private static final float SQ6 = (float)Math.sqrt(6);
42

    
43
  private static final float IVY_D = 0.003f;
44
  private static final int   IVY_N = 8;
45
  private static final float IVY_C = 0.59f;
46
  private static final float IVY_M = 0.35f;
47
  private static final float REX_D = 0.2f;
48
  private static final int   REX_N = 5;
49

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

    
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
  private static final Static1D RADIUS = new Static1D(1);
61

    
62
  private static FactoryCubit mThis;
63

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

    
66
  private FactoryCubit()
67
    {
68

    
69
    }
70

    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

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

    
77
    return mThis;
78
    }
79

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

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

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

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

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

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

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

    
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138

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

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

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

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

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

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

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

    
185
    return bands;
186
    }
187

    
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189

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

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

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

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

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

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

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

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

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

    
229
///////////////////////////////////////////////////////////////////////////////////////////////////
230

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

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

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

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

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

    
262
    return new MeshJoined(meshes);
263
    }
264

    
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

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

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

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

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

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

    
294
    return new MeshJoined(meshes);
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

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

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

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

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

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

    
322
    return new MeshJoined(meshes);
323
    }
324

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

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

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

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

    
353
    return new MeshJoined(meshes);
354
    }
355

    
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

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

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

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

    
376
    return new MeshJoined(meshes);
377
    }
378

    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380

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

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

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

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

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

    
403
    return new MeshJoined(meshes);
404
    }
405

    
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407

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

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

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

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

    
434
    return new MeshJoined(meshes);
435
    }
436

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438

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

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

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

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

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

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

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

    
465
    return new MeshJoined(meshes);
466
    }
467

    
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469

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

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

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

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

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

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

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

    
500
    return new MeshJoined(meshes);
501
    }
502

    
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504

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

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

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

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

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

    
533
    return new MeshJoined(meshes);
534
    }
535

    
536
///////////////////////////////////////////////////////////////////////////////////////////////////
537

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

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

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

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

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

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

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

    
580
    return new MeshJoined(meshes);
581
    }
582

    
583
///////////////////////////////////////////////////////////////////////////////////////////////////
584

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

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

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

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

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

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

    
612
    return new MeshJoined(meshes);
613
    }
614

    
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616

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

    
621
    final float angle = (float)Math.PI/(6*REX_N);
622
    float[] vertices = new float[6*REX_N];
623
    final float D = 0.5f - REX_D;
624
    final float F = D*SQ2*(SQ3-1);
625
    final float B = 2.5f;
626

    
627
    final float V1x = -F*0.5f;
628
    final float V1y = -F*SQ3/6;
629
    final float V2x = -V1x;
630
    final float V2y = V1y;
631
    final float V3x = 0.0f;
632
    final float V3y = -2*V1y;
633

    
634
    final float C1x = 0.0f;
635
    final float C1y = -F*(1+2*SQ3/3);
636
    final float C2x = B*V1x;
637
    final float C2y = B*V1y;
638
    final float C3x = B*V2x;
639
    final float C3y = B*V2y;
640

    
641
    for(int i=0; i<REX_N; i++)
642
      {
643
      writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i          );
644
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
645
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
646
      }
647

    
648
    float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
649
    float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
650

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

    
656
    return new MeshJoined(meshes);
657
    }
658

    
659
///////////////////////////////////////////////////////////////////////////////////////////////////
660

    
661
  MeshBase createFacesRexFace()
662
    {
663
    MeshBase[] meshes = new MeshBase[2];
664

    
665
    final float angle = (float)Math.PI/(6*REX_N);
666
    float[] vertices = new float[8*REX_N];
667
    final float D = 0.5f - REX_D;
668
    final float F = D*(SQ3-1);
669

    
670
    final float V1x = 0.0f;
671
    final float V1y = +F;
672
    final float V2x = -F;
673
    final float V2y = 0.0f;
674
    final float V3x = 0.0f;
675
    final float V3y = -F;
676
    final float V4x = +F;
677
    final float V4y = 0.0f;
678

    
679
    final float C1x = +D;
680
    final float C1y = -D;
681
    final float C2x = +D;
682
    final float C2y = +D;
683
    final float C3x = -D;
684
    final float C3y = +D;
685
    final float C4x = -D;
686
    final float C4y = -D;
687

    
688
    for(int i=0; i<REX_N; i++)
689
      {
690
      writeVertex(C1x,C1y,V1x,V1y, i*angle, vertices, 2*i          );
691
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
692
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
693
      writeVertex(C4x,C4y,V4x,V4y, i*angle, vertices, 2*i + 6*REX_N);
694
      }
695

    
696
    float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
697
    float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
698

    
699
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
700
    meshes[0].setEffectAssociation(0,1,0);
701
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
702
    meshes[1].setEffectAssociation(0,2,0);
703

    
704
    return new MeshJoined(meshes);
705
    }
706

    
707
///////////////////////////////////////////////////////////////////////////////////////////////////
708

    
709
  MeshBase createFacesRexEdge()
710
    {
711
    MeshBase[] meshes = new MeshPolygon[6];
712

    
713
    float E = 0.5f - REX_D;
714
    float F = 0.5f;
715
    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
716
    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
717

    
718
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
719
    meshes[0].setEffectAssociation(0,1,0);
720
    meshes[1] = meshes[0].copy(true);
721
    meshes[1].setEffectAssociation(0,2,0);
722

    
723
    float G = (float)Math.sqrt(E*E+F*F);
724
    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
725
    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
726

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

    
736
    return new MeshJoined(meshes);
737
    }
738

    
739
///////////////////////////////////////////////////////////////////////////////////////////////////
740

    
741
  MeshBase createFacesKilominxCorner()
742
    {
743
    MeshBase[] meshes = new MeshPolygon[6];
744

    
745
    float X1= (SQ5+1)/8;
746
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
747
    float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
748
    float H = 0.5f* SIN54 / COS54;
749
    float X2= H*SIN_HALFD;
750
    float Y3= H/(2*COS_HALFD);
751
    float Y4= H*(1/(2*COS_HALFD) - COS_HALFD);
752

    
753
    float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
754
    float[] bands0 = computeBands(0.03f,39,0.3f,0.2f,5);
755
    float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 };
756
    float[] bands1 = computeBands(0.00f,27,0.25f,0.5f,5);
757

    
758
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
759
    meshes[0].setEffectAssociation(0, 1,0);
760
    meshes[1] = meshes[0].copy(true);
761
    meshes[1].setEffectAssociation(0, 2,0);
762
    meshes[2] = meshes[0].copy(true);
763
    meshes[2].setEffectAssociation(0, 4,0);
764
    meshes[3] = new MeshPolygon(vertices1, bands1, 1, 1);
765
    meshes[3].setEffectAssociation(0, 8,0);
766
    meshes[4] = meshes[3].copy(true);
767
    meshes[4].setEffectAssociation(0,16,0);
768
    meshes[5] = meshes[3].copy(true);
769
    meshes[5].setEffectAssociation(0,32,0);
770

    
771
    return new MeshJoined(meshes);
772
    }
773

    
774
///////////////////////////////////////////////////////////////////////////////////////////////////
775

    
776
  MeshBase createFacesMegaminxCorner()
777
    {
778
    MeshBase[] meshes = new MeshPolygon[6];
779

    
780
    float Y = COS54/(2*SIN54);
781

    
782
    float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
783
    float[] bands0 = computeBands(0.04f,34,0.3f,0.2f,5);
784
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
785

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

    
799
    return new MeshJoined(meshes);
800
    }
801

    
802
///////////////////////////////////////////////////////////////////////////////////////////////////
803

    
804
  MeshBase createFacesMegaminxEdge(float width, float height)
805
    {
806
    MeshBase[] meshes = new MeshPolygon[6];
807

    
808
    float D = height/COS18;
809
    float W = D*SIN18;
810

    
811
    float Y1 = 0.5f*width;
812
    float Y2 = 0.5f*width + W;
813
    float Y3 = 0.5f*width + 2*W;
814
    float X2 = D*SIN54;
815
    float X1 = 0.5f*height;
816
    float Y4 = D*COS54;
817

    
818
    float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
819
    float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 };
820
    float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 };
821

    
822
    float[] bands0 = computeBands(0.04f,34,  X1,0.2f,5);
823
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
824

    
825
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
826
    meshes[0].setEffectAssociation(0, 1,0);
827
    meshes[1] = meshes[0].copy(true);
828
    meshes[1].setEffectAssociation(0, 2,0);
829
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 4);
830
    meshes[2].setEffectAssociation(0, 4,0);
831
    meshes[3] = meshes[2].copy(true);
832
    meshes[3].setEffectAssociation(0, 8,0);
833
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 4);
834
    meshes[4].setEffectAssociation(0,16,0);
835
    meshes[5] = meshes[4].copy(true);
836
    meshes[5].setEffectAssociation(0,32,0);
837

    
838
    return new MeshJoined(meshes);
839
    }
840

    
841
///////////////////////////////////////////////////////////////////////////////////////////////////
842

    
843
  private float[] createVertices(int A, int B)
844
    {
845
    float E = 0.5f / Math.max(A,B);
846
    return new float[] { -A*E,-B*E, +A*E,-B*E, +A*E,+B*E, -A*E,+B*E };
847
    }
848

    
849
///////////////////////////////////////////////////////////////////////////////////////////////////
850

    
851
  MeshBase createCuboid(int[] dimensions)
852
    {
853
    int X = dimensions[0];
854
    int Y = dimensions[1];
855
    int Z = dimensions[2];
856

    
857
    float[] verticesXY = createVertices(X,Y);
858
    float[] verticesXZ = createVertices(X,Z);
859
    float[] verticesYZ = createVertices(Z,Y);
860

    
861
    float defHeight = 0.048f;
862

    
863
    float[] bandsX = computeBands( defHeight/X,65,0.25f,0.5f,5);
864
    float[] bandsY = computeBands( defHeight/Y,65,0.25f,0.5f,5);
865
    float[] bandsZ = computeBands( defHeight/Z,65,0.25f,0.5f,5);
866

    
867
    MeshBase[] meshes = new MeshPolygon[6];
868

    
869
    meshes[0] = new MeshPolygon(verticesYZ,bandsX,1,2);
870
    meshes[0].setEffectAssociation(0,1,0);
871
    meshes[1] = meshes[0].copy(true);
872
    meshes[1].setEffectAssociation(0,2,0);
873
    meshes[2] = new MeshPolygon(verticesXZ,bandsY,1,2);
874
    meshes[2].setEffectAssociation(0,4,0);
875
    meshes[3] = meshes[2].copy(true);
876
    meshes[3].setEffectAssociation(0,8,0);
877
    meshes[4] = new MeshPolygon(verticesXY,bandsZ,1,2);
878
    meshes[4].setEffectAssociation(0,16,0);
879
    meshes[5] = meshes[4].copy(true);
880
    meshes[5].setEffectAssociation(0,32,0);
881

    
882

    
883
    return new MeshJoined(meshes);
884
    }
885

    
886
///////////////////////////////////////////////////////////////////////////////////////////////////
887
// EFFECTS
888
///////////////////////////////////////////////////////////////////////////////////////////////////
889

    
890
  VertexEffect[] createVertexEffectsCube()
891
    {
892
    Static3D axisY   = new Static3D(0,1,0);
893
    Static3D axisX   = new Static3D(1,0,0);
894
    Static3D center  = new Static3D(0,0,0);
895
    Static1D angle90 = new Static1D(90);
896
    Static1D angle180= new Static1D(180);
897
    Static1D angle270= new Static1D(270);
898

    
899
    VertexEffect[] effect = new VertexEffect[6];
900

    
901
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
902
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
903
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
904
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
905
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
906
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
907

    
908
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
909
    effect[1].setMeshAssociation(32,-1);  // back
910
    effect[2].setMeshAssociation( 8,-1);  // bottom
911
    effect[3].setMeshAssociation( 4,-1);  // top
912
    effect[4].setMeshAssociation( 2,-1);  // left
913
    effect[5].setMeshAssociation( 1,-1);  // right
914

    
915
    return effect;
916
    }
917

    
918
///////////////////////////////////////////////////////////////////////////////////////////////////
919

    
920
  VertexEffect[] createVertexEffectsSkewbCorner()
921
    {
922
    float E = 0.5f;
923

    
924
    Static3D axisX  = new Static3D(1,0,0);
925
    Static3D axisY  = new Static3D(0,1,0);
926
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
927
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
928
    Static1D angle1 = new Static1D(+90);
929
    Static1D angle2 = new Static1D(-90);
930
    Static1D angle3 = new Static1D(-15);
931
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
932
    Static1D angle5 = new Static1D(120);
933
    Static1D angle6 = new Static1D(240);
934
    Static3D center1= new Static3D(0,0,0);
935
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
936
    Static3D move1  = new Static3D(-E/4,-E/4,0);
937
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
938

    
939
    VertexEffect[] effect = new VertexEffect[10];
940

    
941
    effect[0] = new VertexEffectMove(move1);
942
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
943
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
944
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
945
    effect[4] = new VertexEffectMove(move2);
946
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
947
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
948
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
949
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
950
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
951

    
952
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
953
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
954
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
955
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
956
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
957
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
958
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
959
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
960
    effect[8].setMeshAssociation(16,-1);  // mesh 4
961
    effect[9].setMeshAssociation(32,-1);  // mesh 5
962

    
963
    return effect;
964
    }
965

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

    
968
  VertexEffect[] createVertexEffectsSkewbFace()
969
    {
970
    Static3D center = new Static3D(0,0,0);
971
    Static3D axisX  = new Static3D(1,0,0);
972
    Static3D axisZ  = new Static3D(0,0,1);
973
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
974

    
975
    VertexEffect[] effect = new VertexEffect[6];
976

    
977
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
978
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
979
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
980
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
981
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
982
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
983

    
984
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
985
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
986
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
987
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
988
    effect[4].setMeshAssociation(16,-1);  // mesh 4
989
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
990

    
991
    return effect;
992
    }
993

    
994
///////////////////////////////////////////////////////////////////////////////////////////////////
995

    
996
  VertexEffect[] createVertexEffectsOcta()
997
    {
998
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
999
    Static1D angle1= new Static1D( 90);
1000
    Static1D angle2= new Static1D(180);
1001
    Static1D angle3= new Static1D(270);
1002
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
1003
    Static3D axisX = new Static3D(1,0,0);
1004
    Static3D axisY = new Static3D(0,1,0);
1005
    Static3D cent0 = new Static3D(0,0,0);
1006
    Static3D cent1 = new Static3D(0,SQ2/2,0);
1007
    Static3D flipY = new Static3D( 1,-1, 1);
1008
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
1009

    
1010
    VertexEffect[] effect = new VertexEffect[7];
1011

    
1012
    effect[0] = new VertexEffectScale(scale);
1013
    effect[1] = new VertexEffectMove(move1);
1014
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
1015
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
1016
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
1017
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
1018
    effect[6] = new VertexEffectScale(flipY);
1019

    
1020
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
1021
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
1022
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
1023
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
1024

    
1025
    return effect;
1026
    }
1027

    
1028
///////////////////////////////////////////////////////////////////////////////////////////////////
1029

    
1030
  VertexEffect[] createVertexEffectsTetra()
1031
    {
1032
    Static3D flipZ = new Static3D( 1, 1,-1);
1033
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
1034
    Static1D angle1= new Static1D( 90);
1035
    Static1D angle2= new Static1D(180);
1036
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
1037
    Static3D axisX = new Static3D(1,0,0);
1038
    Static3D axisY = new Static3D(0,1,0);
1039
    Static3D axisZ = new Static3D(0,0,1);
1040
    Static3D cent0 = new Static3D(0,0,0);
1041
    Static3D cent1 = new Static3D(0,SQ2/4,0);
1042
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
1043

    
1044
    VertexEffect[] effect = new VertexEffect[7];
1045

    
1046
    effect[0] = new VertexEffectScale(scale);
1047
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
1048
    effect[2] = new VertexEffectMove(move1);
1049
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
1050
    effect[4] = new VertexEffectScale(flipZ);
1051
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
1052
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
1053

    
1054
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
1055
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
1056
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
1057

    
1058
    return effect;
1059
    }
1060

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

    
1063
  VertexEffect[] createVertexEffectsDino()
1064
    {
1065
    float E = 0.5f*SQ2;
1066
    float F = 0.5f;
1067
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
1068

    
1069
    Static1D angle1 = new Static1D(-ANGLE);
1070
    Static1D angle2 = new Static1D(+ANGLE);
1071
    Static3D axisX  = new Static3D(1,0,0);
1072
    Static3D axisY  = new Static3D(0,1,0);
1073
    Static3D axisZ  = new Static3D(0,-1,1);
1074
    Static3D center0= new Static3D(0,0,0);
1075
    Static3D center1= new Static3D(0,-3*F,0);
1076

    
1077
    VertexEffect[] effect = new VertexEffect[10];
1078

    
1079
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
1080
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
1081
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
1082
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
1083
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
1084
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
1085
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
1086
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
1087
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
1088
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
1089

    
1090
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
1091
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
1092
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
1093
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 0
1094
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
1095
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
1096
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1097
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
1098
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
1099
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
1100

    
1101
    return effect;
1102
    }
1103

    
1104
///////////////////////////////////////////////////////////////////////////////////////////////////
1105

    
1106
  VertexEffect[] createVertexEffectsHelicopterCorner()
1107
    {
1108
    float E = 0.5f;
1109

    
1110
    Static3D axisX  = new Static3D(1,0,0);
1111
    Static3D axisY  = new Static3D(0,1,0);
1112
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
1113
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
1114
    Static1D angle1 = new Static1D(+90);
1115
    Static1D angle2 = new Static1D(-90);
1116
    Static1D angle3 = new Static1D(-135);
1117
    Static1D angle4 = new Static1D(90);
1118
    Static1D angle5 = new Static1D(120);
1119
    Static1D angle6 = new Static1D(240);
1120
    Static3D center1= new Static3D(0,0,0);
1121
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
1122
    Static3D move1  = new Static3D(-E/4,-E/4,0);
1123
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
1124

    
1125
    VertexEffect[] effect = new VertexEffect[10];
1126

    
1127
    effect[0] = new VertexEffectMove(move1);
1128
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
1129
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
1130
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
1131
    effect[4] = new VertexEffectMove(move2);
1132
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
1133
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1134
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1135
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1136
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1137

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

    
1149
    return effect;
1150
    }
1151

    
1152
///////////////////////////////////////////////////////////////////////////////////////////////////
1153

    
1154
  VertexEffect[] createVertexEffectsHelicopterFace()
1155
    {
1156
    float E = 0.5f;
1157
    float F = SQ2/4;
1158

    
1159
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1160
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1161
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1162
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1163
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1164
    Static1D angle1 = new Static1D(135);
1165
    Static1D angle2 = new Static1D(90);
1166
    Static1D angle3 = new Static1D(-90);
1167
    Static1D angle4 = new Static1D(-135);
1168
    Static3D axisX  = new Static3D(1,0,0);
1169
    Static3D axisY  = new Static3D(0,1,0);
1170
    Static3D axisZ  = new Static3D(0,0,1);
1171
    Static3D axis1  = new Static3D(1,-1,0);
1172
    Static3D center = new Static3D(0,0,0);
1173
    Static3D center1= new Static3D(-E/2,-E/2,0);
1174

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

    
1177
    effect[0] = new VertexEffectMove(move0);
1178
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1179
    effect[2] = new VertexEffectMove(move1);
1180
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1181
    effect[4] = new VertexEffectMove(move2);
1182
    effect[5] = new VertexEffectMove(move3);
1183
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1184
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1185
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1186
    effect[9] = new VertexEffectMove(move4);
1187

    
1188
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1189
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1190
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1191
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1192
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1193
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1194
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1195
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1196
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1197
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1198

    
1199
    return effect;
1200
    }
1201

    
1202
///////////////////////////////////////////////////////////////////////////////////////////////////
1203

    
1204
  VertexEffect[] createVertexEffectsRediEdge()
1205
    {
1206
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1207
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1208
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1209
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1210
    Static3D flipZ = new Static3D(1,1,-1);
1211
    Static3D flipX = new Static3D(-1,1,1);
1212
    Static3D scale = new Static3D(2,2,2);
1213
    Static3D cent0 = new Static3D(0,0, 0);
1214
    Static3D cent1 = new Static3D(0,0, -1.5f);
1215
    Static3D axisX = new Static3D(1,0, 0);
1216
    Static3D axisY = new Static3D(0,1, 0);
1217
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1218
    Static1D angle1= new Static1D(90);
1219
    Static1D angle2= new Static1D(45);
1220
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1221

    
1222
    VertexEffect[] effect = new VertexEffect[12];
1223

    
1224
    effect[0] = new VertexEffectScale(scale);
1225
    effect[1] = new VertexEffectMove(move0);
1226
    effect[2] = new VertexEffectScale(flipZ);
1227
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1228
    effect[4] = new VertexEffectMove(move1);
1229
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1230
    effect[6] = new VertexEffectMove(move2);
1231
    effect[7] = new VertexEffectScale(flipX);
1232
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1233
    effect[9] = new VertexEffectMove(move3);
1234
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1235
    effect[11]= new VertexEffectScale(flipX);
1236

    
1237
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1238
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1239
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1240
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1241
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1242
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1243
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1244
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1245
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1246
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1247
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1248
    effect[11].setMeshAssociation(32,-1); // mesh 5
1249

    
1250
    return effect;
1251
    }
1252

    
1253
///////////////////////////////////////////////////////////////////////////////////////////////////
1254

    
1255
  VertexEffect[] createVertexEffectsRediCorner()
1256
    {
1257
    Static3D axisY   = new Static3D(0,1,0);
1258
    Static3D axisX   = new Static3D(1,0,0);
1259
    Static3D axisZ   = new Static3D(0,0,1);
1260
    Static3D center  = new Static3D(0,0,0);
1261
    Static1D angle90 = new Static1D(90);
1262
    Static1D angle270= new Static1D(270);
1263
    Static1D angle45 = new Static1D(-45);
1264
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1265

    
1266
    VertexEffect[] effect = new VertexEffect[7];
1267

    
1268
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1269
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1270
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1271
    effect[3] = new VertexEffectScale(scale);
1272
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1273
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1274
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1275

    
1276
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1277
    effect[1].setMeshAssociation( 2,-1);  // 1
1278
    effect[2].setMeshAssociation( 4,-1);  // 2
1279
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1280
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1281
    effect[5].setMeshAssociation(16,-1);  // 4
1282
    effect[6].setMeshAssociation(32,-1);  // 5
1283

    
1284
    return effect;
1285
    }
1286

    
1287
///////////////////////////////////////////////////////////////////////////////////////////////////
1288

    
1289
  VertexEffect[] createVertexEffectsIvyCorner()
1290
    {
1291
    Static3D axisX  = new Static3D(1,0,0);
1292
    Static3D axisY  = new Static3D(0,1,0);
1293
    Static1D angle1 = new Static1D(+90);
1294
    Static1D angle2 = new Static1D(-90);
1295
    Static3D center = new Static3D(0,0,0);
1296
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1297

    
1298
    VertexEffect[] effect = new VertexEffect[5];
1299

    
1300
    effect[0] = new VertexEffectScale(1/IVY_C);
1301
    effect[1] = new VertexEffectMove(move1);
1302
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1303
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1304
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1305

    
1306
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1307
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1308
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1309

    
1310
    return effect;
1311
    }
1312

    
1313
///////////////////////////////////////////////////////////////////////////////////////////////////
1314

    
1315
  VertexEffect[] createVertexEffectsRexEdge()
1316
    {
1317
    float E = 0.5f - REX_D;
1318
    float F = 0.5f;
1319
    float G = (float)Math.sqrt(E*E+F*F);
1320
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1321

    
1322
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1323
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1324

    
1325
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1326
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1327
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1328
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1329
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1330
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1331

    
1332
    Static1D angle180 = new Static1D(180);
1333
    Static1D angle90  = new Static1D( 90);
1334
    Static1D angle270 = new Static1D(270);
1335
    Static1D angle1   = new Static1D(+A);
1336
    Static1D angle2   = new Static1D(-A);
1337

    
1338
    VertexEffect[] effect = new VertexEffect[12];
1339

    
1340
    effect[0] = new VertexEffectMove(move1);
1341
    effect[1] = new VertexEffectMove(move2);
1342
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1343
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1344
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1345
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1346
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1347
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1348
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1349
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1350
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1351
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1352

    
1353
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1354
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1355
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1356
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1357
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1358
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1359
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1360
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1361
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1362
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1363
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1364
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1365

    
1366
    return effect;
1367
    }
1368

    
1369
///////////////////////////////////////////////////////////////////////////////////////////////////
1370

    
1371
  VertexEffect[] createVertexEffectsRexCorner()
1372
    {
1373
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1374
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1375
    Static1D angle = new Static1D(45);
1376

    
1377
    VertexEffect[] effect = new VertexEffect[1];
1378
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1379

    
1380
    return effect;
1381
    }
1382

    
1383
///////////////////////////////////////////////////////////////////////////////////////////////////
1384

    
1385
  VertexEffect[] createVertexEffectsKilominxCorner()
1386
    {
1387
    VertexEffect[] effect = new VertexEffect[9];
1388

    
1389
    float H = 0.5f*(SIN54 / COS54);
1390
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1391
    float Y2= H/(2*COS_HALFD);
1392
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1393
    float sin18 = SIN18;
1394
    float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18));
1395
    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
1396

    
1397
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1398
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1399
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1400
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*SIN_HALFD/(COS_HALFD*LEN));
1401

    
1402
    Static3D move1 = new Static3D(0,-Y1,0);
1403
    Static3D move2 = new Static3D(0,-Y2,0);
1404
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1405
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1406

    
1407
    Static1D angle1 = new Static1D(54);
1408
    Static1D angle2 = new Static1D(A/2+18);
1409
    Static1D angle3 = new Static1D(90);
1410
    Static1D angle4 = new Static1D(120);
1411
    Static1D angle5 = new Static1D(240);
1412
    Static1D angle6 = new Static1D(90-A/2);
1413

    
1414
    effect[0] = new VertexEffectMove(move1);
1415
    effect[1] = new VertexEffectMove(move2);
1416
    effect[2] = new VertexEffectRotate(angle1, axisZ, center);
1417
    effect[3] = new VertexEffectRotate(angle2, axisZ, center);
1418
    effect[4] = new VertexEffectRotate(angle3, axisA, center);
1419
    effect[5] = new VertexEffectMove(move3);
1420
    effect[6] = new VertexEffectRotate(angle4, axisC, center);
1421
    effect[7] = new VertexEffectRotate(angle5, axisC, center);
1422
    effect[8] = new VertexEffectRotate(angle6, axisY, center);
1423

    
1424
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1425
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1426
    effect[2].setMeshAssociation( 7,-1);  // meshes 0,1,2
1427
    effect[3].setMeshAssociation(56,-1);  // meshes 3,4,5
1428
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1429
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1430
    effect[6].setMeshAssociation(18,-1);  // meshes 1,4
1431
    effect[7].setMeshAssociation(36,-1);  // meshes 2,5
1432

    
1433
    return effect;
1434
    }
1435

    
1436
///////////////////////////////////////////////////////////////////////////////////////////////////
1437

    
1438
  VertexEffect[] createVertexEffectsMegaminxCorner()
1439
    {
1440
    VertexEffect[] effect = new VertexEffect[9];
1441

    
1442
    float Y = COS54/(2*SIN54);
1443

    
1444
    float sinA = (2*SIN54*SIN54-1)/COS54;
1445
    float cosA = (float)Math.sqrt(1-sinA*sinA);
1446
    float LEN  = 0.5f/SIN54;
1447

    
1448
    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
1449
    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
1450
    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
1451

    
1452
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1453
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1454

    
1455
    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
1456
    Static3D move2= new Static3D(0.0f, Y , 0.0f );
1457

    
1458
    Static1D angleD = new Static1D(DIHEDRAL1);
1459
    Static1D angleE = new Static1D(360-DIHEDRAL1);
1460
    Static1D angleF = new Static1D(DIHEDRAL2);
1461

    
1462
    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
1463
    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
1464
    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
1465
    effect[3] = new VertexEffectMove(move1);
1466
    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
1467
    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
1468
    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
1469
    effect[7] = new VertexEffectMove(move2);
1470
    effect[8] = new VertexEffectScale(SIN54);
1471

    
1472
    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
1473
    effect[1].setMeshAssociation( 16,-1);  // mesh 4
1474
    effect[2].setMeshAssociation( 32,-1);  // mesh 5
1475
    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
1476
    effect[4].setMeshAssociation(  1,-1);  // mesh 0
1477
    effect[5].setMeshAssociation(  2,-1);  // mesh 1
1478

    
1479
    return effect;
1480
    }
1481

    
1482
///////////////////////////////////////////////////////////////////////////////////////////////////
1483

    
1484
  VertexEffect[] createVertexEffectsMegaminxEdge(float width, float height)
1485
    {
1486
    VertexEffect[] effect = new VertexEffect[11];
1487

    
1488
    float X = 0.5f*height;
1489
    float Y = height*(COS54/COS18) + width*0.5f;
1490
    float Z = 2*height*COS_HALFD;
1491

    
1492
    float alpha = 90-DIHEDRAL1/2;
1493
    float beta  = DIHEDRAL2;
1494

    
1495
    Static1D angle1 = new Static1D(alpha);
1496
    Static1D angle2 = new Static1D(180-alpha);
1497
    Static1D angle3 = new Static1D(beta);
1498

    
1499
    Static3D move1 = new Static3D(X,0,0);
1500
    Static3D move2 = new Static3D(X,0,-Z);
1501
    Static3D move3 = new Static3D(0,+Y,0);
1502
    Static3D move4 = new Static3D(0,-Y,0);
1503
    Static3D scale = new Static3D(+1,+1,-1);
1504

    
1505
    Static3D axisXplus = new Static3D(+1, 0, 0);
1506
    Static3D axisXminus= new Static3D(-1, 0, 0);
1507
    Static3D axisYplus = new Static3D( 0,+1, 0);
1508
    Static3D axisYminus= new Static3D( 0,-1, 0);
1509

    
1510
    Static3D center1= new Static3D( 0, 0, 0);
1511
    Static3D center2= new Static3D( 0, 0,-Z);
1512
    Static3D center3= new Static3D( 0,+width*0.5f, 0);
1513
    Static3D center4= new Static3D( 0,-width*0.5f, 0);
1514

    
1515
    effect[ 0] = new VertexEffectMove(move1);
1516
    effect[ 1] = new VertexEffectMove(move2);
1517
    effect[ 2] = new VertexEffectMove(move3);
1518
    effect[ 3] = new VertexEffectMove(move4);
1519
    effect[ 4] = new VertexEffectScale(scale);
1520
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1521
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1522
    effect[ 7] = new VertexEffectRotate(angle1, axisYminus, center2);
1523
    effect[ 8] = new VertexEffectRotate(angle2, axisYminus, center2);
1524
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center3);
1525
    effect[10] = new VertexEffectRotate(angle3, axisXminus, center4);
1526

    
1527
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1528
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1529
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1530
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1531
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1532
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1533
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1534
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1535
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1536
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1537
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1538

    
1539
    return effect;
1540
    }
1541

    
1542
///////////////////////////////////////////////////////////////////////////////////////////////////
1543

    
1544
  VertexEffect[] createCuboidEffects(int[] dimensions)
1545
    {
1546
    float X = dimensions[0];
1547
    float Y = dimensions[1];
1548
    float Z = dimensions[2];
1549

    
1550
    float MAX_XY = Math.max(X,Y);
1551
    float MAX_XZ = Math.max(X,Z);
1552
    float MAX_YZ = Math.max(Z,Y);
1553

    
1554
    Static1D angle = new Static1D(90);
1555
    Static3D move  = new Static3D( 0.0f, 0.0f, 0.5f);
1556
    Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
1557
    Static3D axisY = new Static3D( 0.0f, 1.0f, 0.0f);
1558
    Static3D center= new Static3D( 0.0f, 0.0f, 0.0f);
1559

    
1560
    Static3D scale3 = new Static3D(MAX_XY,MAX_XY,+Z);
1561
    Static3D scale4 = new Static3D(MAX_XY,MAX_XY,-Z);
1562
    Static3D scale5 = new Static3D(MAX_XZ,+Y,MAX_XZ);
1563
    Static3D scale6 = new Static3D(MAX_XZ,-Y,MAX_XZ);
1564
    Static3D scale7 = new Static3D(+X,MAX_YZ,MAX_YZ);
1565
    Static3D scale8 = new Static3D(-X,MAX_YZ,MAX_YZ);
1566

    
1567
    VertexEffect[] effect = new VertexEffect[9];
1568

    
1569
    effect[0] = new VertexEffectMove(move);
1570
    effect[1] = new VertexEffectRotate(angle, axisX, center);
1571
    effect[2] = new VertexEffectRotate(angle, axisY, center);
1572
    effect[3] = new VertexEffectScale(scale3);
1573
    effect[4] = new VertexEffectScale(scale4);
1574
    effect[5] = new VertexEffectScale(scale5);
1575
    effect[6] = new VertexEffectScale(scale6);
1576
    effect[7] = new VertexEffectScale(scale7);
1577
    effect[8] = new VertexEffectScale(scale8);
1578

    
1579
    effect[1].setMeshAssociation(12,-1);  // meshes 2,3
1580
    effect[2].setMeshAssociation( 3,-1);  // meshes 0,1
1581
    effect[3].setMeshAssociation(16,-1);  // mesh 4
1582
    effect[4].setMeshAssociation(32,-1);  // mesh 5
1583
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1584
    effect[6].setMeshAssociation( 4,-1);  // mesh 2
1585
    effect[7].setMeshAssociation( 1,-1);  // mesh 0
1586
    effect[8].setMeshAssociation( 2,-1);  // mesh 1
1587

    
1588
    return effect;
1589
    }
1590

    
1591
///////////////////////////////////////////////////////////////////////////////////////////////////
1592
// OBJECTS
1593
///////////////////////////////////////////////////////////////////////////////////////////////////
1594
// CUBE
1595

    
1596
  MeshBase createCubeMesh(int index)
1597
    {
1598
    MeshBase mesh = createFacesCube(index);
1599
    VertexEffect[] effects = createVertexEffectsCube();
1600
    for( VertexEffect effect : effects ) mesh.apply(effect);
1601

    
1602
    Static3D roundingCenter  = new Static3D(0,0,0);
1603
    Static3D[] vertices = new Static3D[8];
1604
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1605
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1606
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1607
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1608
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1609
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1610
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1611
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1612

    
1613
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1614

    
1615
    mesh.mergeEffComponents();
1616

    
1617
    return mesh;
1618
    }
1619

    
1620
///////////////////////////////////////////////////////////////////////////////////////////////////
1621
// SKEWB
1622

    
1623
  MeshBase createSkewbCornerMesh()
1624
    {
1625
    MeshBase mesh = createFacesSkewbCorner();
1626
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1627
    for( VertexEffect effect : effects ) mesh.apply(effect);
1628

    
1629
    float E = 0.5f;
1630
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1631

    
1632
    Static3D[] verticesType1 = new Static3D[1];
1633
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1634
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1635

    
1636
    Static3D[] verticesType2 = new Static3D[3];
1637
    verticesType2[0] = new Static3D(-E, 0, 0);
1638
    verticesType2[1] = new Static3D( 0,-E, 0);
1639
    verticesType2[2] = new Static3D( 0, 0,-E);
1640
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1641

    
1642
    mesh.mergeEffComponents();
1643

    
1644
    return mesh;
1645
    }
1646

    
1647
///////////////////////////////////////////////////////////////////////////////////////////////////
1648

    
1649
  MeshBase createSkewbFaceMesh()
1650
    {
1651
    MeshBase mesh = createFacesSkewbFace();
1652
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1653
    for( VertexEffect effect : effects ) mesh.apply(effect);
1654

    
1655
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1656
    float E = SQ2/4;
1657
    Static3D[] vertices = new Static3D[4];
1658
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1659
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1660
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1661
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1662
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1663

    
1664
    mesh.mergeEffComponents();
1665
    mesh.addEmptyTexComponent();
1666

    
1667
    return mesh;
1668
    }
1669

    
1670
///////////////////////////////////////////////////////////////////////////////////////////////////
1671
// SKEWB DIAMOND / PYRAMINX
1672

    
1673
  MeshBase createOctaMesh()
1674
    {
1675
    MeshBase mesh = createFacesOcta();
1676
    VertexEffect[] effects = createVertexEffectsOcta();
1677
    for( VertexEffect effect : effects ) mesh.apply(effect);
1678

    
1679
    Static3D roundingCenter = new Static3D(0,0,0);
1680
    Static3D[] vertices = new Static3D[6];
1681
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1682
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1683
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1684
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1685
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1686
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1687

    
1688
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1689

    
1690
    mesh.mergeEffComponents();
1691

    
1692
    return mesh;
1693
    }
1694

    
1695
///////////////////////////////////////////////////////////////////////////////////////////////////
1696

    
1697
  MeshBase createTetraMesh()
1698
    {
1699
    MeshBase mesh = createFacesTetra();
1700
    VertexEffect[] effects = createVertexEffectsTetra();
1701
    for( VertexEffect effect : effects ) mesh.apply(effect);
1702

    
1703
    Static3D roundingCenter = new Static3D(0,0,0);
1704
    Static3D[] verticesRound = new Static3D[4];
1705
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1706
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1707
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1708
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1709
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1710

    
1711
    mesh.mergeEffComponents();
1712
    mesh.addEmptyTexComponent();
1713
    mesh.addEmptyTexComponent();
1714
    mesh.addEmptyTexComponent();
1715
    mesh.addEmptyTexComponent();
1716

    
1717
    return mesh;
1718
    }
1719

    
1720
///////////////////////////////////////////////////////////////////////////////////////////////////
1721
// DINO
1722

    
1723
  MeshBase createDinoMesh()
1724
    {
1725
    MeshBase mesh = createFacesDino();
1726
    VertexEffect[] effects = createVertexEffectsDino();
1727
    for( VertexEffect effect : effects ) mesh.apply(effect);
1728

    
1729
    float F = 0.5f;
1730
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1731
    Static3D[] verticesRound = new Static3D[4];
1732
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1733
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1734
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1735
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1736
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1737

    
1738
    mesh.mergeEffComponents();
1739

    
1740
    return mesh;
1741
    }
1742

    
1743
///////////////////////////////////////////////////////////////////////////////////////////////////
1744
// Helicopter
1745

    
1746
  MeshBase createHelicopterCornerMesh()
1747
    {
1748
    MeshBase mesh = createFacesHelicopterCorner();
1749
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1750
    for( VertexEffect effect : effects ) mesh.apply(effect);
1751

    
1752
    float E = 0.5f;
1753
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1754

    
1755
    Static3D[] verticesType1 = new Static3D[1];
1756
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1757
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1758

    
1759
    Static3D[] verticesType2 = new Static3D[3];
1760
    verticesType2[0] = new Static3D(-E, 0, 0);
1761
    verticesType2[1] = new Static3D( 0,-E, 0);
1762
    verticesType2[2] = new Static3D( 0, 0,-E);
1763
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1764

    
1765
    mesh.mergeEffComponents();
1766

    
1767
    return mesh;
1768
    }
1769

    
1770
///////////////////////////////////////////////////////////////////////////////////////////////////
1771

    
1772
  MeshBase createHelicopterFaceMesh()
1773
    {
1774
    MeshBase mesh = createFacesHelicopterFace();
1775
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1776
    for( VertexEffect effect : effects ) mesh.apply(effect);
1777

    
1778
    float E = 0.5f;
1779
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1780

    
1781
    Static3D[] verticesType1 = new Static3D[1];
1782
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1783
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1784

    
1785
    Static3D[] verticesType2 = new Static3D[2];
1786
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1787
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1788
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1789

    
1790
    mesh.mergeEffComponents();
1791
    mesh.addEmptyTexComponent();
1792
    mesh.addEmptyTexComponent();
1793

    
1794
    return mesh;
1795
    }
1796

    
1797
///////////////////////////////////////////////////////////////////////////////////////////////////
1798
// Redi cube
1799

    
1800
  MeshBase createRediEdgeMesh()
1801
    {
1802
    MeshBase mesh = createFacesRediEdge();
1803
    VertexEffect[] effects = createVertexEffectsRediEdge();
1804
    for( VertexEffect effect : effects ) mesh.apply(effect);
1805

    
1806
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1807
    Static3D[] vertices = new Static3D[2];
1808
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1809
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1810
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1811

    
1812
    mesh.mergeEffComponents();
1813

    
1814
    return mesh;
1815
    }
1816

    
1817
///////////////////////////////////////////////////////////////////////////////////////////////////
1818

    
1819
  MeshBase createRediCornerMesh()
1820
    {
1821
    MeshBase mesh = createFacesRediCorner();
1822
    VertexEffect[] effects = createVertexEffectsRediCorner();
1823
    for( VertexEffect effect : effects ) mesh.apply(effect);
1824

    
1825
    Static3D center = new Static3D(0,0,0);
1826
    Static3D[] vertices = new Static3D[8];
1827
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1828
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1829
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1830
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1831
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1832
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1833
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1834
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1835

    
1836
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1837

    
1838
    mesh.mergeEffComponents();
1839

    
1840
    return mesh;
1841
    }
1842

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

    
1845
  MeshBase createIvyCornerMesh()
1846
    {
1847
    MeshBase mesh = createFacesIvyCorner();
1848
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1849
    for( VertexEffect effect : effects ) mesh.apply(effect);
1850

    
1851
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1852
    Static3D[] vertices = new Static3D[4];
1853
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1854
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1855
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1856
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1857

    
1858
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1859

    
1860
    mesh.mergeEffComponents();
1861

    
1862
    return mesh;
1863
    }
1864

    
1865
///////////////////////////////////////////////////////////////////////////////////////////////////
1866

    
1867
  MeshBase createIvyFaceMesh()
1868
    {
1869
    MeshBase mesh = createFacesIvyFace();
1870

    
1871
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1872
    Static3D[] vertices = new Static3D[2];
1873
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1874
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1875

    
1876
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1877

    
1878
    mesh.mergeEffComponents();
1879
    mesh.addEmptyTexComponent();
1880
    mesh.addEmptyTexComponent();
1881
    mesh.addEmptyTexComponent();
1882
    mesh.addEmptyTexComponent();
1883

    
1884
    return mesh;
1885
    }
1886

    
1887
///////////////////////////////////////////////////////////////////////////////////////////////////
1888

    
1889
  MeshBase createRexCornerMesh()
1890
    {
1891
    MeshBase mesh = createFacesRexCorner();
1892
    VertexEffect[] effects = createVertexEffectsRexCorner();
1893
    for( VertexEffect effect : effects ) mesh.apply(effect);
1894

    
1895
    Static3D center = new Static3D(0.0f,0.0f,-0.25f);
1896
    Static3D[] vertices = new Static3D[1];
1897
    vertices[0] = new Static3D(+0.25f,+0.25f,+0.0f);
1898
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1899

    
1900
    mesh.mergeEffComponents();
1901
    mesh.addEmptyTexComponent();
1902
    mesh.addEmptyTexComponent();
1903

    
1904
    return mesh;
1905
    }
1906

    
1907
///////////////////////////////////////////////////////////////////////////////////////////////////
1908

    
1909
  MeshBase createRexFaceMesh()
1910
    {
1911
    MeshBase mesh = createFacesRexFace();
1912

    
1913
    mesh.mergeEffComponents();
1914
    mesh.addEmptyTexComponent();
1915
    mesh.addEmptyTexComponent();
1916

    
1917
    return mesh;
1918
    }
1919

    
1920
///////////////////////////////////////////////////////////////////////////////////////////////////
1921

    
1922
  MeshBase createRexEdgeMesh()
1923
    {
1924
    MeshBase mesh = createFacesRexEdge();
1925
    VertexEffect[] effects = createVertexEffectsRexEdge();
1926
    for( VertexEffect effect : effects ) mesh.apply(effect);
1927

    
1928
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1929
    Static3D[] vertices = new Static3D[2];
1930
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1931
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1932
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1933

    
1934
    mesh.mergeEffComponents();
1935

    
1936
    return mesh;
1937
    }
1938

    
1939
///////////////////////////////////////////////////////////////////////////////////////////////////
1940

    
1941
  MeshBase createKilominxCornerMesh()
1942
    {
1943
    MeshBase mesh = createFacesKilominxCorner();
1944
    VertexEffect[] effects = createVertexEffectsKilominxCorner();
1945
    for( VertexEffect effect : effects ) mesh.apply(effect);
1946

    
1947
    float A = (2*SQ3/3)* SIN54;
1948
    float B = 0.4f;
1949
    float X = SIN_HALFD* SIN54 * COS54;
1950
    float Y = SIN54 * SIN54 - 0.5f;
1951
    float Z = COS_HALFD* SIN54 * COS54;
1952

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

    
1955
    Static3D[] vertices = new Static3D[4];
1956
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1957
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1958
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1959
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1960

    
1961
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1962

    
1963
    //mesh.mergeEffComponents();
1964

    
1965
    return mesh;
1966
    }
1967

    
1968
///////////////////////////////////////////////////////////////////////////////////////////////////
1969

    
1970
  MeshBase createMegaminxCornerMesh()
1971
    {
1972
    MeshBase mesh = createFacesMegaminxCorner();
1973
    VertexEffect[] effects = createVertexEffectsMegaminxCorner();
1974
    for( VertexEffect effect : effects ) mesh.apply(effect);
1975

    
1976
    float A = (2*SQ3/3)* SIN54;
1977
    float B = 0.4f;
1978
    float X = SIN_HALFD* SIN54 * COS54;
1979
    float Y = SIN54 * SIN54 - 0.5f;
1980
    float Z = COS_HALFD* SIN54 * COS54;
1981

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

    
1984
    Static3D[] vertices = new Static3D[4];
1985
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1986
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1987
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1988
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1989

    
1990
    roundCorners(mesh,center,vertices,0.04f,0.10f);
1991

    
1992
    //mesh.mergeEffComponents();
1993

    
1994
    return mesh;
1995
    }
1996

    
1997
///////////////////////////////////////////////////////////////////////////////////////////////////
1998

    
1999
  MeshBase createMegaminxEdgeMesh(float width, float height)
2000
    {
2001
    MeshBase mesh = createFacesMegaminxEdge(width,height);
2002
    VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
2003
    for( VertexEffect effect : effects ) mesh.apply(effect);
2004

    
2005
    //mesh.mergeEffComponents();
2006

    
2007
    return mesh;
2008
    }
2009

    
2010
///////////////////////////////////////////////////////////////////////////////////////////////////
2011

    
2012
  MeshBase createCuboidMesh(int[] dimensions)
2013
    {
2014
    MeshBase mesh = createCuboid(dimensions);
2015
    VertexEffect[] effects = createCuboidEffects(dimensions);
2016
    for( VertexEffect effect : effects ) mesh.apply(effect);
2017

    
2018
  //  mesh.mergeEffComponents();
2019

    
2020
    return mesh;
2021
    }
2022
  }
(1-1/5)