Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 4e627d8b

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

    
20
package org.distorted.objects;
21

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

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

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

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

    
48
  static final float MINX_C0 = (SQ5-1)/4;
49
  static final float MINX_C1 = (SQ5+1)/4;                         // sin(54 deg)
50
  static final float MINX_C3 = (float)(Math.sqrt(10-2*SQ5)/4);    // cos(54 deg)
51
  static final float MINX_C4 = (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
52
  static final float MINX_C5 = (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
53

    
54
  private static final int IVY_N = 8;
55

    
56
  private static final Static1D RADIUS = new Static1D(1);
57
  private static FactoryCubit mThis;
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

    
61
  private FactoryCubit()
62
    {
63

    
64
    }
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

    
68
  public static FactoryCubit getInstance()
69
    {
70
    if( mThis==null ) mThis = new FactoryCubit();
71

    
72
    return mThis;
73
    }
74

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

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
  private float f(float D, float B, float x)
113
    {
114
    return ((D-B)*x + B*(1-D))/(1-B);
115
    }
116

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

    
119
  private float g(float R, float D, float x, float cosAlpha)
120
    {
121
    float d = x-D;
122
    return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
123
    }
124

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

    
127
  private float h(float R, float sinAlpha, float x)
128
    {
129
    return R*(sinAlpha-(float)Math.sin(x));
130
    }
131

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

    
134
  private float[] computeBands(float H, int alpha, float dist, float K, int N)
135
    {
136
    float[] bands = new float[2*N];
137

    
138
    bands[0] = 1.0f;
139
    bands[1] = 0.0f;
140

    
141
    float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
142
    float sinBeta = (float)Math.sin(beta);
143
    float cosBeta = (float)Math.cos(beta);
144
    float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
145
    float D = R*sinBeta;
146
    float B = h(R,sinBeta,K*beta);
147

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

    
161
      for(int i=0; i<=K1; i++)
162
        {
163
        float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
164
        float x = h(R,sinBeta,angle);
165
        bands[2*i+2] = 1.0f - x;
166
        bands[2*i+3] = g(R,D,x,cosBeta);
167
        }
168

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

    
177
    bands[2*N-2] = 0.0f;
178
    bands[2*N-1] =    H;
179

    
180
    return bands;
181
    }
182

    
183
///////////////////////////////////////////////////////////////////////////////////////////////////
184

    
185
  private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
186
    {
187
    Static4D reg= new Static4D(0,0,0,regionRadius);
188

    
189
    float centX = center.get0();
190
    float centY = center.get1();
191
    float centZ = center.get2();
192

    
193
    for (Static3D vertex : vertices)
194
      {
195
      float x = strength*(centX - vertex.get0());
196
      float y = strength*(centY - vertex.get1());
197
      float z = strength*(centZ - vertex.get2());
198

    
199
      VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
200
      mesh.apply(effect);
201
      }
202
    }
203

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

    
209
  private void writeVertex( float cx, float cy, float px, float py, float radians, float[] array, int index)
210
    {
211
    float vx = px-cx;
212
    float vy = py-cy;
213

    
214
    float sinA = (float)Math.sin(radians);
215
    float cosA = (float)Math.cos(radians);
216

    
217
    float rvx = vx*cosA - vy*sinA;
218
    float rvy = vx*sinA + vy*cosA;
219

    
220
    array[index  ] = rvx + cx;
221
    array[index+1] = rvy + cy;
222
    }
223

    
224
///////////////////////////////////////////////////////////////////////////////////////////////////
225

    
226
  MeshBase createFacesCube(int sizeIndex)
227
    {
228
    MeshBase[] meshes = new MeshPolygon[6];
229

    
230
    float E = 0.5f;
231
    int extraI, extraV, num;
232

    
233
    switch(sizeIndex)
234
      {
235
      case 0 : num = 6; extraI = 2; extraV = 2; break;
236
      case 1 : num = 5; extraI = 2; extraV = 2; break;
237
      case 2 : num = 5; extraI = 1; extraV = 2; break;
238
      default: num = 4; extraI = 1; extraV = 1; break;
239
      }
240

    
241
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
242
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
243

    
244
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
245
    meshes[0].setEffectAssociation(0,1,0);
246
    meshes[1] = meshes[0].copy(true);
247
    meshes[1].setEffectAssociation(0,2,0);
248
    meshes[2] = meshes[0].copy(true);
249
    meshes[2].setEffectAssociation(0,4,0);
250
    meshes[3] = meshes[0].copy(true);
251
    meshes[3].setEffectAssociation(0,8,0);
252
    meshes[4] = meshes[0].copy(true);
253
    meshes[4].setEffectAssociation(0,16,0);
254
    meshes[5] = meshes[0].copy(true);
255
    meshes[5].setEffectAssociation(0,32,0);
256

    
257
    return new MeshJoined(meshes);
258
    }
259

    
260
///////////////////////////////////////////////////////////////////////////////////////////////////
261

    
262
  MeshBase createFacesSkewbCorner()
263
    {
264
    MeshBase[] meshes = new MeshBase[6];
265

    
266
    float E = 0.5f;
267
    float F = SQ2/2;
268
    float G = SQ6/16;
269
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
270
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
271

    
272
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
273
    meshes[0].setEffectAssociation(0,1,0);
274
    meshes[1] = meshes[0].copy(true);
275
    meshes[1].setEffectAssociation(0,2,0);
276
    meshes[2] = meshes[0].copy(true);
277
    meshes[2].setEffectAssociation(0,4,0);
278

    
279
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
280
    float[] bands1 = computeBands(0,0,1,0,3);
281

    
282
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
283
    meshes[3].setEffectAssociation(0,8,0);
284
    meshes[4] = meshes[3].copy(true);
285
    meshes[4].setEffectAssociation(0,16,0);
286
    meshes[5] = meshes[3].copy(true);
287
    meshes[5].setEffectAssociation(0,32,0);
288

    
289
    return new MeshJoined(meshes);
290
    }
291

    
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293

    
294
  MeshBase createFacesSkewbFace()
295
    {
296
    MeshBase[] meshes = new MeshBase[5];
297

    
298
    float E = SQ2/4;
299
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
300
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
301

    
302
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
303
    meshes[0].setEffectAssociation(0,1,0);
304

    
305
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
306
    float[] bands1 = computeBands(0,0,1,0,3);
307

    
308
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
309
    meshes[1].setEffectAssociation(0,2,0);
310
    meshes[2] = meshes[1].copy(true);
311
    meshes[2].setEffectAssociation(0,4,0);
312
    meshes[3] = meshes[1].copy(true);
313
    meshes[3].setEffectAssociation(0,8,0);
314
    meshes[4] = meshes[1].copy(true);
315
    meshes[4].setEffectAssociation(0,16,0);
316

    
317
    return new MeshJoined(meshes);
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321

    
322
  MeshBase createFacesOcta()
323
    {
324
    MeshBase[] meshes = new MeshPolygon[8];
325

    
326
    float E = 0.75f;
327
    float F = 0.5f;
328
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
329
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
330

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

    
348
    return new MeshJoined(meshes);
349
    }
350

    
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352

    
353
  MeshBase createFacesTetra()
354
    {
355
    MeshBase[] meshes = new MeshBase[4];
356

    
357
    float E = 0.75f;
358
    float F = 0.5f;
359
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
360
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
361

    
362
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
363
    meshes[0].setEffectAssociation(0,1,0);
364
    meshes[1] = meshes[0].copy(true);
365
    meshes[1].setEffectAssociation(0,2,0);
366
    meshes[2] = meshes[0].copy(true);
367
    meshes[2].setEffectAssociation(0,4,0);
368
    meshes[3] = meshes[0].copy(true);
369
    meshes[3].setEffectAssociation(0,8,0);
370

    
371
    return new MeshJoined(meshes);
372
    }
373

    
374
///////////////////////////////////////////////////////////////////////////////////////////////////
375

    
376
  MeshBase createFacesDino()
377
    {
378
    MeshBase[] meshes = new MeshPolygon[4];
379

    
380
    float E = 0.5f*SQ2;
381
    float F = 0.5f;
382
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
383
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
384

    
385
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
386
    meshes[0].setEffectAssociation(0,1,0);
387
    meshes[1] = meshes[0].copy(true);
388
    meshes[1].setEffectAssociation(0,2,0);
389

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

    
393
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
394
    meshes[2].setEffectAssociation(0,4,0);
395
    meshes[3] = meshes[2].copy(true);
396
    meshes[3].setEffectAssociation(0,8,0);
397

    
398
    return new MeshJoined(meshes);
399
    }
400

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

    
403
  MeshBase createFacesHelicopterCorner()
404
    {
405
    MeshBase[] meshes = new MeshBase[6];
406

    
407
    float E = 0.5f;
408
    float F = SQ2/4;
409
    float G = 1.0f/12;
410
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
411
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
412

    
413
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
414
    meshes[0].setEffectAssociation(0,1,0);
415
    meshes[1] = meshes[0].copy(true);
416
    meshes[1].setEffectAssociation(0,2,0);
417
    meshes[2] = meshes[0].copy(true);
418
    meshes[2].setEffectAssociation(0,4,0);
419

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

    
429
    return new MeshJoined(meshes);
430
    }
431

    
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433

    
434
  MeshBase createFacesHelicopterFace()
435
    {
436
    MeshBase[] meshes = new MeshBase[4];
437

    
438
    float E = 0.5f;
439
    float F = SQ2/4;
440
    float G = 1.0f/12;
441
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
442
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
443

    
444
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
445
    meshes[0].setEffectAssociation(0,1,0);
446

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

    
450
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
451
    meshes[1].setEffectAssociation(0,2,0);
452

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

    
455
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
456
    meshes[2].setEffectAssociation(0,4,0);
457
    meshes[3] = meshes[2].copy(true);
458
    meshes[3].setEffectAssociation(0,8,0);
459

    
460
    return new MeshJoined(meshes);
461
    }
462

    
463
///////////////////////////////////////////////////////////////////////////////////////////////////
464

    
465
  MeshBase createFacesRediEdge()
466
    {
467
    MeshBase[] meshes = new MeshPolygon[6];
468

    
469
    float F = 0.25f;
470
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
471
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
472

    
473
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
474
    meshes[0].setEffectAssociation(0,1,0);
475
    meshes[1] = meshes[0].copy(true);
476
    meshes[1].setEffectAssociation(0,2,0);
477

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

    
481
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
482
    meshes[2].setEffectAssociation(0,4,0);
483
    meshes[3] = meshes[2].copy(true);
484
    meshes[3].setEffectAssociation(0,8,0);
485

    
486
    float X = 0.25f*SQ2;
487
    float Y = SQ6/16;
488
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
489

    
490
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
491
    meshes[4].setEffectAssociation(0,16,0);
492
    meshes[5] = meshes[4].copy(true);
493
    meshes[5].setEffectAssociation(0,32,0);
494

    
495
    return new MeshJoined(meshes);
496
    }
497

    
498
///////////////////////////////////////////////////////////////////////////////////////////////////
499

    
500
  MeshBase createFacesRediCorner()
501
    {
502
    MeshBase[] meshes = new MeshBase[6];
503

    
504
    float E = 0.5f;
505
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
506
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
507

    
508
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
509
    meshes[0].setEffectAssociation(0,1,0);
510
    meshes[1] = meshes[0].copy(true);
511
    meshes[1].setEffectAssociation(0,2,0);
512
    meshes[2] = meshes[0].copy(true);
513
    meshes[2].setEffectAssociation(0,4,0);
514

    
515
    float F = 0.5f;
516
    float X = 0.5f;
517
    float G = 0.72f;
518
    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 };
519
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
520

    
521
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
522
    meshes[3].setEffectAssociation(0,8,0);
523
    meshes[4] = meshes[3].copy(true);
524
    meshes[4].setEffectAssociation(0,16,0);
525
    meshes[5] = meshes[3].copy(true);
526
    meshes[5].setEffectAssociation(0,32,0);
527

    
528
    return new MeshJoined(meshes);
529
    }
530

    
531
///////////////////////////////////////////////////////////////////////////////////////////////////
532

    
533
  MeshBase createFacesIvyCorner()
534
    {
535
    MeshBase[] meshes = new MeshBase[6];
536

    
537
    final float angle = (float)Math.PI/(2*IVY_N);
538
    final float CORR  = 1.0f - 2*IVY_D;
539
    final float DIST  = -0.5f*CORR + IVY_D;
540
    float[] vertices  = new float[2*(IVY_N+1)+6];
541

    
542
    vertices[0] = (0.5f-IVY_M) * IVY_C;
543
    vertices[1] = (DIST-IVY_M) * IVY_C;
544
    vertices[2] = (0.5f-IVY_M) * IVY_C;
545
    vertices[3] = (0.5f-IVY_M) * IVY_C;
546
    vertices[4] = (DIST-IVY_M) * IVY_C;
547
    vertices[5] = (0.5f-IVY_M) * IVY_C;
548

    
549
    for(int i=0; i<=IVY_N; i++)
550
      {
551
      float ang = (IVY_N-i)*angle;
552
      float sin = (float)Math.sin(ang);
553
      float cos = (float)Math.cos(ang);
554

    
555
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
556
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
557
      }
558

    
559
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
560
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
561

    
562
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
563
    meshes[0].setEffectAssociation(0,1,0);
564
    meshes[1] = meshes[0].copy(true);
565
    meshes[1].setEffectAssociation(0,2,0);
566
    meshes[2] = meshes[0].copy(true);
567
    meshes[2].setEffectAssociation(0,4,0);
568
    meshes[3] = new MeshPolygon(vertices,bands1,1,2);
569
    meshes[3].setEffectAssociation(0,8,0);
570
    meshes[4] = meshes[3].copy(true);
571
    meshes[4].setEffectAssociation(0,16,0);
572
    meshes[5] = meshes[3].copy(true);
573
    meshes[5].setEffectAssociation(0,32,0);
574

    
575
    return new MeshJoined(meshes);
576
    }
577

    
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579

    
580
  MeshBase createFacesIvyFace()
581
    {
582
    MeshBase[] meshes = new MeshBase[2];
583

    
584
    final float angle = (float)Math.PI/(2*IVY_N);
585
    final float CORR  = 1.0f - 2*IVY_D;
586
    float[] vertices = new float[4*IVY_N];
587

    
588
    for(int i=0; i<IVY_N; i++)
589
      {
590
      float sin = (float)Math.sin(i*angle);
591
      float cos = (float)Math.cos(i*angle);
592

    
593
      vertices[2*i          ] = CORR*(0.5f-cos);
594
      vertices[2*i+1        ] = CORR*(0.5f-sin);
595
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
596
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
597
      }
598

    
599
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
600
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
601

    
602
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
603
    meshes[0].setEffectAssociation(0,1,0);
604
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
605
    meshes[1].setEffectAssociation(0,2,0);
606

    
607
    return new MeshJoined(meshes);
608
    }
609

    
610
///////////////////////////////////////////////////////////////////////////////////////////////////
611

    
612
  MeshBase createFacesRexCorner()
613
    {
614
    MeshBase[] meshes = new MeshBase[2];
615

    
616
    float F = REX_D*SQ2;
617
    float G = (1-REX_D)*SQ2/2;
618
    float H = 0.1f;
619
    float J = +2*G/3 - H*G;
620

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

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

    
626
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
627
    meshes[0].setEffectAssociation(0,1,0);
628
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
629
    meshes[1].setEffectAssociation(0,2,0);
630

    
631
    return new MeshJoined(meshes);
632
    }
633

    
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635

    
636
  MeshBase createFacesRexFace()
637
    {
638
    MeshBase[] meshes = new MeshBase[2];
639

    
640
    float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
641

    
642
    float[] bands0 = computeBands(0.016f,10,REX_D/2,0.5f,5);
643
    float[] bands1 = computeBands(0.000f,45,REX_D/2,0.0f,2);
644

    
645
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
646
    meshes[0].setEffectAssociation(0,1,0);
647
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
648
    meshes[1].setEffectAssociation(0,2,0);
649

    
650
    return new MeshJoined(meshes);
651
    }
652

    
653
///////////////////////////////////////////////////////////////////////////////////////////////////
654

    
655
  MeshBase createFacesRexEdge()
656
    {
657
    MeshBase[] meshes = new MeshPolygon[6];
658

    
659
    float E = 0.5f - REX_D;
660
    float F = 0.5f;
661
    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
662
    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
663

    
664
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
665
    meshes[0].setEffectAssociation(0,1,0);
666
    meshes[1] = meshes[0].copy(true);
667
    meshes[1].setEffectAssociation(0,2,0);
668

    
669
    float G = (float)Math.sqrt(E*E+F*F);
670
    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
671
    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
672

    
673
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
674
    meshes[2].setEffectAssociation(0,4,0);
675
    meshes[3] = meshes[2].copy(true);
676
    meshes[3].setEffectAssociation(0,8,0);
677
    meshes[4] = meshes[2].copy(true);
678
    meshes[4].setEffectAssociation(0,16,0);
679
    meshes[5] = meshes[2].copy(true);
680
    meshes[5].setEffectAssociation(0,32,0);
681

    
682
    return new MeshJoined(meshes);
683
    }
684

    
685
///////////////////////////////////////////////////////////////////////////////////////////////////
686

    
687
  MeshBase createFacesMinxCorner()
688
    {
689
    MeshBase[] meshes = new MeshPolygon[6];
690

    
691
    float X1= (SQ5+1)/8;
692
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
693
    float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
694
    float H = 0.5f*MINX_C1/MINX_C3;
695
    float X2= H*MINX_C5;
696
    float Y3= H/(2*MINX_C4);
697
    float Y4= H*(1/(2*MINX_C4) - MINX_C4);
698

    
699
    float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
700
    float[] bands0 = computeBands(0.03f,39,0.3f,0.2f,5);
701
    float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 };
702
    float[] bands1 = computeBands(0.00f,27,0.25f,0.5f,2);
703

    
704
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
705
    meshes[0].setEffectAssociation(0, 1,0);
706
    meshes[1] = meshes[0].copy(true);
707
    meshes[1].setEffectAssociation(0, 2,0);
708
    meshes[2] = meshes[0].copy(true);
709
    meshes[2].setEffectAssociation(0, 4,0);
710
    meshes[3] = new MeshPolygon(vertices1, bands1, 0, 0);
711
    meshes[3].setEffectAssociation(0, 8,0);
712
    meshes[4] = meshes[3].copy(true);
713
    meshes[4].setEffectAssociation(0,16,0);
714
    meshes[5] = meshes[3].copy(true);
715
    meshes[5].setEffectAssociation(0,32,0);
716

    
717
    return new MeshJoined(meshes);
718
    }
719

    
720
///////////////////////////////////////////////////////////////////////////////////////////////////
721
// EFFECTS
722
///////////////////////////////////////////////////////////////////////////////////////////////////
723

    
724
  VertexEffect[] createVertexEffectsCube()
725
    {
726
    Static3D axisY   = new Static3D(0,1,0);
727
    Static3D axisX   = new Static3D(1,0,0);
728
    Static3D center  = new Static3D(0,0,0);
729
    Static1D angle90 = new Static1D(90);
730
    Static1D angle180= new Static1D(180);
731
    Static1D angle270= new Static1D(270);
732

    
733
    VertexEffect[] effect = new VertexEffect[6];
734

    
735
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
736
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
737
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
738
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
739
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
740
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
741

    
742
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
743
    effect[1].setMeshAssociation(32,-1);  // back
744
    effect[2].setMeshAssociation( 8,-1);  // bottom
745
    effect[3].setMeshAssociation( 4,-1);  // top
746
    effect[4].setMeshAssociation( 2,-1);  // left
747
    effect[5].setMeshAssociation( 1,-1);  // right
748

    
749
    return effect;
750
    }
751

    
752
///////////////////////////////////////////////////////////////////////////////////////////////////
753

    
754
  VertexEffect[] createVertexEffectsSkewbCorner()
755
    {
756
    float E = 0.5f;
757

    
758
    Static3D axisX  = new Static3D(1,0,0);
759
    Static3D axisY  = new Static3D(0,1,0);
760
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
761
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
762
    Static1D angle1 = new Static1D(+90);
763
    Static1D angle2 = new Static1D(-90);
764
    Static1D angle3 = new Static1D(-15);
765
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
766
    Static1D angle5 = new Static1D(120);
767
    Static1D angle6 = new Static1D(240);
768
    Static3D center1= new Static3D(0,0,0);
769
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
770
    Static3D move1  = new Static3D(-E/4,-E/4,0);
771
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
772

    
773
    VertexEffect[] effect = new VertexEffect[10];
774

    
775
    effect[0] = new VertexEffectMove(move1);
776
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
777
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
778
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
779
    effect[4] = new VertexEffectMove(move2);
780
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
781
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
782
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
783
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
784
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
785

    
786
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
787
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
788
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
789
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
790
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
791
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
792
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
793
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
794
    effect[8].setMeshAssociation(16,-1);  // mesh 4
795
    effect[9].setMeshAssociation(32,-1);  // mesh 5
796

    
797
    return effect;
798
    }
799

    
800
///////////////////////////////////////////////////////////////////////////////////////////////////
801

    
802
  VertexEffect[] createVertexEffectsSkewbFace()
803
    {
804
    Static3D center = new Static3D(0,0,0);
805
    Static3D axisX  = new Static3D(1,0,0);
806
    Static3D axisZ  = new Static3D(0,0,1);
807
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
808

    
809
    VertexEffect[] effect = new VertexEffect[6];
810

    
811
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
812
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
813
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
814
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
815
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
816
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
817

    
818
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
819
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
820
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
821
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
822
    effect[4].setMeshAssociation(16,-1);  // mesh 4
823
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
824

    
825
    return effect;
826
    }
827

    
828
///////////////////////////////////////////////////////////////////////////////////////////////////
829

    
830
  VertexEffect[] createVertexEffectsOcta()
831
    {
832
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
833
    Static1D angle1= new Static1D( 90);
834
    Static1D angle2= new Static1D(180);
835
    Static1D angle3= new Static1D(270);
836
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
837
    Static3D axisX = new Static3D(1,0,0);
838
    Static3D axisY = new Static3D(0,1,0);
839
    Static3D cent0 = new Static3D(0,0,0);
840
    Static3D cent1 = new Static3D(0,SQ2/2,0);
841
    Static3D flipY = new Static3D( 1,-1, 1);
842
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
843

    
844
    VertexEffect[] effect = new VertexEffect[7];
845

    
846
    effect[0] = new VertexEffectScale(scale);
847
    effect[1] = new VertexEffectMove(move1);
848
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
849
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
850
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
851
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
852
    effect[6] = new VertexEffectScale(flipY);
853

    
854
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
855
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
856
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
857
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
858

    
859
    return effect;
860
    }
861

    
862
///////////////////////////////////////////////////////////////////////////////////////////////////
863

    
864
  VertexEffect[] createVertexEffectsTetra()
865
    {
866
    Static3D flipZ = new Static3D( 1, 1,-1);
867
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
868
    Static1D angle1= new Static1D( 90);
869
    Static1D angle2= new Static1D(180);
870
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
871
    Static3D axisX = new Static3D(1,0,0);
872
    Static3D axisY = new Static3D(0,1,0);
873
    Static3D axisZ = new Static3D(0,0,1);
874
    Static3D cent0 = new Static3D(0,0,0);
875
    Static3D cent1 = new Static3D(0,SQ2/4,0);
876
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
877

    
878
    VertexEffect[] effect = new VertexEffect[7];
879

    
880
    effect[0] = new VertexEffectScale(scale);
881
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
882
    effect[2] = new VertexEffectMove(move1);
883
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
884
    effect[4] = new VertexEffectScale(flipZ);
885
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
886
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
887

    
888
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
889
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
890
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
891

    
892
    return effect;
893
    }
894

    
895
///////////////////////////////////////////////////////////////////////////////////////////////////
896

    
897
  VertexEffect[] createVertexEffectsDino()
898
    {
899
    float E = 0.5f*SQ2;
900
    float F = 0.5f;
901
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
902

    
903
    Static1D angle1 = new Static1D(-ANGLE);
904
    Static1D angle2 = new Static1D(+ANGLE);
905
    Static3D axisX  = new Static3D(1,0,0);
906
    Static3D axisY  = new Static3D(0,1,0);
907
    Static3D axisZ  = new Static3D(0,-1,1);
908
    Static3D center0= new Static3D(0,0,0);
909
    Static3D center1= new Static3D(0,-3*F,0);
910

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

    
913
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
914
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
915
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
916
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
917
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
918
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
919
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
920
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
921
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
922
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
923

    
924
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
925
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
926
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
927
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
928
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
929
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
930
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
931
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
932
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
933
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
934

    
935
    return effect;
936
    }
937

    
938
///////////////////////////////////////////////////////////////////////////////////////////////////
939

    
940
  VertexEffect[] createVertexEffectsHelicopterCorner()
941
    {
942
    float E = 0.5f;
943

    
944
    Static3D axisX  = new Static3D(1,0,0);
945
    Static3D axisY  = new Static3D(0,1,0);
946
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
947
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
948
    Static1D angle1 = new Static1D(+90);
949
    Static1D angle2 = new Static1D(-90);
950
    Static1D angle3 = new Static1D(-135);
951
    Static1D angle4 = new Static1D(90);
952
    Static1D angle5 = new Static1D(120);
953
    Static1D angle6 = new Static1D(240);
954
    Static3D center1= new Static3D(0,0,0);
955
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
956
    Static3D move1  = new Static3D(-E/4,-E/4,0);
957
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
958

    
959
    VertexEffect[] effect = new VertexEffect[10];
960

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

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

    
983
    return effect;
984
    }
985

    
986
///////////////////////////////////////////////////////////////////////////////////////////////////
987

    
988
  VertexEffect[] createVertexEffectsHelicopterFace()
989
    {
990
    float E = 0.5f;
991
    float F = SQ2/4;
992

    
993
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
994
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
995
    Static3D move2  = new Static3D(-E/2, F/3, 0);
996
    Static3D move3  = new Static3D(+E/2, F/3, 0);
997
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
998
    Static1D angle1 = new Static1D(135);
999
    Static1D angle2 = new Static1D(90);
1000
    Static1D angle3 = new Static1D(-90);
1001
    Static1D angle4 = new Static1D(-135);
1002
    Static3D axisX  = new Static3D(1,0,0);
1003
    Static3D axisY  = new Static3D(0,1,0);
1004
    Static3D axisZ  = new Static3D(0,0,1);
1005
    Static3D axis1  = new Static3D(1,-1,0);
1006
    Static3D center = new Static3D(0,0,0);
1007
    Static3D center1= new Static3D(-E/2,-E/2,0);
1008

    
1009
    VertexEffect[] effect = new VertexEffect[10];
1010

    
1011
    effect[0] = new VertexEffectMove(move0);
1012
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1013
    effect[2] = new VertexEffectMove(move1);
1014
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1015
    effect[4] = new VertexEffectMove(move2);
1016
    effect[5] = new VertexEffectMove(move3);
1017
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1018
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1019
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1020
    effect[9] = new VertexEffectMove(move4);
1021

    
1022
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1023
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1024
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1025
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1026
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1027
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1028
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1029
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1030
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1031
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1032

    
1033
    return effect;
1034
    }
1035

    
1036
///////////////////////////////////////////////////////////////////////////////////////////////////
1037

    
1038
  VertexEffect[] createVertexEffectsRediEdge()
1039
    {
1040
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1041
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1042
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1043
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1044
    Static3D flipZ = new Static3D(1,1,-1);
1045
    Static3D flipX = new Static3D(-1,1,1);
1046
    Static3D scale = new Static3D(2,2,2);
1047
    Static3D cent0 = new Static3D(0,0, 0);
1048
    Static3D cent1 = new Static3D(0,0, -1.5f);
1049
    Static3D axisX = new Static3D(1,0, 0);
1050
    Static3D axisY = new Static3D(0,1, 0);
1051
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1052
    Static1D angle1= new Static1D(90);
1053
    Static1D angle2= new Static1D(45);
1054
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1055

    
1056
    VertexEffect[] effect = new VertexEffect[12];
1057

    
1058
    effect[0] = new VertexEffectScale(scale);
1059
    effect[1] = new VertexEffectMove(move0);
1060
    effect[2] = new VertexEffectScale(flipZ);
1061
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1062
    effect[4] = new VertexEffectMove(move1);
1063
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1064
    effect[6] = new VertexEffectMove(move2);
1065
    effect[7] = new VertexEffectScale(flipX);
1066
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1067
    effect[9] = new VertexEffectMove(move3);
1068
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1069
    effect[11]= new VertexEffectScale(flipX);
1070

    
1071
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1072
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1073
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1074
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1075
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1076
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1077
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1078
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1079
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1080
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1081
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1082
    effect[11].setMeshAssociation(32,-1); // mesh 5
1083

    
1084
    return effect;
1085
    }
1086

    
1087
///////////////////////////////////////////////////////////////////////////////////////////////////
1088

    
1089
  VertexEffect[] createVertexEffectsRediCorner()
1090
    {
1091
    Static3D axisY   = new Static3D(0,1,0);
1092
    Static3D axisX   = new Static3D(1,0,0);
1093
    Static3D axisZ   = new Static3D(0,0,1);
1094
    Static3D center  = new Static3D(0,0,0);
1095
    Static1D angle90 = new Static1D(90);
1096
    Static1D angle270= new Static1D(270);
1097
    Static1D angle45 = new Static1D(-45);
1098
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1099

    
1100
    VertexEffect[] effect = new VertexEffect[7];
1101

    
1102
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1103
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1104
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1105
    effect[3] = new VertexEffectScale(scale);
1106
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1107
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1108
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1109

    
1110
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1111
    effect[1].setMeshAssociation( 2,-1);  // 1
1112
    effect[2].setMeshAssociation( 4,-1);  // 2
1113
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1114
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1115
    effect[5].setMeshAssociation(16,-1);  // 4
1116
    effect[6].setMeshAssociation(32,-1);  // 5
1117

    
1118
    return effect;
1119
    }
1120

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

    
1123
  VertexEffect[] createVertexEffectsIvyCorner()
1124
    {
1125
    Static3D axisX  = new Static3D(1,0,0);
1126
    Static3D axisY  = new Static3D(0,1,0);
1127
    Static1D angle1 = new Static1D(+90);
1128
    Static1D angle2 = new Static1D(-90);
1129
    Static3D center = new Static3D(0,0,0);
1130
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1131

    
1132
    VertexEffect[] effect = new VertexEffect[5];
1133

    
1134
    effect[0] = new VertexEffectScale(1/IVY_C);
1135
    effect[1] = new VertexEffectMove(move1);
1136
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1137
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1138
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1139

    
1140
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1141
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1142
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1143

    
1144
    return effect;
1145
    }
1146

    
1147
///////////////////////////////////////////////////////////////////////////////////////////////////
1148

    
1149
  VertexEffect[] createVertexEffectsRexEdge()
1150
    {
1151
    float E = 0.5f - REX_D;
1152
    float F = 0.5f;
1153
    float G = (float)Math.sqrt(E*E+F*F);
1154
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1155

    
1156
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1157
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1158

    
1159
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1160
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1161
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1162
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1163
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1164
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1165

    
1166
    Static1D angle180 = new Static1D(180);
1167
    Static1D angle90  = new Static1D( 90);
1168
    Static1D angle270 = new Static1D(270);
1169
    Static1D angle1   = new Static1D(+A);
1170
    Static1D angle2   = new Static1D(-A);
1171

    
1172
    VertexEffect[] effect = new VertexEffect[12];
1173

    
1174
    effect[0] = new VertexEffectMove(move1);
1175
    effect[1] = new VertexEffectMove(move2);
1176
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1177
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1178
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1179
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1180
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1181
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1182
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1183
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1184
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1185
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1186

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

    
1200
    return effect;
1201
    }
1202

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

    
1205
  VertexEffect[] createVertexEffectsRexCorner()
1206
    {
1207
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1208
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1209
    Static1D angle = new Static1D(225);
1210

    
1211
    VertexEffect[] effect = new VertexEffect[1];
1212
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1213

    
1214
    return effect;
1215
    }
1216

    
1217
///////////////////////////////////////////////////////////////////////////////////////////////////
1218

    
1219
  VertexEffect[] createVertexEffectsMinxCorner()
1220
    {
1221
    VertexEffect[] effect = new VertexEffect[9];
1222

    
1223
    float H = 0.5f*(MINX_C1/MINX_C3);
1224
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1225
    float Y2= H/(2*MINX_C4);
1226
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1227
    float sin18 = MINX_C0;
1228
    float cos18 = (float)(Math.sqrt(1-MINX_C0*MINX_C0));
1229
    float LEN   = (float)Math.sqrt(H*H/(MINX_C4*MINX_C4) + 0.25f);
1230

    
1231
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1232
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1233
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1234
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*MINX_C5/(MINX_C4*LEN));
1235

    
1236
    Static3D move1 = new Static3D(0,-Y1,0);
1237
    Static3D move2 = new Static3D(0,-Y2,0);
1238
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1239
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1240

    
1241
    Static1D angle1 = new Static1D(54);
1242
    Static1D angle2 = new Static1D(A/2+18);
1243
    Static1D angle3 = new Static1D(90);
1244
    Static1D angle4 = new Static1D(120);
1245
    Static1D angle5 = new Static1D(240);
1246
    Static1D angle6 = new Static1D(90-A/2);
1247

    
1248
    effect[0] = new VertexEffectMove(move1);
1249
    effect[1] = new VertexEffectMove(move2);
1250
    effect[2] = new VertexEffectRotate(angle1, axisZ, center);
1251
    effect[3] = new VertexEffectRotate(angle2, axisZ, center);
1252
    effect[4] = new VertexEffectRotate(angle3, axisA, center);
1253
    effect[5] = new VertexEffectMove(move3);
1254
    effect[6] = new VertexEffectRotate(angle4, axisC, center);
1255
    effect[7] = new VertexEffectRotate(angle5, axisC, center);
1256
    effect[8] = new VertexEffectRotate(angle6, axisY, center);
1257

    
1258
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1259
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1260
    effect[2].setMeshAssociation( 7,-1);  // meshes 0,1,2
1261
    effect[3].setMeshAssociation(56,-1);  // meshes 3,4,5
1262
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1263
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1264
    effect[6].setMeshAssociation(18,-1);  // meshes 1,4
1265
    effect[7].setMeshAssociation(36,-1);  // meshes 2,5
1266

    
1267
    return effect;
1268
    }
1269

    
1270
///////////////////////////////////////////////////////////////////////////////////////////////////
1271
// OBJECTS
1272
///////////////////////////////////////////////////////////////////////////////////////////////////
1273
// CUBE
1274

    
1275
  MeshBase createCubeMesh(int index)
1276
    {
1277
    MeshBase mesh = createFacesCube(index);
1278
    VertexEffect[] effects = createVertexEffectsCube();
1279
    for( VertexEffect effect : effects ) mesh.apply(effect);
1280

    
1281
    Static3D roundingCenter  = new Static3D(0,0,0);
1282
    Static3D[] vertices = new Static3D[8];
1283
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1284
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1285
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1286
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1287
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1288
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1289
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1290
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1291

    
1292
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1293

    
1294
    mesh.mergeEffComponents();
1295

    
1296
    return mesh;
1297
    }
1298

    
1299
///////////////////////////////////////////////////////////////////////////////////////////////////
1300
// SKEWB
1301

    
1302
  MeshBase createSkewbCornerMesh()
1303
    {
1304
    MeshBase mesh = createFacesSkewbCorner();
1305
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1306
    for( VertexEffect effect : effects ) mesh.apply(effect);
1307

    
1308
    float E = 0.5f;
1309
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1310

    
1311
    Static3D[] verticesType1 = new Static3D[1];
1312
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1313
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1314

    
1315
    Static3D[] verticesType2 = new Static3D[3];
1316
    verticesType2[0] = new Static3D(-E, 0, 0);
1317
    verticesType2[1] = new Static3D( 0,-E, 0);
1318
    verticesType2[2] = new Static3D( 0, 0,-E);
1319
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1320

    
1321
    mesh.mergeEffComponents();
1322

    
1323
    return mesh;
1324
    }
1325

    
1326
///////////////////////////////////////////////////////////////////////////////////////////////////
1327

    
1328
  MeshBase createSkewbFaceMesh()
1329
    {
1330
    MeshBase mesh = createFacesSkewbFace();
1331
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1332
    for( VertexEffect effect : effects ) mesh.apply(effect);
1333

    
1334
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1335
    float E = SQ2/4;
1336
    Static3D[] vertices = new Static3D[4];
1337
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1338
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1339
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1340
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1341
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1342

    
1343
    mesh.mergeEffComponents();
1344
    mesh.addEmptyTexComponent();
1345

    
1346
    return mesh;
1347
    }
1348

    
1349
///////////////////////////////////////////////////////////////////////////////////////////////////
1350
// SKEWB DIAMOND / PYRAMINX
1351

    
1352
  MeshBase createOctaMesh()
1353
    {
1354
    MeshBase mesh = createFacesOcta();
1355
    VertexEffect[] effects = createVertexEffectsOcta();
1356
    for( VertexEffect effect : effects ) mesh.apply(effect);
1357

    
1358
    Static3D roundingCenter = new Static3D(0,0,0);
1359
    Static3D[] vertices = new Static3D[6];
1360
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1361
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1362
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1363
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1364
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1365
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1366

    
1367
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1368

    
1369
    mesh.mergeEffComponents();
1370

    
1371
    return mesh;
1372
    }
1373

    
1374
///////////////////////////////////////////////////////////////////////////////////////////////////
1375

    
1376
  MeshBase createTetraMesh()
1377
    {
1378
    MeshBase mesh = createFacesTetra();
1379
    VertexEffect[] effects = createVertexEffectsTetra();
1380
    for( VertexEffect effect : effects ) mesh.apply(effect);
1381

    
1382
    Static3D roundingCenter = new Static3D(0,0,0);
1383
    Static3D[] verticesRound = new Static3D[4];
1384
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1385
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1386
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1387
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1388
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1389

    
1390
    mesh.mergeEffComponents();
1391
    mesh.addEmptyTexComponent();
1392
    mesh.addEmptyTexComponent();
1393
    mesh.addEmptyTexComponent();
1394
    mesh.addEmptyTexComponent();
1395

    
1396
    return mesh;
1397
    }
1398

    
1399
///////////////////////////////////////////////////////////////////////////////////////////////////
1400
// DINO
1401

    
1402
  MeshBase createDinoMesh()
1403
    {
1404
    MeshBase mesh = createFacesDino();
1405
    VertexEffect[] effects = createVertexEffectsDino();
1406
    for( VertexEffect effect : effects ) mesh.apply(effect);
1407

    
1408
    float F = 0.5f;
1409
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1410
    Static3D[] verticesRound = new Static3D[4];
1411
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1412
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1413
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1414
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1415
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1416

    
1417
    mesh.mergeEffComponents();
1418

    
1419
    return mesh;
1420
    }
1421

    
1422
///////////////////////////////////////////////////////////////////////////////////////////////////
1423
// Helicopter
1424

    
1425
  MeshBase createHelicopterCornerMesh()
1426
    {
1427
    MeshBase mesh = createFacesHelicopterCorner();
1428
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1429
    for( VertexEffect effect : effects ) mesh.apply(effect);
1430

    
1431
    float E = 0.5f;
1432
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1433

    
1434
    Static3D[] verticesType1 = new Static3D[1];
1435
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1436
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1437

    
1438
    Static3D[] verticesType2 = new Static3D[3];
1439
    verticesType2[0] = new Static3D(-E, 0, 0);
1440
    verticesType2[1] = new Static3D( 0,-E, 0);
1441
    verticesType2[2] = new Static3D( 0, 0,-E);
1442
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1443

    
1444
    mesh.mergeEffComponents();
1445

    
1446
    return mesh;
1447
    }
1448

    
1449
///////////////////////////////////////////////////////////////////////////////////////////////////
1450

    
1451
  MeshBase createHelicopterFaceMesh()
1452
    {
1453
    MeshBase mesh = createFacesHelicopterFace();
1454
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1455
    for( VertexEffect effect : effects ) mesh.apply(effect);
1456

    
1457
    float E = 0.5f;
1458
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1459

    
1460
    Static3D[] verticesType1 = new Static3D[1];
1461
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1462
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1463

    
1464
    Static3D[] verticesType2 = new Static3D[2];
1465
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1466
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1467
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1468

    
1469
    mesh.mergeEffComponents();
1470
    mesh.addEmptyTexComponent();
1471
    mesh.addEmptyTexComponent();
1472

    
1473
    return mesh;
1474
    }
1475

    
1476
///////////////////////////////////////////////////////////////////////////////////////////////////
1477
// Redi cube
1478

    
1479
  MeshBase createRediEdgeMesh()
1480
    {
1481
    MeshBase mesh = createFacesRediEdge();
1482
    VertexEffect[] effects = createVertexEffectsRediEdge();
1483
    for( VertexEffect effect : effects ) mesh.apply(effect);
1484

    
1485
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1486
    Static3D[] vertices = new Static3D[2];
1487
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1488
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1489
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1490

    
1491
    mesh.mergeEffComponents();
1492

    
1493
    return mesh;
1494
    }
1495

    
1496
///////////////////////////////////////////////////////////////////////////////////////////////////
1497

    
1498
  MeshBase createRediCornerMesh()
1499
    {
1500
    MeshBase mesh = createFacesRediCorner();
1501
    VertexEffect[] effects = createVertexEffectsRediCorner();
1502
    for( VertexEffect effect : effects ) mesh.apply(effect);
1503

    
1504
    Static3D center = new Static3D(0,0,0);
1505
    Static3D[] vertices = new Static3D[8];
1506
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1507
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1508
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1509
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1510
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1511
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1512
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1513
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1514

    
1515
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1516

    
1517
    mesh.mergeEffComponents();
1518

    
1519
    return mesh;
1520
    }
1521

    
1522
///////////////////////////////////////////////////////////////////////////////////////////////////
1523

    
1524
  MeshBase createIvyCornerMesh()
1525
    {
1526
    MeshBase mesh = createFacesIvyCorner();
1527
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1528
    for( VertexEffect effect : effects ) mesh.apply(effect);
1529

    
1530
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1531
    Static3D[] vertices = new Static3D[4];
1532
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1533
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1534
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1535
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1536

    
1537
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1538

    
1539
    mesh.mergeEffComponents();
1540

    
1541
    return mesh;
1542
    }
1543

    
1544
///////////////////////////////////////////////////////////////////////////////////////////////////
1545

    
1546
  MeshBase createIvyFaceMesh()
1547
    {
1548
    MeshBase mesh = createFacesIvyFace();
1549

    
1550
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1551
    Static3D[] vertices = new Static3D[2];
1552
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1553
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1554

    
1555
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1556

    
1557
    mesh.mergeEffComponents();
1558
    mesh.addEmptyTexComponent();
1559
    mesh.addEmptyTexComponent();
1560
    mesh.addEmptyTexComponent();
1561
    mesh.addEmptyTexComponent();
1562

    
1563
    return mesh;
1564
    }
1565

    
1566
///////////////////////////////////////////////////////////////////////////////////////////////////
1567

    
1568
  MeshBase createRexCornerMesh()
1569
    {
1570
    MeshBase mesh = createFacesRexCorner();
1571
    VertexEffect[] effects = createVertexEffectsRexCorner();
1572
    for( VertexEffect effect : effects ) mesh.apply(effect);
1573

    
1574
    final float G = (1-REX_D)/3;
1575
    Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
1576
    Static3D[] vertices = new Static3D[1];
1577
    vertices[0] = new Static3D(+G,-G,+0.0f);
1578
    roundCorners(mesh,center,vertices,0.10f,0.10f);
1579

    
1580
    mesh.mergeEffComponents();
1581
    mesh.addEmptyTexComponent();
1582
    mesh.addEmptyTexComponent();
1583
    mesh.addEmptyTexComponent();
1584
    mesh.addEmptyTexComponent();
1585

    
1586
    return mesh;
1587
    }
1588

    
1589
///////////////////////////////////////////////////////////////////////////////////////////////////
1590

    
1591
  MeshBase createRexFaceMesh()
1592
    {
1593
    MeshBase mesh = createFacesRexFace();
1594

    
1595
    mesh.mergeEffComponents();
1596
    mesh.addEmptyTexComponent();
1597
    mesh.addEmptyTexComponent();
1598
    mesh.addEmptyTexComponent();
1599
    mesh.addEmptyTexComponent();
1600

    
1601
    return mesh;
1602
    }
1603

    
1604
///////////////////////////////////////////////////////////////////////////////////////////////////
1605

    
1606
  MeshBase createRexEdgeMesh()
1607
    {
1608
    MeshBase mesh = createFacesRexEdge();
1609
    VertexEffect[] effects = createVertexEffectsRexEdge();
1610
    for( VertexEffect effect : effects ) mesh.apply(effect);
1611

    
1612
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1613
    Static3D[] vertices = new Static3D[2];
1614
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1615
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1616
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1617

    
1618
    mesh.mergeEffComponents();
1619

    
1620
    return mesh;
1621
    }
1622

    
1623
///////////////////////////////////////////////////////////////////////////////////////////////////
1624

    
1625
  MeshBase createMinxCornerMesh()
1626
    {
1627
    MeshBase mesh = createFacesMinxCorner();
1628
    VertexEffect[] effects = createVertexEffectsMinxCorner();
1629
    for( VertexEffect effect : effects ) mesh.apply(effect);
1630
/*
1631
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1632
    Static3D[] vertices = new Static3D[2];
1633
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1634
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1635
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1636
*/
1637
    mesh.mergeEffComponents();
1638

    
1639
    return mesh;
1640
    }
1641
  }
(2-2/28)