Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 22b32e57

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

    
20
package org.distorted.objects;
21

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

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

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

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

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

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

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

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

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

    
70
  private FactoryCubit()
71
    {
72

    
73
    }
74

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

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

    
81
    return mThis;
82
    }
83

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
189
    return bands;
190
    }
191

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

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

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

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

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

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

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

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

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

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

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

    
246
    return new MeshJoined(meshes);
247
    }
248

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

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

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

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

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

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

    
278
    return new MeshJoined(meshes);
279
    }
280

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

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

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

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

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

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

    
306
    return new MeshJoined(meshes);
307
    }
308

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

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

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

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

    
337
    return new MeshJoined(meshes);
338
    }
339

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

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

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

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

    
360
    return new MeshJoined(meshes);
361
    }
362

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

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

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

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

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

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

    
387
    return new MeshJoined(meshes);
388
    }
389

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

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

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

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

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

    
418
    return new MeshJoined(meshes);
419
    }
420

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

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

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

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

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

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

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

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

    
449
    return new MeshJoined(meshes);
450
    }
451

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

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

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

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

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

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

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

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

    
484
    return new MeshJoined(meshes);
485
    }
486

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

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

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

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

    
504
    float F = 0.5f;
505
    float X = 0.5f;
506
    float G = 0.72f;
507
    float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F };
508
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
509

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

    
517
    return new MeshJoined(meshes);
518
    }
519

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

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

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

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

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

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

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

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

    
564
    return new MeshJoined(meshes);
565
    }
566

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

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

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

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

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

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

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

    
596
    return new MeshJoined(meshes);
597
    }
598

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

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

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

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

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

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

    
620
    return new MeshJoined(meshes);
621
    }
622

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

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

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

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

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

    
639
    return new MeshJoined(meshes);
640
    }
641

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

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

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

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

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

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

    
671
    return new MeshJoined(meshes);
672
    }
673

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

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

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

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

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

    
706
    return new MeshJoined(meshes);
707
    }
708

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

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

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

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

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

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

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

    
740
    return new MeshJoined(meshes);
741
    }
742

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

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

    
749
    float D = height/COS18;
750
    float W = D*SIN18;
751
    float X1 = height/2;
752
    float Y1 = width/2;
753
    float Y2 = (width+W)/2;
754
    float X3 = D*SIN54;
755
    float Y3 = D*COS54;
756
    float X4 = height*SIN_HALFD;
757
    float Y4 = height*COS_HALFD;
758

    
759
    float[] vertices0 = { -X1,-Y1, X1, -Y1, X1, Y1+W,-X1, Y1 };
760
    float[] vertices1 = { -X1,-Y2, X1, -Y2, X1, Y2+W,-X1, Y2 };
761
    float[] vertices2 = { -X3, 0.0f, 0.0f, -Y3, X3, 0.0f, 0.0f, Y3 };
762
    float[] vertices3 = { -X4, 0.0f, 0.0f, -Y4, X4, 0.0f, 0.0f, Y4 };
763

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

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

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

    
784
    return new MeshJoined(meshes);
785
    }
786

    
787
///////////////////////////////////////////////////////////////////////////////////////////////////
788

    
789
  MeshBase createFacesMegaminxEdge(int numLayers, float width, float height)
790
    {
791
    MeshBase[] meshes = new MeshPolygon[6];
792

    
793
    float D = height/COS18;
794
    float W = D*SIN18;
795

    
796
    float Y1 = 0.5f*width;
797
    float Y2 = 0.5f*width + W;
798
    float Y3 = 0.5f*width + 2*W;
799
    float X2 = D*SIN54;
800
    float X1 = 0.5f*height;
801
    float Y4 = D*COS54;
802

    
803
    float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
804
    float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 };
805
    float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 };
806

    
807
    int numBands0 = numLayers==3 ? 5 : 3;
808
    int numBands1 = numLayers==3 ? 2 : 2;
809
    float h       = numLayers==3 ? 0.03f : 0.03f;
810

    
811
    float[] bands0 = computeBands(h    ,34,0.2f,0.2f,numBands0);
812
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,numBands1);
813

    
814
    meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0);
815
    meshes[0].setEffectAssociation(0, 1,0);
816
    meshes[1] = meshes[0].copy(true);
817
    meshes[1].setEffectAssociation(0, 2,0);
818
    meshes[2] = new MeshPolygon(vertices1, bands1, 0, 0);
819
    meshes[2].setEffectAssociation(0, 4,0);
820
    meshes[3] = meshes[2].copy(true);
821
    meshes[3].setEffectAssociation(0, 8,0);
822
    meshes[4] = new MeshPolygon(vertices2, bands1, 0, 0);
823
    meshes[4].setEffectAssociation(0,16,0);
824
    meshes[5] = meshes[4].copy(true);
825
    meshes[5].setEffectAssociation(0,32,0);
826

    
827
    return new MeshJoined(meshes);
828
    }
829

    
830
///////////////////////////////////////////////////////////////////////////////////////////////////
831

    
832
  MeshBase createFacesMegaminxCenter(int numLayers)
833
    {
834
    MeshBase[] meshes = new MeshPolygon[2];
835

    
836
    float R  = 0.5f;
837
    float X1 = R*COS54;
838
    float Y1 = R*SIN54;
839
    float X2 = R*COS18;
840
    float Y2 = R*SIN18;
841

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

    
844
    int numBands0 = numLayers==3 ? 4 : 3;
845
    int numBands1 = numLayers==3 ? 2 : 2;
846
    float h       = numLayers==3 ? 0.04f : 0.04f;
847

    
848
    float[] bands0 = computeBands( h    ,45, R/3,0.2f, numBands0);
849
    float[] bands1 = computeBands( 0.00f,34, R/3,0.2f, numBands1);
850

    
851
    meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0);
852
    meshes[0].setEffectAssociation(0,1,0);
853
    meshes[1] = new MeshPolygon(vertices0, bands1, 0, 0);
854
    meshes[1].setEffectAssociation(0,2,0);
855

    
856
    return new MeshJoined(meshes);
857
    }
858

    
859
///////////////////////////////////////////////////////////////////////////////////////////////////
860

    
861
  private float[] createVertices(int A, int B)
862
    {
863
    float E = 0.5f / Math.max(A,B);
864
    return new float[] { -A*E,-B*E, +A*E,-B*E, +A*E,+B*E, -A*E,+B*E };
865
    }
866

    
867
///////////////////////////////////////////////////////////////////////////////////////////////////
868

    
869
  MeshBase createCuboid(int[] dimensions)
870
    {
871
    int X = dimensions[0];
872
    int Y = dimensions[1];
873
    int Z = dimensions[2];
874

    
875
    float[] verticesXY = createVertices(X,Y);
876
    float[] verticesXZ = createVertices(X,Z);
877
    float[] verticesYZ = createVertices(Z,Y);
878

    
879
    float defHeight = 0.048f;
880

    
881
    float[] bandsX = computeBands( defHeight/X,65,0.25f,0.5f,5);
882
    float[] bandsY = computeBands( defHeight/Y,65,0.25f,0.5f,5);
883
    float[] bandsZ = computeBands( defHeight/Z,65,0.25f,0.5f,5);
884

    
885
    MeshBase[] meshes = new MeshPolygon[6];
886

    
887
    meshes[0] = new MeshPolygon(verticesYZ,bandsX,1,2);
888
    meshes[0].setEffectAssociation(0,1,0);
889
    meshes[1] = meshes[0].copy(true);
890
    meshes[1].setEffectAssociation(0,2,0);
891
    meshes[2] = new MeshPolygon(verticesXZ,bandsY,1,2);
892
    meshes[2].setEffectAssociation(0,4,0);
893
    meshes[3] = meshes[2].copy(true);
894
    meshes[3].setEffectAssociation(0,8,0);
895
    meshes[4] = new MeshPolygon(verticesXY,bandsZ,1,2);
896
    meshes[4].setEffectAssociation(0,16,0);
897
    meshes[5] = meshes[4].copy(true);
898
    meshes[5].setEffectAssociation(0,32,0);
899

    
900
    return new MeshJoined(meshes);
901
    }
902

    
903
///////////////////////////////////////////////////////////////////////////////////////////////////
904
// EFFECTS
905
///////////////////////////////////////////////////////////////////////////////////////////////////
906

    
907
  VertexEffect[] createVertexEffectsCube()
908
    {
909
    Static3D axisY   = new Static3D(0,1,0);
910
    Static3D axisX   = new Static3D(1,0,0);
911
    Static3D center  = new Static3D(0,0,0);
912
    Static1D angle90 = new Static1D(90);
913
    Static1D angle180= new Static1D(180);
914
    Static1D angle270= new Static1D(270);
915

    
916
    VertexEffect[] effect = new VertexEffect[6];
917

    
918
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
919
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
920
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
921
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
922
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
923
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
924

    
925
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
926
    effect[1].setMeshAssociation(32,-1);  // back
927
    effect[2].setMeshAssociation( 8,-1);  // bottom
928
    effect[3].setMeshAssociation( 4,-1);  // top
929
    effect[4].setMeshAssociation( 2,-1);  // left
930
    effect[5].setMeshAssociation( 1,-1);  // right
931

    
932
    return effect;
933
    }
934

    
935
///////////////////////////////////////////////////////////////////////////////////////////////////
936

    
937
  VertexEffect[] createVertexEffectsSkewbCorner()
938
    {
939
    float E = 0.5f;
940

    
941
    Static3D axisX  = new Static3D(1,0,0);
942
    Static3D axisY  = new Static3D(0,1,0);
943
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
944
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
945
    Static1D angle1 = new Static1D(+90);
946
    Static1D angle2 = new Static1D(-90);
947
    Static1D angle3 = new Static1D(-15);
948
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
949
    Static1D angle5 = new Static1D(120);
950
    Static1D angle6 = new Static1D(240);
951
    Static3D center1= new Static3D(0,0,0);
952
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
953
    Static3D move1  = new Static3D(-E/4,-E/4,0);
954
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
955

    
956
    VertexEffect[] effect = new VertexEffect[10];
957

    
958
    effect[0] = new VertexEffectMove(move1);
959
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
960
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
961
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
962
    effect[4] = new VertexEffectMove(move2);
963
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
964
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
965
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
966
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
967
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
968

    
969
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
970
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
971
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
972
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
973
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
974
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
975
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
976
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
977
    effect[8].setMeshAssociation(16,-1);  // mesh 4
978
    effect[9].setMeshAssociation(32,-1);  // mesh 5
979

    
980
    return effect;
981
    }
982

    
983
///////////////////////////////////////////////////////////////////////////////////////////////////
984

    
985
  VertexEffect[] createVertexEffectsSkewbFace()
986
    {
987
    Static3D center = new Static3D(0,0,0);
988
    Static3D axisX  = new Static3D(1,0,0);
989
    Static3D axisZ  = new Static3D(0,0,1);
990
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
991

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

    
994
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
995
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
996
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
997
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
998
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
999
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
1000

    
1001
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
1002
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1003
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
1004
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
1005
    effect[4].setMeshAssociation(16,-1);  // mesh 4
1006
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
1007

    
1008
    return effect;
1009
    }
1010

    
1011
///////////////////////////////////////////////////////////////////////////////////////////////////
1012

    
1013
  VertexEffect[] createVertexEffectsOcta()
1014
    {
1015
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
1016
    Static1D angle1= new Static1D( 90);
1017
    Static1D angle2= new Static1D(180);
1018
    Static1D angle3= new Static1D(270);
1019
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
1020
    Static3D axisX = new Static3D(1,0,0);
1021
    Static3D axisY = new Static3D(0,1,0);
1022
    Static3D cent0 = new Static3D(0,0,0);
1023
    Static3D cent1 = new Static3D(0,SQ2/2,0);
1024
    Static3D flipY = new Static3D( 1,-1, 1);
1025
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
1026

    
1027
    VertexEffect[] effect = new VertexEffect[7];
1028

    
1029
    effect[0] = new VertexEffectScale(scale);
1030
    effect[1] = new VertexEffectMove(move1);
1031
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
1032
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
1033
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
1034
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
1035
    effect[6] = new VertexEffectScale(flipY);
1036

    
1037
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
1038
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
1039
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
1040
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
1041

    
1042
    return effect;
1043
    }
1044

    
1045
///////////////////////////////////////////////////////////////////////////////////////////////////
1046

    
1047
  VertexEffect[] createVertexEffectsTetra()
1048
    {
1049
    Static3D flipZ = new Static3D( 1, 1,-1);
1050
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
1051
    Static1D angle1= new Static1D( 90);
1052
    Static1D angle2= new Static1D(180);
1053
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
1054
    Static3D axisX = new Static3D(1,0,0);
1055
    Static3D axisY = new Static3D(0,1,0);
1056
    Static3D axisZ = new Static3D(0,0,1);
1057
    Static3D cent0 = new Static3D(0,0,0);
1058
    Static3D cent1 = new Static3D(0,SQ2/4,0);
1059
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
1060

    
1061
    VertexEffect[] effect = new VertexEffect[7];
1062

    
1063
    effect[0] = new VertexEffectScale(scale);
1064
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
1065
    effect[2] = new VertexEffectMove(move1);
1066
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
1067
    effect[4] = new VertexEffectScale(flipZ);
1068
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
1069
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
1070

    
1071
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
1072
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
1073
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
1074

    
1075
    return effect;
1076
    }
1077

    
1078
///////////////////////////////////////////////////////////////////////////////////////////////////
1079

    
1080
  VertexEffect[] createVertexEffectsDino()
1081
    {
1082
    float E = 0.5f*SQ2;
1083
    float F = 0.5f;
1084
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
1085

    
1086
    Static1D angle1 = new Static1D(-ANGLE);
1087
    Static1D angle2 = new Static1D(+ANGLE);
1088
    Static3D axisX  = new Static3D(1,0,0);
1089
    Static3D axisY  = new Static3D(0,1,0);
1090
    Static3D axisZ  = new Static3D(0,-1,1);
1091
    Static3D center0= new Static3D(0,0,0);
1092
    Static3D center1= new Static3D(0,-3*F,0);
1093

    
1094
    VertexEffect[] effect = new VertexEffect[10];
1095

    
1096
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
1097
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
1098
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
1099
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
1100
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
1101
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
1102
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
1103
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
1104
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
1105
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
1106

    
1107
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
1108
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
1109
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
1110
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
1111
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
1112
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
1113
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1114
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
1115
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
1116
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
1117

    
1118
    return effect;
1119
    }
1120

    
1121
///////////////////////////////////////////////////////////////////////////////////////////////////
1122

    
1123
  VertexEffect[] createVertexEffectsHelicopterCorner()
1124
    {
1125
    float E = 0.5f;
1126

    
1127
    Static3D axisX  = new Static3D(1,0,0);
1128
    Static3D axisY  = new Static3D(0,1,0);
1129
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
1130
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
1131
    Static1D angle1 = new Static1D(+90);
1132
    Static1D angle2 = new Static1D(-90);
1133
    Static1D angle3 = new Static1D(-135);
1134
    Static1D angle4 = new Static1D(90);
1135
    Static1D angle5 = new Static1D(120);
1136
    Static1D angle6 = new Static1D(240);
1137
    Static3D center1= new Static3D(0,0,0);
1138
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
1139
    Static3D move1  = new Static3D(-E/4,-E/4,0);
1140
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
1141

    
1142
    VertexEffect[] effect = new VertexEffect[10];
1143

    
1144
    effect[0] = new VertexEffectMove(move1);
1145
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
1146
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
1147
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
1148
    effect[4] = new VertexEffectMove(move2);
1149
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
1150
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1151
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1152
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1153
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1154

    
1155
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1156
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1157
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1158
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1159
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1160
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1161
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1162
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1163
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1164
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1165

    
1166
    return effect;
1167
    }
1168

    
1169
///////////////////////////////////////////////////////////////////////////////////////////////////
1170

    
1171
  VertexEffect[] createVertexEffectsHelicopterFace()
1172
    {
1173
    float E = 0.5f;
1174
    float F = SQ2/4;
1175

    
1176
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1177
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1178
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1179
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1180
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1181
    Static1D angle1 = new Static1D(135);
1182
    Static1D angle2 = new Static1D(90);
1183
    Static1D angle3 = new Static1D(-90);
1184
    Static1D angle4 = new Static1D(-135);
1185
    Static3D axisX  = new Static3D(1,0,0);
1186
    Static3D axisY  = new Static3D(0,1,0);
1187
    Static3D axisZ  = new Static3D(0,0,1);
1188
    Static3D axis1  = new Static3D(1,-1,0);
1189
    Static3D center = new Static3D(0,0,0);
1190
    Static3D center1= new Static3D(-E/2,-E/2,0);
1191

    
1192
    VertexEffect[] effect = new VertexEffect[10];
1193

    
1194
    effect[0] = new VertexEffectMove(move0);
1195
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1196
    effect[2] = new VertexEffectMove(move1);
1197
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1198
    effect[4] = new VertexEffectMove(move2);
1199
    effect[5] = new VertexEffectMove(move3);
1200
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1201
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1202
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1203
    effect[9] = new VertexEffectMove(move4);
1204

    
1205
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1206
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1207
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1208
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1209
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1210
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1211
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1212
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1213
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1214
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1215

    
1216
    return effect;
1217
    }
1218

    
1219
///////////////////////////////////////////////////////////////////////////////////////////////////
1220

    
1221
  VertexEffect[] createVertexEffectsRediEdge()
1222
    {
1223
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1224
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1225
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1226
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1227
    Static3D flipZ = new Static3D(1,1,-1);
1228
    Static3D flipX = new Static3D(-1,1,1);
1229
    Static3D scale = new Static3D(2,2,2);
1230
    Static3D cent0 = new Static3D(0,0, 0);
1231
    Static3D cent1 = new Static3D(0,0, -1.5f);
1232
    Static3D axisX = new Static3D(1,0, 0);
1233
    Static3D axisY = new Static3D(0,1, 0);
1234
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1235
    Static1D angle1= new Static1D(90);
1236
    Static1D angle2= new Static1D(45);
1237
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1238

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

    
1241
    effect[0] = new VertexEffectScale(scale);
1242
    effect[1] = new VertexEffectMove(move0);
1243
    effect[2] = new VertexEffectScale(flipZ);
1244
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1245
    effect[4] = new VertexEffectMove(move1);
1246
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1247
    effect[6] = new VertexEffectMove(move2);
1248
    effect[7] = new VertexEffectScale(flipX);
1249
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1250
    effect[9] = new VertexEffectMove(move3);
1251
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1252
    effect[11]= new VertexEffectScale(flipX);
1253

    
1254
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1255
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1256
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1257
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1258
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1259
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1260
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1261
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1262
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1263
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1264
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1265
    effect[11].setMeshAssociation(32,-1); // mesh 5
1266

    
1267
    return effect;
1268
    }
1269

    
1270
///////////////////////////////////////////////////////////////////////////////////////////////////
1271

    
1272
  VertexEffect[] createVertexEffectsRediCorner()
1273
    {
1274
    Static3D axisY   = new Static3D(0,1,0);
1275
    Static3D axisX   = new Static3D(1,0,0);
1276
    Static3D axisZ   = new Static3D(0,0,1);
1277
    Static3D center  = new Static3D(0,0,0);
1278
    Static1D angle90 = new Static1D(90);
1279
    Static1D angle270= new Static1D(270);
1280
    Static1D angle45 = new Static1D(-45);
1281
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1282

    
1283
    VertexEffect[] effect = new VertexEffect[7];
1284

    
1285
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1286
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1287
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1288
    effect[3] = new VertexEffectScale(scale);
1289
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1290
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1291
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1292

    
1293
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1294
    effect[1].setMeshAssociation( 2,-1);  // 1
1295
    effect[2].setMeshAssociation( 4,-1);  // 2
1296
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1297
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1298
    effect[5].setMeshAssociation(16,-1);  // 4
1299
    effect[6].setMeshAssociation(32,-1);  // 5
1300

    
1301
    return effect;
1302
    }
1303

    
1304
///////////////////////////////////////////////////////////////////////////////////////////////////
1305

    
1306
  VertexEffect[] createVertexEffectsIvyCorner()
1307
    {
1308
    Static3D axisX  = new Static3D(1,0,0);
1309
    Static3D axisY  = new Static3D(0,1,0);
1310
    Static1D angle1 = new Static1D(+90);
1311
    Static1D angle2 = new Static1D(-90);
1312
    Static3D center = new Static3D(0,0,0);
1313
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1314

    
1315
    VertexEffect[] effect = new VertexEffect[5];
1316

    
1317
    effect[0] = new VertexEffectScale(1/IVY_C);
1318
    effect[1] = new VertexEffectMove(move1);
1319
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1320
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1321
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1322

    
1323
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1324
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1325
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1326

    
1327
    return effect;
1328
    }
1329

    
1330
///////////////////////////////////////////////////////////////////////////////////////////////////
1331

    
1332
  VertexEffect[] createVertexEffectsRexEdge()
1333
    {
1334
    float E = 0.5f - REX_D;
1335
    float F = 0.5f;
1336
    float G = (float)Math.sqrt(E*E+F*F);
1337
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1338

    
1339
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1340
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1341

    
1342
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1343
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1344
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1345
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1346
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1347
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1348

    
1349
    Static1D angle180 = new Static1D(180);
1350
    Static1D angle90  = new Static1D( 90);
1351
    Static1D angle270 = new Static1D(270);
1352
    Static1D angle1   = new Static1D(+A);
1353
    Static1D angle2   = new Static1D(-A);
1354

    
1355
    VertexEffect[] effect = new VertexEffect[12];
1356

    
1357
    effect[0] = new VertexEffectMove(move1);
1358
    effect[1] = new VertexEffectMove(move2);
1359
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1360
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1361
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1362
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1363
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1364
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1365
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1366
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1367
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1368
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1369

    
1370
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1371
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1372
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1373
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1374
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1375
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1376
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1377
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1378
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1379
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1380
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1381
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1382

    
1383
    return effect;
1384
    }
1385

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

    
1388
  VertexEffect[] createVertexEffectsRexCorner()
1389
    {
1390
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1391
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1392
    Static1D angle = new Static1D(225);
1393

    
1394
    VertexEffect[] effect = new VertexEffect[1];
1395
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1396

    
1397
    return effect;
1398
    }
1399

    
1400
///////////////////////////////////////////////////////////////////////////////////////////////////
1401

    
1402
  VertexEffect[] createVertexEffectsKilominxCenter(float width)
1403
    {
1404
    VertexEffect[] effect = new VertexEffect[11];
1405

    
1406
    float H = 0.5f*(SIN54/COS54);
1407
    float Y1= 0.5f*SIN_HALFD;
1408
    float Y2= H/(2*COS_HALFD);
1409
    float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18));
1410
    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
1411

    
1412
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1413
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1414
    Static3D axisA = new Static3D(-SIN18, cos18, 0.0f);
1415
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H* SIN_HALFD /(COS_HALFD*LEN));
1416

    
1417
    Static3D move1 = new Static3D(0,-Y1,0);
1418
    Static3D move2 = new Static3D(0,-Y2,0);
1419
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*SIN18,0);
1420
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1421

    
1422
    Static1D angle1 = new Static1D(54);
1423
    Static1D angle2 = new Static1D(DIHEDRAL1/2+18);
1424
    Static1D angle3 = new Static1D(90);
1425
    Static1D angle4 = new Static1D(120);
1426
    Static1D angle5 = new Static1D(240);
1427
    Static1D angle6 = new Static1D(90-DIHEDRAL1/2);
1428

    
1429
    effect[0] = new VertexEffectMove(move1);
1430
    effect[1] = new VertexEffectScale(1/MINX_SC);
1431
    effect[2] = new VertexEffectMove(move2);
1432
    effect[3] = new VertexEffectRotate(angle1, axisZ, center);
1433
    effect[4] = new VertexEffectRotate(angle2, axisZ, center);
1434
    effect[5] = new VertexEffectRotate(angle3, axisA, center);
1435
    effect[6] = new VertexEffectMove(move3);
1436
    effect[7] = new VertexEffectRotate(angle4, axisC, center);
1437
    effect[8] = new VertexEffectRotate(angle5, axisC, center);
1438
    effect[9] = new VertexEffectRotate(angle6, axisY, center);
1439
    effect[10]= new VertexEffectScale(width/0.5f);
1440

    
1441
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1442
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1443
    effect[2].setMeshAssociation(56,-1);  // meshes 3,4,5
1444
    effect[3].setMeshAssociation( 7,-1);  // meshes 0,1,2
1445
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1446
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1447
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1448
    effect[7].setMeshAssociation(18,-1);  // meshes 1,4
1449
    effect[8].setMeshAssociation(36,-1);  // meshes 2,5
1450

    
1451
    return effect;
1452
    }
1453

    
1454
///////////////////////////////////////////////////////////////////////////////////////////////////
1455

    
1456
  VertexEffect[] createVertexEffectsMinxCorner(float width)
1457
    {
1458
    VertexEffect[] effect = new VertexEffect[9];
1459

    
1460
    float Y = COS54/(2*SIN54);
1461

    
1462
    float sinA = (2*SIN54*SIN54-1)/COS54;
1463
    float cosA = (float)Math.sqrt(1-sinA*sinA);
1464
    float LEN  = 0.5f/SIN54;
1465
    float scale= width/LEN;
1466

    
1467
    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
1468
    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
1469
    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
1470

    
1471
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1472
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1473

    
1474
    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
1475
    Static3D move2= new Static3D(0.0f, Y , 0.0f );
1476

    
1477
    Static1D angleD = new Static1D(DIHEDRAL1);
1478
    Static1D angleE = new Static1D(360-DIHEDRAL1);
1479
    Static1D angleF = new Static1D(DIHEDRAL2);
1480

    
1481
    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
1482
    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
1483
    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
1484
    effect[3] = new VertexEffectMove(move1);
1485
    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
1486
    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
1487
    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
1488
    effect[7] = new VertexEffectMove(move2);
1489
    effect[8] = new VertexEffectScale(scale);
1490

    
1491
    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
1492
    effect[1].setMeshAssociation( 16,-1);  // mesh 4
1493
    effect[2].setMeshAssociation( 32,-1);  // mesh 5
1494
    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
1495
    effect[4].setMeshAssociation(  1,-1);  // mesh 0
1496
    effect[5].setMeshAssociation(  2,-1);  // mesh 1
1497

    
1498
    return effect;
1499
    }
1500

    
1501
///////////////////////////////////////////////////////////////////////////////////////////////////
1502

    
1503
  VertexEffect[] createVertexEffectsKilominxEdge(float width, float height, boolean left)
1504
    {
1505
    VertexEffect[] effect = new VertexEffect[11 + (left ? 0:1)];
1506

    
1507
    float D = height/COS18;
1508
    float W = D*SIN18;
1509
    float X1 = height/2;
1510
    float Y1 = width/2;
1511
    float Y2 = (width+W)/2;
1512
    float Y3 = D*COS54;
1513
    float Y4 = height*COS_HALFD;
1514
    float Z = 2*height*COS_HALFD;
1515
    float alpha = 90-DIHEDRAL1/2;
1516

    
1517
    Static1D angle1 = new Static1D(alpha);
1518
    Static1D angle2 = new Static1D(180-alpha);
1519
    Static1D angle3 = new Static1D(DIHEDRAL2);
1520
    Static1D angle4 = new Static1D(90);
1521

    
1522
    Static3D move1 = new Static3D(+X1,-Y1,0);
1523
    Static3D move2 = new Static3D(-X1,-Y2+W,-Z);
1524
    Static3D move3 = new Static3D(0,+Y3,0);
1525
    Static3D move4 = new Static3D(0,-Y4-width,0);
1526
    Static3D scale = new Static3D(+1,+1,-1);
1527

    
1528
    Static3D axisXplus = new Static3D(+1, 0, 0);
1529
    Static3D axisYplus = new Static3D( 0,+1, 0);
1530

    
1531
    Static3D center1= new Static3D( 0, 0, 0);
1532
    Static3D center2= new Static3D( 0, 0,-Z);
1533
    Static3D center3= new Static3D( 0,-width, 0);
1534

    
1535
    effect[ 0] = new VertexEffectMove(move1);
1536
    effect[ 1] = new VertexEffectMove(move2);
1537
    effect[ 2] = new VertexEffectMove(move3);
1538
    effect[ 3] = new VertexEffectMove(move4);
1539
    effect[ 4] = new VertexEffectScale(scale);
1540
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1541
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1542
    effect[ 7] = new VertexEffectRotate(angle1, axisYplus , center2);
1543
    effect[ 8] = new VertexEffectRotate(angle2, axisYplus , center2);
1544
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center1);
1545
    effect[10] = new VertexEffectRotate(angle4, axisXplus , center3);
1546

    
1547
    if( !left )
1548
      {
1549
      Static3D scale1 = new Static3D(+1,-1,+1);
1550
      effect[11] = new VertexEffectScale(scale1);
1551
      }
1552

    
1553
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1554
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1555
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1556
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1557
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1558
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1559
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1560
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1561
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1562
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1563
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1564

    
1565
    return effect;
1566
    }
1567

    
1568
///////////////////////////////////////////////////////////////////////////////////////////////////
1569

    
1570
  VertexEffect[] createVertexEffectsMegaminxEdge(float width, float height)
1571
    {
1572
    VertexEffect[] effect = new VertexEffect[11];
1573

    
1574
    float X = 0.5f*height;
1575
    float Y = height*(COS54/COS18) + width*0.5f;
1576
    float Z = 2*height*COS_HALFD;
1577

    
1578
    float alpha = 90-DIHEDRAL1/2;
1579
    float beta  = DIHEDRAL2;
1580

    
1581
    Static1D angle1 = new Static1D(alpha);
1582
    Static1D angle2 = new Static1D(180-alpha);
1583
    Static1D angle3 = new Static1D(beta);
1584

    
1585
    Static3D move1 = new Static3D(X,0,0);
1586
    Static3D move2 = new Static3D(X,0,-Z);
1587
    Static3D move3 = new Static3D(0,+Y,0);
1588
    Static3D move4 = new Static3D(0,-Y,0);
1589
    Static3D scale = new Static3D(+1,+1,-1);
1590

    
1591
    Static3D axisXplus = new Static3D(+1, 0, 0);
1592
    Static3D axisXminus= new Static3D(-1, 0, 0);
1593
    Static3D axisYplus = new Static3D( 0,+1, 0);
1594
    Static3D axisYminus= new Static3D( 0,-1, 0);
1595

    
1596
    Static3D center1= new Static3D( 0, 0, 0);
1597
    Static3D center2= new Static3D( 0, 0,-Z);
1598
    Static3D center3= new Static3D( 0,+width*0.5f, 0);
1599
    Static3D center4= new Static3D( 0,-width*0.5f, 0);
1600

    
1601
    effect[ 0] = new VertexEffectMove(move1);
1602
    effect[ 1] = new VertexEffectMove(move2);
1603
    effect[ 2] = new VertexEffectMove(move3);
1604
    effect[ 3] = new VertexEffectMove(move4);
1605
    effect[ 4] = new VertexEffectScale(scale);
1606
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1607
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1608
    effect[ 7] = new VertexEffectRotate(angle1, axisYminus, center2);
1609
    effect[ 8] = new VertexEffectRotate(angle2, axisYminus, center2);
1610
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center3);
1611
    effect[10] = new VertexEffectRotate(angle3, axisXminus, center4);
1612

    
1613
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1614
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1615
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1616
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1617
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1618
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1619
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1620
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1621
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1622
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1623
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1624

    
1625
    return effect;
1626
    }
1627

    
1628
///////////////////////////////////////////////////////////////////////////////////////////////////
1629

    
1630
  VertexEffect[] createVertexEffectsMegaminxCenter(float width)
1631
    {
1632
    VertexEffect[] effect = new VertexEffect[2];
1633

    
1634
    Static1D angle = new Static1D(DIHEDRAL2);
1635
    Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
1636
    Static3D center= new Static3D( 0, 0, 0);
1637

    
1638
    effect[0] = new VertexEffectScale(width/COS54);
1639
    effect[1] = new VertexEffectRotate(angle, axisX, center);
1640

    
1641
    return effect;
1642
    }
1643

    
1644
///////////////////////////////////////////////////////////////////////////////////////////////////
1645

    
1646
  VertexEffect[] createCuboidEffects(int[] dimensions)
1647
    {
1648
    float X = dimensions[0];
1649
    float Y = dimensions[1];
1650
    float Z = dimensions[2];
1651

    
1652
    float MAX_XY = Math.max(X,Y);
1653
    float MAX_XZ = Math.max(X,Z);
1654
    float MAX_YZ = Math.max(Z,Y);
1655

    
1656
    Static1D angle = new Static1D(90);
1657
    Static3D move  = new Static3D( 0.0f, 0.0f, 0.5f);
1658
    Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
1659
    Static3D axisY = new Static3D( 0.0f, 1.0f, 0.0f);
1660
    Static3D center= new Static3D( 0.0f, 0.0f, 0.0f);
1661

    
1662
    Static3D scale3 = new Static3D(MAX_XY,MAX_XY,+Z);
1663
    Static3D scale4 = new Static3D(MAX_XY,MAX_XY,-Z);
1664
    Static3D scale5 = new Static3D(MAX_XZ,+Y,MAX_XZ);
1665
    Static3D scale6 = new Static3D(MAX_XZ,-Y,MAX_XZ);
1666
    Static3D scale7 = new Static3D(+X,MAX_YZ,MAX_YZ);
1667
    Static3D scale8 = new Static3D(-X,MAX_YZ,MAX_YZ);
1668

    
1669
    VertexEffect[] effect = new VertexEffect[9];
1670

    
1671
    effect[0] = new VertexEffectMove(move);
1672
    effect[1] = new VertexEffectRotate(angle, axisX, center);
1673
    effect[2] = new VertexEffectRotate(angle, axisY, center);
1674
    effect[3] = new VertexEffectScale(scale3);
1675
    effect[4] = new VertexEffectScale(scale4);
1676
    effect[5] = new VertexEffectScale(scale5);
1677
    effect[6] = new VertexEffectScale(scale6);
1678
    effect[7] = new VertexEffectScale(scale7);
1679
    effect[8] = new VertexEffectScale(scale8);
1680

    
1681
    effect[1].setMeshAssociation(12,-1);  // meshes 2,3
1682
    effect[2].setMeshAssociation( 3,-1);  // meshes 0,1
1683
    effect[3].setMeshAssociation(16,-1);  // mesh 4
1684
    effect[4].setMeshAssociation(32,-1);  // mesh 5
1685
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1686
    effect[6].setMeshAssociation( 4,-1);  // mesh 2
1687
    effect[7].setMeshAssociation( 1,-1);  // mesh 0
1688
    effect[8].setMeshAssociation( 2,-1);  // mesh 1
1689

    
1690
    return effect;
1691
    }
1692

    
1693
///////////////////////////////////////////////////////////////////////////////////////////////////
1694
// OBJECTS
1695
///////////////////////////////////////////////////////////////////////////////////////////////////
1696
// CUBE
1697

    
1698
  MeshBase createCubeMesh(int index)
1699
    {
1700
    MeshBase mesh = createFacesCube(index);
1701
    VertexEffect[] effects = createVertexEffectsCube();
1702
    for( VertexEffect effect : effects ) mesh.apply(effect);
1703

    
1704
    Static3D roundingCenter  = new Static3D(0,0,0);
1705
    Static3D[] vertices = new Static3D[8];
1706
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1707
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1708
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1709
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1710
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1711
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1712
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1713
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1714

    
1715
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1716

    
1717
    mesh.mergeEffComponents();
1718

    
1719
    return mesh;
1720
    }
1721

    
1722
///////////////////////////////////////////////////////////////////////////////////////////////////
1723
// SKEWB
1724

    
1725
  MeshBase createSkewbCornerMesh()
1726
    {
1727
    MeshBase mesh = createFacesSkewbCorner();
1728
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1729
    for( VertexEffect effect : effects ) mesh.apply(effect);
1730

    
1731
    float E = 0.5f;
1732
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1733

    
1734
    Static3D[] verticesType1 = new Static3D[1];
1735
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1736
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1737

    
1738
    Static3D[] verticesType2 = new Static3D[3];
1739
    verticesType2[0] = new Static3D(-E, 0, 0);
1740
    verticesType2[1] = new Static3D( 0,-E, 0);
1741
    verticesType2[2] = new Static3D( 0, 0,-E);
1742
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1743

    
1744
    mesh.mergeEffComponents();
1745

    
1746
    return mesh;
1747
    }
1748

    
1749
///////////////////////////////////////////////////////////////////////////////////////////////////
1750

    
1751
  MeshBase createSkewbFaceMesh()
1752
    {
1753
    MeshBase mesh = createFacesSkewbFace();
1754
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1755
    for( VertexEffect effect : effects ) mesh.apply(effect);
1756

    
1757
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1758
    float E = SQ2/4;
1759
    Static3D[] vertices = new Static3D[4];
1760
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1761
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1762
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1763
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1764
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1765

    
1766
    mesh.mergeEffComponents();
1767
    mesh.addEmptyTexComponent();
1768

    
1769
    return mesh;
1770
    }
1771

    
1772
///////////////////////////////////////////////////////////////////////////////////////////////////
1773
// SKEWB DIAMOND / PYRAMINX
1774

    
1775
  MeshBase createOctaMesh()
1776
    {
1777
    MeshBase mesh = createFacesOcta();
1778
    VertexEffect[] effects = createVertexEffectsOcta();
1779
    for( VertexEffect effect : effects ) mesh.apply(effect);
1780

    
1781
    Static3D roundingCenter = new Static3D(0,0,0);
1782
    Static3D[] vertices = new Static3D[6];
1783
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1784
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1785
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1786
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1787
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1788
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1789

    
1790
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1791

    
1792
    mesh.mergeEffComponents();
1793

    
1794
    return mesh;
1795
    }
1796

    
1797
///////////////////////////////////////////////////////////////////////////////////////////////////
1798

    
1799
  MeshBase createTetraMesh()
1800
    {
1801
    MeshBase mesh = createFacesTetra();
1802
    VertexEffect[] effects = createVertexEffectsTetra();
1803
    for( VertexEffect effect : effects ) mesh.apply(effect);
1804

    
1805
    Static3D roundingCenter = new Static3D(0,0,0);
1806
    Static3D[] verticesRound = new Static3D[4];
1807
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1808
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1809
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1810
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1811
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1812

    
1813
    mesh.mergeEffComponents();
1814
    mesh.addEmptyTexComponent();
1815
    mesh.addEmptyTexComponent();
1816
    mesh.addEmptyTexComponent();
1817
    mesh.addEmptyTexComponent();
1818

    
1819
    return mesh;
1820
    }
1821

    
1822
///////////////////////////////////////////////////////////////////////////////////////////////////
1823
// DINO
1824

    
1825
  MeshBase createDinoMesh()
1826
    {
1827
    MeshBase mesh = createFacesDino();
1828
    VertexEffect[] effects = createVertexEffectsDino();
1829
    for( VertexEffect effect : effects ) mesh.apply(effect);
1830

    
1831
    float F = 0.5f;
1832
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1833
    Static3D[] verticesRound = new Static3D[4];
1834
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1835
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1836
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1837
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1838
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1839

    
1840
    mesh.mergeEffComponents();
1841

    
1842
    return mesh;
1843
    }
1844

    
1845
///////////////////////////////////////////////////////////////////////////////////////////////////
1846
// Helicopter
1847

    
1848
  MeshBase createHelicopterCornerMesh()
1849
    {
1850
    MeshBase mesh = createFacesHelicopterCorner();
1851
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1852
    for( VertexEffect effect : effects ) mesh.apply(effect);
1853

    
1854
    float E = 0.5f;
1855
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1856

    
1857
    Static3D[] verticesType1 = new Static3D[1];
1858
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1859
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1860

    
1861
    Static3D[] verticesType2 = new Static3D[3];
1862
    verticesType2[0] = new Static3D(-E, 0, 0);
1863
    verticesType2[1] = new Static3D( 0,-E, 0);
1864
    verticesType2[2] = new Static3D( 0, 0,-E);
1865
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1866

    
1867
    mesh.mergeEffComponents();
1868

    
1869
    return mesh;
1870
    }
1871

    
1872
///////////////////////////////////////////////////////////////////////////////////////////////////
1873

    
1874
  MeshBase createHelicopterFaceMesh()
1875
    {
1876
    MeshBase mesh = createFacesHelicopterFace();
1877
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1878
    for( VertexEffect effect : effects ) mesh.apply(effect);
1879

    
1880
    float E = 0.5f;
1881
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1882

    
1883
    Static3D[] verticesType1 = new Static3D[1];
1884
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1885
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1886

    
1887
    Static3D[] verticesType2 = new Static3D[2];
1888
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1889
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1890
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1891

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

    
1896
    return mesh;
1897
    }
1898

    
1899
///////////////////////////////////////////////////////////////////////////////////////////////////
1900
// Redi cube
1901

    
1902
  MeshBase createRediEdgeMesh()
1903
    {
1904
    MeshBase mesh = createFacesRediEdge();
1905
    VertexEffect[] effects = createVertexEffectsRediEdge();
1906
    for( VertexEffect effect : effects ) mesh.apply(effect);
1907

    
1908
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1909
    Static3D[] vertices = new Static3D[2];
1910
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1911
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1912
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1913

    
1914
    mesh.mergeEffComponents();
1915

    
1916
    return mesh;
1917
    }
1918

    
1919
///////////////////////////////////////////////////////////////////////////////////////////////////
1920

    
1921
  MeshBase createRediCornerMesh()
1922
    {
1923
    MeshBase mesh = createFacesRediCorner();
1924
    VertexEffect[] effects = createVertexEffectsRediCorner();
1925
    for( VertexEffect effect : effects ) mesh.apply(effect);
1926

    
1927
    Static3D center = new Static3D(0,0,0);
1928
    Static3D[] vertices = new Static3D[8];
1929
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1930
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1931
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1932
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1933
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1934
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1935
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1936
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1937

    
1938
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1939

    
1940
    mesh.mergeEffComponents();
1941

    
1942
    return mesh;
1943
    }
1944

    
1945
///////////////////////////////////////////////////////////////////////////////////////////////////
1946

    
1947
  MeshBase createIvyCornerMesh()
1948
    {
1949
    MeshBase mesh = createFacesIvyCorner();
1950
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1951
    for( VertexEffect effect : effects ) mesh.apply(effect);
1952

    
1953
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1954
    Static3D[] vertices = new Static3D[4];
1955
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1956
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1957
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1958
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1959

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

    
1962
    mesh.mergeEffComponents();
1963

    
1964
    return mesh;
1965
    }
1966

    
1967
///////////////////////////////////////////////////////////////////////////////////////////////////
1968

    
1969
  MeshBase createIvyFaceMesh()
1970
    {
1971
    MeshBase mesh = createFacesIvyFace();
1972

    
1973
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1974
    Static3D[] vertices = new Static3D[2];
1975
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1976
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1977

    
1978
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1979

    
1980
    mesh.mergeEffComponents();
1981
    mesh.addEmptyTexComponent();
1982
    mesh.addEmptyTexComponent();
1983
    mesh.addEmptyTexComponent();
1984
    mesh.addEmptyTexComponent();
1985

    
1986
    return mesh;
1987
    }
1988

    
1989
///////////////////////////////////////////////////////////////////////////////////////////////////
1990

    
1991
  MeshBase createRexCornerMesh()
1992
    {
1993
    MeshBase mesh = createFacesRexCorner();
1994
    VertexEffect[] effects = createVertexEffectsRexCorner();
1995
    for( VertexEffect effect : effects ) mesh.apply(effect);
1996

    
1997
    final float G = (1-REX_D)/3;
1998
    Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
1999
    Static3D[] vertices = new Static3D[1];
2000
    vertices[0] = new Static3D(+G,-G,+0.0f);
2001
    roundCorners(mesh,center,vertices,0.10f,0.10f);
2002

    
2003
    mesh.mergeEffComponents();
2004
    mesh.addEmptyTexComponent();
2005
    mesh.addEmptyTexComponent();
2006
    mesh.addEmptyTexComponent();
2007
    mesh.addEmptyTexComponent();
2008

    
2009
    return mesh;
2010
    }
2011

    
2012
///////////////////////////////////////////////////////////////////////////////////////////////////
2013

    
2014
  MeshBase createRexFaceMesh()
2015
    {
2016
    MeshBase mesh = createFacesRexFace();
2017

    
2018
    mesh.mergeEffComponents();
2019
    mesh.addEmptyTexComponent();
2020
    mesh.addEmptyTexComponent();
2021
    mesh.addEmptyTexComponent();
2022
    mesh.addEmptyTexComponent();
2023

    
2024
    return mesh;
2025
    }
2026

    
2027
///////////////////////////////////////////////////////////////////////////////////////////////////
2028

    
2029
  MeshBase createRexEdgeMesh()
2030
    {
2031
    MeshBase mesh = createFacesRexEdge();
2032
    VertexEffect[] effects = createVertexEffectsRexEdge();
2033
    for( VertexEffect effect : effects ) mesh.apply(effect);
2034

    
2035
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
2036
    Static3D[] vertices = new Static3D[2];
2037
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
2038
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
2039
    roundCorners(mesh,center,vertices,0.06f,0.10f);
2040

    
2041
    mesh.mergeEffComponents();
2042

    
2043
    return mesh;
2044
    }
2045

    
2046
///////////////////////////////////////////////////////////////////////////////////////////////////
2047

    
2048
  MeshBase createKilominxCenterMesh(float width)
2049
    {
2050
    MeshBase mesh = createFacesKilominxCenter();
2051
    VertexEffect[] effects = createVertexEffectsKilominxCenter(width);
2052
    for( VertexEffect effect : effects ) mesh.apply(effect);
2053

    
2054
    float A = (2*SQ3/3)* SIN54;
2055
    float B = 0.4f;
2056
    float X = SIN_HALFD * SIN54 *COS54  ;
2057
    float Y = SIN54 * SIN54 - 0.5f;
2058
    float Z = COS_HALFD* SIN54 *COS54  ;
2059

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

    
2062
    Static3D[] vertices = new Static3D[4];
2063
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
2064
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
2065
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
2066
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
2067

    
2068
    roundCorners(mesh,center,vertices,0.03f,0.10f);
2069

    
2070
    mesh.mergeEffComponents();
2071

    
2072
    return mesh;
2073
    }
2074

    
2075
///////////////////////////////////////////////////////////////////////////////////////////////////
2076
// numLayers==3 --> index=0; numLayers=5 --> index=1 ...
2077
// type: 0,1,... 0 --> edge, 1 --> 1 layer deeper, etc
2078

    
2079
  MeshBase createKilominxEdgeMesh(int numLayers, float width, float height, boolean left)
2080
    {
2081
    MeshBase mesh = createFacesKilominxEdge(numLayers,width,height);
2082
    VertexEffect[] effects = createVertexEffectsKilominxEdge(width,height,left);
2083
    for( VertexEffect effect : effects ) mesh.apply(effect);
2084

    
2085
// round...
2086

    
2087
    mesh.mergeEffComponents();
2088

    
2089
    return mesh;
2090
    }
2091

    
2092
///////////////////////////////////////////////////////////////////////////////////////////////////
2093

    
2094
  MeshBase createMinxCornerMesh(int numLayers, float width)
2095
    {
2096
    MeshBase mesh = createFacesMinxCorner(numLayers);
2097
    VertexEffect[] effects = createVertexEffectsMinxCorner(width);
2098
    for( VertexEffect effect : effects ) mesh.apply(effect);
2099

    
2100
    float A = (2*SQ3/3)* SIN54;
2101
    float B = 0.4f;
2102
/*
2103
    float X = SIN_HALFD* SIN54 * COS54;
2104
    float Y = SIN54 * SIN54 - 0.5f;
2105
    float Z = COS_HALFD* SIN54 * COS54;
2106
    float S = 2*width;
2107
*/
2108
    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
2109
    Static3D[] vertices = new Static3D[1];
2110
    vertices[0] = new Static3D( 0.0f, 0.0f  , 0.0f);
2111
/*
2112
    vertices[1] = new Static3D( 0.0f,-0.5f*S, 0.0f);
2113
    vertices[2] = new Static3D(-X*S , Y*S   ,-Z*S );
2114
    vertices[3] = new Static3D(+X*S , Y*S   ,-Z*S );
2115
*/
2116
    roundCorners(mesh,center,vertices,0.04f,0.10f);
2117

    
2118
    mesh.mergeEffComponents();
2119

    
2120
    return mesh;
2121
    }
2122

    
2123
///////////////////////////////////////////////////////////////////////////////////////////////////
2124
// numLayers==3 --> index=0; numLayers=5 --> index=1 ...
2125
// type: 0,1,... 0 --> edge, 1 --> 1 layer deeper, etc
2126

    
2127
  MeshBase createMegaminxEdgeMesh(int numLayers, float width, float height)
2128
    {
2129
    MeshBase mesh = createFacesMegaminxEdge(numLayers,width,height);
2130
    VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
2131
    for( VertexEffect effect : effects ) mesh.apply(effect);
2132

    
2133
    mesh.mergeEffComponents();
2134

    
2135
    return mesh;
2136
    }
2137

    
2138
///////////////////////////////////////////////////////////////////////////////////////////////////
2139

    
2140
  MeshBase createMegaminxCenterMesh(int numLayers, float width)
2141
    {
2142
    MeshBase mesh = createFacesMegaminxCenter(numLayers);
2143
    VertexEffect[] effects = createVertexEffectsMegaminxCenter(width);
2144
    for( VertexEffect effect : effects ) mesh.apply(effect);
2145

    
2146
    mesh.mergeEffComponents();
2147
    mesh.addEmptyTexComponent();
2148
    mesh.addEmptyTexComponent();
2149
    mesh.addEmptyTexComponent();
2150
    mesh.addEmptyTexComponent();
2151

    
2152
    return mesh;
2153
    }
2154

    
2155
///////////////////////////////////////////////////////////////////////////////////////////////////
2156

    
2157
  MeshBase createCuboidMesh(int[] dimensions)
2158
    {
2159
    MeshBase mesh = createCuboid(dimensions);
2160
    VertexEffect[] effects = createCuboidEffects(dimensions);
2161
    for( VertexEffect effect : effects ) mesh.apply(effect);
2162

    
2163
    int X = dimensions[0];
2164
    int Y = dimensions[1];
2165
    int Z = dimensions[2];
2166

    
2167
    float strength = 0.04f;
2168
    float radius   = 0.15f;
2169

    
2170
    Static3D[] vertices = new Static3D[1];
2171
    Static3D center;
2172

    
2173
    vertices[0] = new Static3D(+0.5f*X,+0.5f*Y,+0.5f*Z);
2174
    center = new Static3D(+0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1));
2175
    roundCorners(mesh, center, vertices, strength, radius);
2176

    
2177
    vertices[0] = new Static3D(+0.5f*X,+0.5f*Y,-0.5f*Z);
2178
    center = new Static3D(+0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1));
2179
    roundCorners(mesh, center, vertices, strength, radius);
2180

    
2181
    vertices[0] = new Static3D(+0.5f*X,-0.5f*Y,+0.5f*Z);
2182
    center = new Static3D(+0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1));
2183
    roundCorners(mesh, center, vertices, strength, radius);
2184

    
2185
    vertices[0] = new Static3D(+0.5f*X,-0.5f*Y,-0.5f*Z);
2186
    center = new Static3D(+0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1));
2187
    roundCorners(mesh, center, vertices, strength, radius);
2188

    
2189
    vertices[0] = new Static3D(-0.5f*X,+0.5f*Y,+0.5f*Z);
2190
    center = new Static3D(-0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1));
2191
    roundCorners(mesh, center, vertices, strength, radius);
2192

    
2193
    vertices[0] = new Static3D(-0.5f*X,+0.5f*Y,-0.5f*Z);
2194
    center = new Static3D(-0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1));
2195
    roundCorners(mesh, center, vertices, strength, radius);
2196

    
2197
    vertices[0] = new Static3D(-0.5f*X,-0.5f*Y,+0.5f*Z);
2198
    center = new Static3D(-0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1));
2199
    roundCorners(mesh, center, vertices, strength, radius);
2200

    
2201
    vertices[0] = new Static3D(-0.5f*X,-0.5f*Y,-0.5f*Z);
2202
    center = new Static3D(-0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1));
2203
    roundCorners(mesh, center, vertices, strength, radius);
2204

    
2205
    mesh.mergeEffComponents();
2206

    
2207
    return mesh;
2208
    }
2209
  }
(2-2/35)