Project

General

Profile

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

examples / src / main / java / org / distorted / examples / meshfile / FactoryCubit.java @ 54e47d9b

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

    
20
package org.distorted.examples.meshfile;
21

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

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

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

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

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

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

    
61
  private static final Static1D RADIUS = new Static1D(1);
62

    
63
  private static FactoryCubit mThis;
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

    
67
  private FactoryCubit()
68
    {
69

    
70
    }
71

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

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

    
78
    return mThis;
79
    }
80

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

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

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

    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

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

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

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

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

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

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

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

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

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

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

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

    
186
    return bands;
187
    }
188

    
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

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

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

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

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

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

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

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

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

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

    
230
///////////////////////////////////////////////////////////////////////////////////////////////////
231

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

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

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

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

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

    
263
    return new MeshJoined(meshes);
264
    }
265

    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267

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

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

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

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

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

    
295
    return new MeshJoined(meshes);
296
    }
297

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

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

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

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

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

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

    
323
    return new MeshJoined(meshes);
324
    }
325

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

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

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

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

    
354
    return new MeshJoined(meshes);
355
    }
356

    
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358

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

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

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

    
377
    return new MeshJoined(meshes);
378
    }
379

    
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381

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

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

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

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

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

    
404
    return new MeshJoined(meshes);
405
    }
406

    
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408

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

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

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

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

    
435
    return new MeshJoined(meshes);
436
    }
437

    
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439

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

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

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

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

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

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

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

    
466
    return new MeshJoined(meshes);
467
    }
468

    
469
///////////////////////////////////////////////////////////////////////////////////////////////////
470

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

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

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

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

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

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

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

    
501
    return new MeshJoined(meshes);
502
    }
503

    
504
///////////////////////////////////////////////////////////////////////////////////////////////////
505

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

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

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

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

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

    
534
    return new MeshJoined(meshes);
535
    }
536

    
537
///////////////////////////////////////////////////////////////////////////////////////////////////
538

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

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

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

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

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

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

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

    
581
    return new MeshJoined(meshes);
582
    }
583

    
584
///////////////////////////////////////////////////////////////////////////////////////////////////
585

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

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

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

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

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

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

    
613
    return new MeshJoined(meshes);
614
    }
615

    
616
///////////////////////////////////////////////////////////////////////////////////////////////////
617

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

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

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

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

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

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

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

    
657
    return new MeshJoined(meshes);
658
    }
659

    
660
///////////////////////////////////////////////////////////////////////////////////////////////////
661

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

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

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

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

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

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

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

    
705
    return new MeshJoined(meshes);
706
    }
707

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

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

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

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

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

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

    
737
    return new MeshJoined(meshes);
738
    }
739

    
740
///////////////////////////////////////////////////////////////////////////////////////////////////
741

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

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

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

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

    
772
    return new MeshJoined(meshes);
773
    }
774

    
775
///////////////////////////////////////////////////////////////////////////////////////////////////
776

    
777
  MeshBase createFacesMinxCorner(int numLayers)
778
    {
779
    MeshBase[] meshes = new MeshPolygon[6];
780

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

    
783
    float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
784

    
785
    int numBands0 = numLayers==3 ? 5 : 3;
786
    int numBands1 = numLayers==3 ? 2 : 2;
787
    float h       = numLayers==3 ? 0.04f : 0.03f;
788
    int   e       = numLayers==3 ? 4 : 1;
789

    
790
    float[] bands0 = computeBands(h    ,34,0.3f,0.2f, numBands0);
791
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f, numBands1);
792

    
793
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
794
    meshes[0].setEffectAssociation(0, 1,0);
795
    meshes[1] = meshes[0].copy(true);
796
    meshes[1].setEffectAssociation(0, 2,0);
797
    meshes[2] = meshes[0].copy(true);
798
    meshes[2].setEffectAssociation(0, 4,0);
799
    meshes[3] = new MeshPolygon(vertices0, bands1, 1, e);
800
    meshes[3].setEffectAssociation(0, 8,0);
801
    meshes[4] = meshes[3].copy(true);
802
    meshes[4].setEffectAssociation(0,16,0);
803
    meshes[5] = meshes[3].copy(true);
804
    meshes[5].setEffectAssociation(0,32,0);
805

    
806
    return new MeshJoined(meshes);
807
    }
808

    
809
///////////////////////////////////////////////////////////////////////////////////////////////////
810

    
811
  MeshBase createFacesKilominxEdge(int numLayers, float width, float height)
812
    {
813
    MeshBase[] meshes = new MeshPolygon[6];
814

    
815
    float D = height/COS18;
816
    float W = D*SIN18;
817
    float X1 = height/2;
818
    float Y1 = width/2;
819
    float Y2 = (width+W)/2;
820
    float X3 = D*SIN54;
821
    float Y3 = D*COS54;
822
    float X4 = height*SIN_HALFD;
823
    float Y4 = height*COS_HALFD;
824

    
825
    float[] vertices0 = { -X1,-Y1, X1, -Y1, X1, Y1+W,-X1, Y1 };
826
    float[] vertices1 = { -X1,-Y2, X1, -Y2, X1, Y2+W,-X1, Y2 };
827
    float[] vertices2 = { -X3, 0.0f, 0.0f, -Y3, X3, 0.0f, 0.0f, Y3 };
828
    float[] vertices3 = { -X4, 0.0f, 0.0f, -Y4, X4, 0.0f, 0.0f, Y4 };
829

    
830
    int numBands0 = numLayers<=5 ? 5 : 3;
831
    int numBands1 = numLayers<=5 ? 3 : 2;
832
    float h       = numLayers<=5 ? 0.03f : 0.03f;
833

    
834
    float[] bands0 = computeBands(h    ,34,0.2f,0.2f,numBands0);
835
    float[] bands1 = computeBands(0.01f,34,0.3f,0.2f,numBands1);
836

    
837
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
838
    meshes[0].setEffectAssociation(0, 1,0);
839
    meshes[1] = meshes[0].copy(true);
840
    meshes[1].setEffectAssociation(0, 2,0);
841
    meshes[2] = new MeshPolygon(vertices1, bands1, 0, 0);
842
    meshes[2].setEffectAssociation(0, 4,0);
843
    meshes[3] = meshes[2].copy(true);
844
    meshes[3].setEffectAssociation(0, 8,0);
845
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 2);
846
    meshes[4].setEffectAssociation(0,16,0);
847
    meshes[5] = new MeshPolygon(vertices3, bands1, 1, 2);
848
    meshes[5].setEffectAssociation(0,32,0);
849

    
850
    return new MeshJoined(meshes);
851
    }
852

    
853
///////////////////////////////////////////////////////////////////////////////////////////////////
854

    
855
  MeshBase createFacesMegaminxEdge(float width, float height)
856
    {
857
    MeshBase[] meshes = new MeshPolygon[6];
858

    
859
    float D = height/COS18;
860
    float W = D*SIN18;
861

    
862
    float Y1 = 0.5f*width;
863
    float Y2 = 0.5f*width + W;
864
    float Y3 = 0.5f*width + 2*W;
865
    float X2 = D*SIN54;
866
    float X1 = 0.5f*height;
867
    float Y4 = D*COS54;
868

    
869
    float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
870
    float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 };
871
    float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 };
872

    
873
    float[] bands0 = computeBands(0.04f,34,  X1,0.2f,5);
874
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
875

    
876
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
877
    meshes[0].setEffectAssociation(0, 1,0);
878
    meshes[1] = meshes[0].copy(true);
879
    meshes[1].setEffectAssociation(0, 2,0);
880
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 4);
881
    meshes[2].setEffectAssociation(0, 4,0);
882
    meshes[3] = meshes[2].copy(true);
883
    meshes[3].setEffectAssociation(0, 8,0);
884
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 4);
885
    meshes[4].setEffectAssociation(0,16,0);
886
    meshes[5] = meshes[4].copy(true);
887
    meshes[5].setEffectAssociation(0,32,0);
888

    
889
    return new MeshJoined(meshes);
890
    }
891

    
892
///////////////////////////////////////////////////////////////////////////////////////////////////
893

    
894
  private float[] createVertices(int A, int B)
895
    {
896
    float E = 0.5f / Math.max(A,B);
897
    return new float[] { -A*E,-B*E, +A*E,-B*E, +A*E,+B*E, -A*E,+B*E };
898
    }
899

    
900
///////////////////////////////////////////////////////////////////////////////////////////////////
901

    
902
  MeshBase createCuboid(int[] dimensions)
903
    {
904
    int X = dimensions[0];
905
    int Y = dimensions[1];
906
    int Z = dimensions[2];
907

    
908
    float[] verticesXY = createVertices(X,Y);
909
    float[] verticesXZ = createVertices(X,Z);
910
    float[] verticesYZ = createVertices(Z,Y);
911

    
912
    float defHeight = 0.048f;
913

    
914
    float[] bandsX = computeBands( defHeight/X,65,0.25f,0.5f,5);
915
    float[] bandsY = computeBands( defHeight/Y,65,0.25f,0.5f,5);
916
    float[] bandsZ = computeBands( defHeight/Z,65,0.25f,0.5f,5);
917

    
918
    MeshBase[] meshes = new MeshPolygon[6];
919

    
920
    meshes[0] = new MeshPolygon(verticesYZ,bandsX,1,2);
921
    meshes[0].setEffectAssociation(0,1,0);
922
    meshes[1] = meshes[0].copy(true);
923
    meshes[1].setEffectAssociation(0,2,0);
924
    meshes[2] = new MeshPolygon(verticesXZ,bandsY,1,2);
925
    meshes[2].setEffectAssociation(0,4,0);
926
    meshes[3] = meshes[2].copy(true);
927
    meshes[3].setEffectAssociation(0,8,0);
928
    meshes[4] = new MeshPolygon(verticesXY,bandsZ,1,2);
929
    meshes[4].setEffectAssociation(0,16,0);
930
    meshes[5] = meshes[4].copy(true);
931
    meshes[5].setEffectAssociation(0,32,0);
932

    
933

    
934
    return new MeshJoined(meshes);
935
    }
936

    
937
///////////////////////////////////////////////////////////////////////////////////////////////////
938
// EFFECTS
939
///////////////////////////////////////////////////////////////////////////////////////////////////
940

    
941
  VertexEffect[] createVertexEffectsCube()
942
    {
943
    Static3D axisY   = new Static3D(0,1,0);
944
    Static3D axisX   = new Static3D(1,0,0);
945
    Static3D center  = new Static3D(0,0,0);
946
    Static1D angle90 = new Static1D(90);
947
    Static1D angle180= new Static1D(180);
948
    Static1D angle270= new Static1D(270);
949

    
950
    VertexEffect[] effect = new VertexEffect[6];
951

    
952
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
953
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
954
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
955
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
956
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
957
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
958

    
959
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
960
    effect[1].setMeshAssociation(32,-1);  // back
961
    effect[2].setMeshAssociation( 8,-1);  // bottom
962
    effect[3].setMeshAssociation( 4,-1);  // top
963
    effect[4].setMeshAssociation( 2,-1);  // left
964
    effect[5].setMeshAssociation( 1,-1);  // right
965

    
966
    return effect;
967
    }
968

    
969
///////////////////////////////////////////////////////////////////////////////////////////////////
970

    
971
  VertexEffect[] createVertexEffectsSkewbCorner()
972
    {
973
    float E = 0.5f;
974

    
975
    Static3D axisX  = new Static3D(1,0,0);
976
    Static3D axisY  = new Static3D(0,1,0);
977
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
978
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
979
    Static1D angle1 = new Static1D(+90);
980
    Static1D angle2 = new Static1D(-90);
981
    Static1D angle3 = new Static1D(-15);
982
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
983
    Static1D angle5 = new Static1D(120);
984
    Static1D angle6 = new Static1D(240);
985
    Static3D center1= new Static3D(0,0,0);
986
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
987
    Static3D move1  = new Static3D(-E/4,-E/4,0);
988
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
989

    
990
    VertexEffect[] effect = new VertexEffect[10];
991

    
992
    effect[0] = new VertexEffectMove(move1);
993
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
994
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
995
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
996
    effect[4] = new VertexEffectMove(move2);
997
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
998
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
999
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1000
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1001
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1002

    
1003
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1004
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1005
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1006
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1007
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1008
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1009
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1010
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1011
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1012
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1013

    
1014
    return effect;
1015
    }
1016

    
1017
///////////////////////////////////////////////////////////////////////////////////////////////////
1018

    
1019
  VertexEffect[] createVertexEffectsSkewbFace()
1020
    {
1021
    Static3D center = new Static3D(0,0,0);
1022
    Static3D axisX  = new Static3D(1,0,0);
1023
    Static3D axisZ  = new Static3D(0,0,1);
1024
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
1025

    
1026
    VertexEffect[] effect = new VertexEffect[6];
1027

    
1028
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
1029
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
1030
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
1031
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
1032
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
1033
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
1034

    
1035
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
1036
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1037
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
1038
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
1039
    effect[4].setMeshAssociation(16,-1);  // mesh 4
1040
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
1041

    
1042
    return effect;
1043
    }
1044

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

    
1047
  VertexEffect[] createVertexEffectsOcta()
1048
    {
1049
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
1050
    Static1D angle1= new Static1D( 90);
1051
    Static1D angle2= new Static1D(180);
1052
    Static1D angle3= new Static1D(270);
1053
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
1054
    Static3D axisX = new Static3D(1,0,0);
1055
    Static3D axisY = new Static3D(0,1,0);
1056
    Static3D cent0 = new Static3D(0,0,0);
1057
    Static3D cent1 = new Static3D(0,SQ2/2,0);
1058
    Static3D flipY = new Static3D( 1,-1, 1);
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 VertexEffectMove(move1);
1065
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
1066
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
1067
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
1068
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
1069
    effect[6] = new VertexEffectScale(flipY);
1070

    
1071
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
1072
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
1073
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
1074
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
1075

    
1076
    return effect;
1077
    }
1078

    
1079
///////////////////////////////////////////////////////////////////////////////////////////////////
1080

    
1081
  VertexEffect[] createVertexEffectsTetra()
1082
    {
1083
    Static3D flipZ = new Static3D( 1, 1,-1);
1084
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
1085
    Static1D angle1= new Static1D( 90);
1086
    Static1D angle2= new Static1D(180);
1087
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
1088
    Static3D axisX = new Static3D(1,0,0);
1089
    Static3D axisY = new Static3D(0,1,0);
1090
    Static3D axisZ = new Static3D(0,0,1);
1091
    Static3D cent0 = new Static3D(0,0,0);
1092
    Static3D cent1 = new Static3D(0,SQ2/4,0);
1093
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
1094

    
1095
    VertexEffect[] effect = new VertexEffect[7];
1096

    
1097
    effect[0] = new VertexEffectScale(scale);
1098
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
1099
    effect[2] = new VertexEffectMove(move1);
1100
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
1101
    effect[4] = new VertexEffectScale(flipZ);
1102
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
1103
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
1104

    
1105
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
1106
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
1107
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
1108

    
1109
    return effect;
1110
    }
1111

    
1112
///////////////////////////////////////////////////////////////////////////////////////////////////
1113

    
1114
  VertexEffect[] createVertexEffectsDino()
1115
    {
1116
    float E = 0.5f*SQ2;
1117
    float F = 0.5f;
1118
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
1119

    
1120
    Static1D angle1 = new Static1D(-ANGLE);
1121
    Static1D angle2 = new Static1D(+ANGLE);
1122
    Static3D axisX  = new Static3D(1,0,0);
1123
    Static3D axisY  = new Static3D(0,1,0);
1124
    Static3D axisZ  = new Static3D(0,-1,1);
1125
    Static3D center0= new Static3D(0,0,0);
1126
    Static3D center1= new Static3D(0,-3*F,0);
1127

    
1128
    VertexEffect[] effect = new VertexEffect[10];
1129

    
1130
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
1131
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
1132
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
1133
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
1134
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
1135
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
1136
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
1137
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
1138
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
1139
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
1140

    
1141
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
1142
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
1143
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
1144
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 0
1145
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
1146
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
1147
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1148
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
1149
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
1150
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
1151

    
1152
    return effect;
1153
    }
1154

    
1155
///////////////////////////////////////////////////////////////////////////////////////////////////
1156

    
1157
  VertexEffect[] createVertexEffectsHelicopterCorner()
1158
    {
1159
    float E = 0.5f;
1160

    
1161
    Static3D axisX  = new Static3D(1,0,0);
1162
    Static3D axisY  = new Static3D(0,1,0);
1163
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
1164
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
1165
    Static1D angle1 = new Static1D(+90);
1166
    Static1D angle2 = new Static1D(-90);
1167
    Static1D angle3 = new Static1D(-135);
1168
    Static1D angle4 = new Static1D(90);
1169
    Static1D angle5 = new Static1D(120);
1170
    Static1D angle6 = new Static1D(240);
1171
    Static3D center1= new Static3D(0,0,0);
1172
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
1173
    Static3D move1  = new Static3D(-E/4,-E/4,0);
1174
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
1175

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

    
1178
    effect[0] = new VertexEffectMove(move1);
1179
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
1180
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
1181
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
1182
    effect[4] = new VertexEffectMove(move2);
1183
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
1184
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1185
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1186
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1187
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1188

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

    
1200
    return effect;
1201
    }
1202

    
1203
///////////////////////////////////////////////////////////////////////////////////////////////////
1204

    
1205
  VertexEffect[] createVertexEffectsHelicopterFace()
1206
    {
1207
    float E = 0.5f;
1208
    float F = SQ2/4;
1209

    
1210
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1211
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1212
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1213
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1214
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1215
    Static1D angle1 = new Static1D(135);
1216
    Static1D angle2 = new Static1D(90);
1217
    Static1D angle3 = new Static1D(-90);
1218
    Static1D angle4 = new Static1D(-135);
1219
    Static3D axisX  = new Static3D(1,0,0);
1220
    Static3D axisY  = new Static3D(0,1,0);
1221
    Static3D axisZ  = new Static3D(0,0,1);
1222
    Static3D axis1  = new Static3D(1,-1,0);
1223
    Static3D center = new Static3D(0,0,0);
1224
    Static3D center1= new Static3D(-E/2,-E/2,0);
1225

    
1226
    VertexEffect[] effect = new VertexEffect[10];
1227

    
1228
    effect[0] = new VertexEffectMove(move0);
1229
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1230
    effect[2] = new VertexEffectMove(move1);
1231
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1232
    effect[4] = new VertexEffectMove(move2);
1233
    effect[5] = new VertexEffectMove(move3);
1234
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1235
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1236
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1237
    effect[9] = new VertexEffectMove(move4);
1238

    
1239
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1240
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1241
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1242
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1243
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1244
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1245
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1246
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1247
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1248
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1249

    
1250
    return effect;
1251
    }
1252

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

    
1255
  VertexEffect[] createVertexEffectsRediEdge()
1256
    {
1257
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1258
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1259
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1260
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1261
    Static3D flipZ = new Static3D(1,1,-1);
1262
    Static3D flipX = new Static3D(-1,1,1);
1263
    Static3D scale = new Static3D(2,2,2);
1264
    Static3D cent0 = new Static3D(0,0, 0);
1265
    Static3D cent1 = new Static3D(0,0, -1.5f);
1266
    Static3D axisX = new Static3D(1,0, 0);
1267
    Static3D axisY = new Static3D(0,1, 0);
1268
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1269
    Static1D angle1= new Static1D(90);
1270
    Static1D angle2= new Static1D(45);
1271
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1272

    
1273
    VertexEffect[] effect = new VertexEffect[12];
1274

    
1275
    effect[0] = new VertexEffectScale(scale);
1276
    effect[1] = new VertexEffectMove(move0);
1277
    effect[2] = new VertexEffectScale(flipZ);
1278
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1279
    effect[4] = new VertexEffectMove(move1);
1280
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1281
    effect[6] = new VertexEffectMove(move2);
1282
    effect[7] = new VertexEffectScale(flipX);
1283
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1284
    effect[9] = new VertexEffectMove(move3);
1285
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1286
    effect[11]= new VertexEffectScale(flipX);
1287

    
1288
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1289
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1290
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1291
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1292
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1293
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1294
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1295
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1296
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1297
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1298
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1299
    effect[11].setMeshAssociation(32,-1); // mesh 5
1300

    
1301
    return effect;
1302
    }
1303

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

    
1306
  VertexEffect[] createVertexEffectsRediCorner()
1307
    {
1308
    Static3D axisY   = new Static3D(0,1,0);
1309
    Static3D axisX   = new Static3D(1,0,0);
1310
    Static3D axisZ   = new Static3D(0,0,1);
1311
    Static3D center  = new Static3D(0,0,0);
1312
    Static1D angle90 = new Static1D(90);
1313
    Static1D angle270= new Static1D(270);
1314
    Static1D angle45 = new Static1D(-45);
1315
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1316

    
1317
    VertexEffect[] effect = new VertexEffect[7];
1318

    
1319
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1320
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1321
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1322
    effect[3] = new VertexEffectScale(scale);
1323
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1324
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1325
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1326

    
1327
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1328
    effect[1].setMeshAssociation( 2,-1);  // 1
1329
    effect[2].setMeshAssociation( 4,-1);  // 2
1330
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1331
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1332
    effect[5].setMeshAssociation(16,-1);  // 4
1333
    effect[6].setMeshAssociation(32,-1);  // 5
1334

    
1335
    return effect;
1336
    }
1337

    
1338
///////////////////////////////////////////////////////////////////////////////////////////////////
1339

    
1340
  VertexEffect[] createVertexEffectsIvyCorner()
1341
    {
1342
    Static3D axisX  = new Static3D(1,0,0);
1343
    Static3D axisY  = new Static3D(0,1,0);
1344
    Static1D angle1 = new Static1D(+90);
1345
    Static1D angle2 = new Static1D(-90);
1346
    Static3D center = new Static3D(0,0,0);
1347
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1348

    
1349
    VertexEffect[] effect = new VertexEffect[5];
1350

    
1351
    effect[0] = new VertexEffectScale(1/IVY_C);
1352
    effect[1] = new VertexEffectMove(move1);
1353
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1354
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1355
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1356

    
1357
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1358
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1359
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1360

    
1361
    return effect;
1362
    }
1363

    
1364
///////////////////////////////////////////////////////////////////////////////////////////////////
1365

    
1366
  VertexEffect[] createVertexEffectsRexEdge()
1367
    {
1368
    float E = 0.5f - REX_D;
1369
    float F = 0.5f;
1370
    float G = (float)Math.sqrt(E*E+F*F);
1371
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1372

    
1373
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1374
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1375

    
1376
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1377
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1378
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1379
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1380
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1381
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1382

    
1383
    Static1D angle180 = new Static1D(180);
1384
    Static1D angle90  = new Static1D( 90);
1385
    Static1D angle270 = new Static1D(270);
1386
    Static1D angle1   = new Static1D(+A);
1387
    Static1D angle2   = new Static1D(-A);
1388

    
1389
    VertexEffect[] effect = new VertexEffect[12];
1390

    
1391
    effect[0] = new VertexEffectMove(move1);
1392
    effect[1] = new VertexEffectMove(move2);
1393
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1394
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1395
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1396
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1397
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1398
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1399
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1400
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1401
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1402
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1403

    
1404
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1405
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1406
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1407
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1408
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1409
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1410
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1411
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1412
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1413
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1414
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1415
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1416

    
1417
    return effect;
1418
    }
1419

    
1420
///////////////////////////////////////////////////////////////////////////////////////////////////
1421

    
1422
  VertexEffect[] createVertexEffectsRexCorner()
1423
    {
1424
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1425
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1426
    Static1D angle = new Static1D(45);
1427

    
1428
    VertexEffect[] effect = new VertexEffect[1];
1429
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1430

    
1431
    return effect;
1432
    }
1433

    
1434
///////////////////////////////////////////////////////////////////////////////////////////////////
1435

    
1436
  VertexEffect[] createVertexEffectsKilominxCorner()
1437
    {
1438
    VertexEffect[] effect = new VertexEffect[9];
1439

    
1440
    float H = 0.5f*(SIN54 / COS54);
1441
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1442
    float Y2= H/(2*COS_HALFD);
1443
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1444
    float sin18 = SIN18;
1445
    float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18));
1446
    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
1447

    
1448
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1449
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1450
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1451
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*SIN_HALFD/(COS_HALFD*LEN));
1452

    
1453
    Static3D move1 = new Static3D(0,-Y1,0);
1454
    Static3D move2 = new Static3D(0,-Y2,0);
1455
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1456
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1457

    
1458
    Static1D angle1 = new Static1D(54);
1459
    Static1D angle2 = new Static1D(A/2+18);
1460
    Static1D angle3 = new Static1D(90);
1461
    Static1D angle4 = new Static1D(120);
1462
    Static1D angle5 = new Static1D(240);
1463
    Static1D angle6 = new Static1D(90-A/2);
1464

    
1465
    effect[0] = new VertexEffectMove(move1);
1466
    effect[1] = new VertexEffectMove(move2);
1467
    effect[2] = new VertexEffectRotate(angle1, axisZ, center);
1468
    effect[3] = new VertexEffectRotate(angle2, axisZ, center);
1469
    effect[4] = new VertexEffectRotate(angle3, axisA, center);
1470
    effect[5] = new VertexEffectMove(move3);
1471
    effect[6] = new VertexEffectRotate(angle4, axisC, center);
1472
    effect[7] = new VertexEffectRotate(angle5, axisC, center);
1473
    effect[8] = new VertexEffectRotate(angle6, axisY, center);
1474

    
1475
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1476
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1477
    effect[2].setMeshAssociation( 7,-1);  // meshes 0,1,2
1478
    effect[3].setMeshAssociation(56,-1);  // meshes 3,4,5
1479
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1480
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1481
    effect[6].setMeshAssociation(18,-1);  // meshes 1,4
1482
    effect[7].setMeshAssociation(36,-1);  // meshes 2,5
1483

    
1484
    return effect;
1485
    }
1486

    
1487
///////////////////////////////////////////////////////////////////////////////////////////////////
1488

    
1489
  VertexEffect[] createVertexEffectsMinxCorner(float width)
1490
    {
1491
    VertexEffect[] effect = new VertexEffect[9];
1492

    
1493
    float Y = COS54/(2*SIN54);
1494

    
1495
    float sinA = (2*SIN54*SIN54-1)/COS54;
1496
    float cosA = (float)Math.sqrt(1-sinA*sinA);
1497
    float LEN  = 0.5f/SIN54;
1498
    float scale= width/LEN;
1499

    
1500
    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
1501
    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
1502
    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
1503

    
1504
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1505
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1506

    
1507
    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
1508
    Static3D move2= new Static3D(0.0f, Y , 0.0f );
1509

    
1510
    Static1D angleD = new Static1D(DIHEDRAL1);
1511
    Static1D angleE = new Static1D(360-DIHEDRAL1);
1512
    Static1D angleF = new Static1D(DIHEDRAL2);
1513

    
1514
    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
1515
    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
1516
    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
1517
    effect[3] = new VertexEffectMove(move1);
1518
    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
1519
    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
1520
    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
1521
    effect[7] = new VertexEffectMove(move2);
1522
    effect[8] = new VertexEffectScale(scale);
1523

    
1524
    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
1525
    effect[1].setMeshAssociation( 16,-1);  // mesh 4
1526
    effect[2].setMeshAssociation( 32,-1);  // mesh 5
1527
    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
1528
    effect[4].setMeshAssociation(  1,-1);  // mesh 0
1529
    effect[5].setMeshAssociation(  2,-1);  // mesh 1
1530

    
1531
    return effect;
1532
    }
1533

    
1534
///////////////////////////////////////////////////////////////////////////////////////////////////
1535

    
1536
  VertexEffect[] createVertexEffectsKilominxEdge(float width, float height, boolean left)
1537
    {
1538
    VertexEffect[] effect = new VertexEffect[11 + (left ? 0:1)];
1539

    
1540
    float D = height/COS18;
1541
    float W = D*SIN18;
1542
    float X1 = height/2;
1543
    float Y1 = width/2;
1544
    float Y2 = (width+W)/2;
1545
    float Y3 = D*COS54;
1546
    float Y4 = height*COS_HALFD;
1547
    float Z = 2*height*COS_HALFD;
1548
    float alpha = 90-DIHEDRAL1/2;
1549
    float beta  = DIHEDRAL2;
1550

    
1551
    Static1D angle1 = new Static1D(alpha);
1552
    Static1D angle2 = new Static1D(180-alpha);
1553
    Static1D angle3 = new Static1D(beta);
1554
    Static1D angle4 = new Static1D(90);
1555

    
1556
    Static3D move1 = new Static3D(+X1,-Y1,0);
1557
    Static3D move2 = new Static3D(-X1,-Y2+W,-Z);
1558
    Static3D move3 = new Static3D(0,+Y3,0);
1559
    Static3D move4 = new Static3D(0,-Y4-width,0);
1560
    Static3D scale = new Static3D(+1,+1,-1);
1561

    
1562
    Static3D axisXplus = new Static3D(+1, 0, 0);
1563
    Static3D axisYplus = new Static3D( 0,+1, 0);
1564

    
1565
    Static3D center1= new Static3D( 0, 0, 0);
1566
    Static3D center2= new Static3D( 0, 0,-Z);
1567
    Static3D center3= new Static3D( 0,-width, 0);
1568

    
1569
    effect[ 0] = new VertexEffectMove(move1);
1570
    effect[ 1] = new VertexEffectMove(move2);
1571
    effect[ 2] = new VertexEffectMove(move3);
1572
    effect[ 3] = new VertexEffectMove(move4);
1573
    effect[ 4] = new VertexEffectScale(scale);
1574
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1575
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1576
    effect[ 7] = new VertexEffectRotate(angle1, axisYplus , center2);
1577
    effect[ 8] = new VertexEffectRotate(angle2, axisYplus , center2);
1578
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center1);
1579
    effect[10] = new VertexEffectRotate(angle4, axisXplus , center3);
1580

    
1581
    if( !left )
1582
      {
1583
      Static3D scale1 = new Static3D(+1,-1,+1);
1584
      effect[11] = new VertexEffectScale(scale1);
1585
      }
1586

    
1587
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1588
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1589
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1590
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1591
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1592
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1593
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1594
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1595
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1596
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1597
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1598

    
1599
    return effect;
1600
    }
1601

    
1602
///////////////////////////////////////////////////////////////////////////////////////////////////
1603

    
1604
  VertexEffect[] createVertexEffectsMegaminxEdge(float width, float height)
1605
    {
1606
    VertexEffect[] effect = new VertexEffect[11];
1607

    
1608
    float X = 0.5f*height;
1609
    float Y = height*(COS54/COS18) + width*0.5f;
1610
    float Z = 2*height*COS_HALFD;
1611

    
1612
    float alpha = 90-DIHEDRAL1/2;
1613
    float beta  = DIHEDRAL2;
1614

    
1615
    Static1D angle1 = new Static1D(alpha);
1616
    Static1D angle2 = new Static1D(180-alpha);
1617
    Static1D angle3 = new Static1D(beta);
1618

    
1619
    Static3D move1 = new Static3D(X,0,0);
1620
    Static3D move2 = new Static3D(X,0,-Z);
1621
    Static3D move3 = new Static3D(0,+Y,0);
1622
    Static3D move4 = new Static3D(0,-Y,0);
1623
    Static3D scale = new Static3D(+1,+1,-1);
1624

    
1625
    Static3D axisXplus = new Static3D(+1, 0, 0);
1626
    Static3D axisXminus= new Static3D(-1, 0, 0);
1627
    Static3D axisYplus = new Static3D( 0,+1, 0);
1628
    Static3D axisYminus= new Static3D( 0,-1, 0);
1629

    
1630
    Static3D center1= new Static3D( 0, 0, 0);
1631
    Static3D center2= new Static3D( 0, 0,-Z);
1632
    Static3D center3= new Static3D( 0,+width*0.5f, 0);
1633
    Static3D center4= new Static3D( 0,-width*0.5f, 0);
1634

    
1635
    effect[ 0] = new VertexEffectMove(move1);
1636
    effect[ 1] = new VertexEffectMove(move2);
1637
    effect[ 2] = new VertexEffectMove(move3);
1638
    effect[ 3] = new VertexEffectMove(move4);
1639
    effect[ 4] = new VertexEffectScale(scale);
1640
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1641
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1642
    effect[ 7] = new VertexEffectRotate(angle1, axisYminus, center2);
1643
    effect[ 8] = new VertexEffectRotate(angle2, axisYminus, center2);
1644
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center3);
1645
    effect[10] = new VertexEffectRotate(angle3, axisXminus, center4);
1646

    
1647
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1648
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1649
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1650
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1651
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1652
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1653
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1654
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1655
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1656
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1657
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1658

    
1659
    return effect;
1660
    }
1661

    
1662
///////////////////////////////////////////////////////////////////////////////////////////////////
1663

    
1664
  VertexEffect[] createCuboidEffects(int[] dimensions)
1665
    {
1666
    float X = dimensions[0];
1667
    float Y = dimensions[1];
1668
    float Z = dimensions[2];
1669

    
1670
    float MAX_XY = Math.max(X,Y);
1671
    float MAX_XZ = Math.max(X,Z);
1672
    float MAX_YZ = Math.max(Z,Y);
1673

    
1674
    Static1D angle = new Static1D(90);
1675
    Static3D move  = new Static3D( 0.0f, 0.0f, 0.5f);
1676
    Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
1677
    Static3D axisY = new Static3D( 0.0f, 1.0f, 0.0f);
1678
    Static3D center= new Static3D( 0.0f, 0.0f, 0.0f);
1679

    
1680
    Static3D scale3 = new Static3D(MAX_XY,MAX_XY,+Z);
1681
    Static3D scale4 = new Static3D(MAX_XY,MAX_XY,-Z);
1682
    Static3D scale5 = new Static3D(MAX_XZ,+Y,MAX_XZ);
1683
    Static3D scale6 = new Static3D(MAX_XZ,-Y,MAX_XZ);
1684
    Static3D scale7 = new Static3D(+X,MAX_YZ,MAX_YZ);
1685
    Static3D scale8 = new Static3D(-X,MAX_YZ,MAX_YZ);
1686

    
1687
    VertexEffect[] effect = new VertexEffect[9];
1688

    
1689
    effect[0] = new VertexEffectMove(move);
1690
    effect[1] = new VertexEffectRotate(angle, axisX, center);
1691
    effect[2] = new VertexEffectRotate(angle, axisY, center);
1692
    effect[3] = new VertexEffectScale(scale3);
1693
    effect[4] = new VertexEffectScale(scale4);
1694
    effect[5] = new VertexEffectScale(scale5);
1695
    effect[6] = new VertexEffectScale(scale6);
1696
    effect[7] = new VertexEffectScale(scale7);
1697
    effect[8] = new VertexEffectScale(scale8);
1698

    
1699
    effect[1].setMeshAssociation(12,-1);  // meshes 2,3
1700
    effect[2].setMeshAssociation( 3,-1);  // meshes 0,1
1701
    effect[3].setMeshAssociation(16,-1);  // mesh 4
1702
    effect[4].setMeshAssociation(32,-1);  // mesh 5
1703
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1704
    effect[6].setMeshAssociation( 4,-1);  // mesh 2
1705
    effect[7].setMeshAssociation( 1,-1);  // mesh 0
1706
    effect[8].setMeshAssociation( 2,-1);  // mesh 1
1707

    
1708
    return effect;
1709
    }
1710

    
1711
///////////////////////////////////////////////////////////////////////////////////////////////////
1712
// OBJECTS
1713
///////////////////////////////////////////////////////////////////////////////////////////////////
1714
// CUBE
1715

    
1716
  MeshBase createCubeMesh(int index)
1717
    {
1718
    MeshBase mesh = createFacesCube(index);
1719
    VertexEffect[] effects = createVertexEffectsCube();
1720
    for( VertexEffect effect : effects ) mesh.apply(effect);
1721

    
1722
    Static3D roundingCenter  = new Static3D(0,0,0);
1723
    Static3D[] vertices = new Static3D[8];
1724
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1725
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1726
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1727
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1728
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1729
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1730
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1731
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1732

    
1733
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1734

    
1735
    mesh.mergeEffComponents();
1736

    
1737
    return mesh;
1738
    }
1739

    
1740
///////////////////////////////////////////////////////////////////////////////////////////////////
1741
// SKEWB
1742

    
1743
  MeshBase createSkewbCornerMesh()
1744
    {
1745
    MeshBase mesh = createFacesSkewbCorner();
1746
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1747
    for( VertexEffect effect : effects ) mesh.apply(effect);
1748

    
1749
    float E = 0.5f;
1750
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1751

    
1752
    Static3D[] verticesType1 = new Static3D[1];
1753
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1754
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1755

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

    
1762
    mesh.mergeEffComponents();
1763

    
1764
    return mesh;
1765
    }
1766

    
1767
///////////////////////////////////////////////////////////////////////////////////////////////////
1768

    
1769
  MeshBase createSkewbFaceMesh()
1770
    {
1771
    MeshBase mesh = createFacesSkewbFace();
1772
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1773
    for( VertexEffect effect : effects ) mesh.apply(effect);
1774

    
1775
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1776
    float E = SQ2/4;
1777
    Static3D[] vertices = new Static3D[4];
1778
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1779
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1780
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1781
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1782
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1783

    
1784
    mesh.mergeEffComponents();
1785
    mesh.addEmptyTexComponent();
1786

    
1787
    return mesh;
1788
    }
1789

    
1790
///////////////////////////////////////////////////////////////////////////////////////////////////
1791
// SKEWB DIAMOND / PYRAMINX
1792

    
1793
  MeshBase createOctaMesh()
1794
    {
1795
    MeshBase mesh = createFacesOcta();
1796
    VertexEffect[] effects = createVertexEffectsOcta();
1797
    for( VertexEffect effect : effects ) mesh.apply(effect);
1798

    
1799
    Static3D roundingCenter = new Static3D(0,0,0);
1800
    Static3D[] vertices = new Static3D[6];
1801
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1802
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1803
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1804
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1805
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1806
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1807

    
1808
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1809

    
1810
    mesh.mergeEffComponents();
1811

    
1812
    return mesh;
1813
    }
1814

    
1815
///////////////////////////////////////////////////////////////////////////////////////////////////
1816

    
1817
  MeshBase createTetraMesh()
1818
    {
1819
    MeshBase mesh = createFacesTetra();
1820
    VertexEffect[] effects = createVertexEffectsTetra();
1821
    for( VertexEffect effect : effects ) mesh.apply(effect);
1822

    
1823
    Static3D roundingCenter = new Static3D(0,0,0);
1824
    Static3D[] verticesRound = new Static3D[4];
1825
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1826
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1827
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1828
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1829
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1830

    
1831
    mesh.mergeEffComponents();
1832
    mesh.addEmptyTexComponent();
1833
    mesh.addEmptyTexComponent();
1834
    mesh.addEmptyTexComponent();
1835
    mesh.addEmptyTexComponent();
1836

    
1837
    return mesh;
1838
    }
1839

    
1840
///////////////////////////////////////////////////////////////////////////////////////////////////
1841
// DINO
1842

    
1843
  MeshBase createDinoMesh()
1844
    {
1845
    MeshBase mesh = createFacesDino();
1846
    VertexEffect[] effects = createVertexEffectsDino();
1847
    for( VertexEffect effect : effects ) mesh.apply(effect);
1848

    
1849
    float F = 0.5f;
1850
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1851
    Static3D[] verticesRound = new Static3D[4];
1852
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1853
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1854
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1855
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1856
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1857

    
1858
    mesh.mergeEffComponents();
1859

    
1860
    return mesh;
1861
    }
1862

    
1863
///////////////////////////////////////////////////////////////////////////////////////////////////
1864
// Helicopter
1865

    
1866
  MeshBase createHelicopterCornerMesh()
1867
    {
1868
    MeshBase mesh = createFacesHelicopterCorner();
1869
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1870
    for( VertexEffect effect : effects ) mesh.apply(effect);
1871

    
1872
    float E = 0.5f;
1873
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1874

    
1875
    Static3D[] verticesType1 = new Static3D[1];
1876
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1877
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1878

    
1879
    Static3D[] verticesType2 = new Static3D[3];
1880
    verticesType2[0] = new Static3D(-E, 0, 0);
1881
    verticesType2[1] = new Static3D( 0,-E, 0);
1882
    verticesType2[2] = new Static3D( 0, 0,-E);
1883
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1884

    
1885
    mesh.mergeEffComponents();
1886

    
1887
    return mesh;
1888
    }
1889

    
1890
///////////////////////////////////////////////////////////////////////////////////////////////////
1891

    
1892
  MeshBase createHelicopterFaceMesh()
1893
    {
1894
    MeshBase mesh = createFacesHelicopterFace();
1895
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1896
    for( VertexEffect effect : effects ) mesh.apply(effect);
1897

    
1898
    float E = 0.5f;
1899
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1900

    
1901
    Static3D[] verticesType1 = new Static3D[1];
1902
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1903
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1904

    
1905
    Static3D[] verticesType2 = new Static3D[2];
1906
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1907
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1908
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1909

    
1910
    mesh.mergeEffComponents();
1911
    mesh.addEmptyTexComponent();
1912
    mesh.addEmptyTexComponent();
1913

    
1914
    return mesh;
1915
    }
1916

    
1917
///////////////////////////////////////////////////////////////////////////////////////////////////
1918
// Redi cube
1919

    
1920
  MeshBase createRediEdgeMesh()
1921
    {
1922
    MeshBase mesh = createFacesRediEdge();
1923
    VertexEffect[] effects = createVertexEffectsRediEdge();
1924
    for( VertexEffect effect : effects ) mesh.apply(effect);
1925

    
1926
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1927
    Static3D[] vertices = new Static3D[2];
1928
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1929
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1930
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1931

    
1932
    mesh.mergeEffComponents();
1933

    
1934
    return mesh;
1935
    }
1936

    
1937
///////////////////////////////////////////////////////////////////////////////////////////////////
1938

    
1939
  MeshBase createRediCornerMesh()
1940
    {
1941
    MeshBase mesh = createFacesRediCorner();
1942
    VertexEffect[] effects = createVertexEffectsRediCorner();
1943
    for( VertexEffect effect : effects ) mesh.apply(effect);
1944

    
1945
    Static3D center = new Static3D(0,0,0);
1946
    Static3D[] vertices = new Static3D[8];
1947
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1948
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1949
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1950
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1951
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1952
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1953
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1954
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1955

    
1956
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1957

    
1958
    mesh.mergeEffComponents();
1959

    
1960
    return mesh;
1961
    }
1962

    
1963
///////////////////////////////////////////////////////////////////////////////////////////////////
1964

    
1965
  MeshBase createIvyCornerMesh()
1966
    {
1967
    MeshBase mesh = createFacesIvyCorner();
1968
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1969
    for( VertexEffect effect : effects ) mesh.apply(effect);
1970

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

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

    
1980
    mesh.mergeEffComponents();
1981

    
1982
    return mesh;
1983
    }
1984

    
1985
///////////////////////////////////////////////////////////////////////////////////////////////////
1986

    
1987
  MeshBase createIvyFaceMesh()
1988
    {
1989
    MeshBase mesh = createFacesIvyFace();
1990

    
1991
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1992
    Static3D[] vertices = new Static3D[2];
1993
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1994
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1995

    
1996
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1997

    
1998
    mesh.mergeEffComponents();
1999
    mesh.addEmptyTexComponent();
2000
    mesh.addEmptyTexComponent();
2001
    mesh.addEmptyTexComponent();
2002
    mesh.addEmptyTexComponent();
2003

    
2004
    return mesh;
2005
    }
2006

    
2007
///////////////////////////////////////////////////////////////////////////////////////////////////
2008

    
2009
  MeshBase createRexCornerMesh()
2010
    {
2011
    MeshBase mesh = createFacesRexCorner();
2012
    VertexEffect[] effects = createVertexEffectsRexCorner();
2013
    for( VertexEffect effect : effects ) mesh.apply(effect);
2014

    
2015
    Static3D center = new Static3D(0.0f,0.0f,-0.25f);
2016
    Static3D[] vertices = new Static3D[1];
2017
    vertices[0] = new Static3D(+0.25f,+0.25f,+0.0f);
2018
    roundCorners(mesh,center,vertices,0.03f,0.10f);
2019

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

    
2024
    return mesh;
2025
    }
2026

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

    
2029
  MeshBase createRexFaceMesh()
2030
    {
2031
    MeshBase mesh = createFacesRexFace();
2032

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

    
2037
    return mesh;
2038
    }
2039

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

    
2042
  MeshBase createRexEdgeMesh()
2043
    {
2044
    MeshBase mesh = createFacesRexEdge();
2045
    VertexEffect[] effects = createVertexEffectsRexEdge();
2046
    for( VertexEffect effect : effects ) mesh.apply(effect);
2047

    
2048
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
2049
    Static3D[] vertices = new Static3D[2];
2050
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
2051
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
2052
    roundCorners(mesh,center,vertices,0.06f,0.10f);
2053

    
2054
    mesh.mergeEffComponents();
2055

    
2056
    return mesh;
2057
    }
2058

    
2059
///////////////////////////////////////////////////////////////////////////////////////////////////
2060

    
2061
  MeshBase createKilominxCornerMesh()
2062
    {
2063
    MeshBase mesh = createFacesKilominxCorner();
2064
    VertexEffect[] effects = createVertexEffectsKilominxCorner();
2065
    for( VertexEffect effect : effects ) mesh.apply(effect);
2066

    
2067
    float A = (2*SQ3/3)* SIN54;
2068
    float B = 0.4f;
2069
    float X = SIN_HALFD* SIN54 * COS54;
2070
    float Y = SIN54 * SIN54 - 0.5f;
2071
    float Z = COS_HALFD* SIN54 * COS54;
2072

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

    
2075
    Static3D[] vertices = new Static3D[4];
2076
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
2077
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
2078
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
2079
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
2080

    
2081
    roundCorners(mesh,center,vertices,0.03f,0.10f);
2082

    
2083
    //mesh.mergeEffComponents();
2084

    
2085
    return mesh;
2086
    }
2087

    
2088
///////////////////////////////////////////////////////////////////////////////////////////////////
2089

    
2090
  MeshBase createKilominxEdgeMesh(int numLayers, float width, float height, boolean left)
2091
    {
2092
    MeshBase mesh = createFacesKilominxEdge(numLayers,width,height);
2093
    VertexEffect[] effects = createVertexEffectsKilominxEdge(width,height,left);
2094
    for( VertexEffect effect : effects ) mesh.apply(effect);
2095

    
2096
    float A = (2*SQ3/3)* SIN54;
2097
    float B = 0.4f;
2098
    float X = SIN_HALFD* SIN54 * COS54;
2099
    float Y = SIN54 * SIN54 - 0.5f;
2100
    float Z = COS_HALFD* SIN54 * COS54;
2101
    float S = 2*width;
2102

    
2103
    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
2104
    Static3D[] vertices = new Static3D[4];
2105
    vertices[0] = new Static3D( 0.0f, 0.0f  , 0.0f);
2106
    vertices[1] = new Static3D( 0.0f,-0.5f*S, 0.0f);
2107
    vertices[2] = new Static3D(-X*S , Y*S   ,-Z*S );
2108
    vertices[3] = new Static3D(+X*S , Y*S   ,-Z*S );
2109

    
2110
    roundCorners(mesh,center,vertices,0.04f,0.10f);
2111

    
2112
    //mesh.mergeEffComponents();
2113

    
2114
    return mesh;
2115
    }
2116

    
2117
///////////////////////////////////////////////////////////////////////////////////////////////////
2118

    
2119
  MeshBase createMinxCornerMesh()
2120
    {
2121
    int numLayers = 9;
2122
    float width = (numLayers/3.0f)*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
2123

    
2124
    MeshBase mesh = createFacesMinxCorner(numLayers);
2125
    VertexEffect[] effects = createVertexEffectsMinxCorner(width);
2126
    for( VertexEffect effect : effects ) mesh.apply(effect);
2127

    
2128
    float A = (2*SQ3/3)* SIN54;
2129
    float B = 0.4f;
2130
    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
2131
    Static3D[] vertices = new Static3D[1];
2132
    vertices[0] = new Static3D( 0.0f, 0.0f  , 0.0f);
2133
    roundCorners(mesh,center,vertices,0.04f,0.10f);
2134

    
2135
    //mesh.mergeEffComponents();
2136

    
2137
    return mesh;
2138
    }
2139

    
2140
///////////////////////////////////////////////////////////////////////////////////////////////////
2141

    
2142
  MeshBase createMegaminxEdgeMesh(float width, float height)
2143
    {
2144
    MeshBase mesh = createFacesMegaminxEdge(width,height);
2145
    VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
2146
    for( VertexEffect effect : effects ) mesh.apply(effect);
2147

    
2148
    //mesh.mergeEffComponents();
2149

    
2150
    return mesh;
2151
    }
2152

    
2153
///////////////////////////////////////////////////////////////////////////////////////////////////
2154

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

    
2161
    int X = dimensions[0];
2162
    int Y = dimensions[1];
2163
    int Z = dimensions[2];
2164

    
2165
    float strength = 0.04f;
2166
    float radius   = 0.15f;
2167

    
2168
    Static3D[] vertices = new Static3D[1];
2169
    Static3D center;
2170

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

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

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

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

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

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

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

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

    
2203
  //  mesh.mergeEffComponents();
2204

    
2205
    return mesh;
2206
    }
2207
  }
(1-1/5)