Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ b1dea8dd

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
  static final float MINX_SC = 0.5f;
54

    
55
  private static final int IVY_N = 8;
56

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

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

    
62
  private FactoryCubit()
63
    {
64

    
65
    }
66

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

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

    
73
    return mThis;
74
    }
75

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

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

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

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

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

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

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

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

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

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

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

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

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

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

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

    
181
    return bands;
182
    }
183

    
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185

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

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

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

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

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

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

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

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

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

    
225
///////////////////////////////////////////////////////////////////////////////////////////////////
226

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

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

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

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

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

    
258
    return new MeshJoined(meshes);
259
    }
260

    
261
///////////////////////////////////////////////////////////////////////////////////////////////////
262

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

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

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

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

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

    
290
    return new MeshJoined(meshes);
291
    }
292

    
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294

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

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

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

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

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

    
318
    return new MeshJoined(meshes);
319
    }
320

    
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322

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

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

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

    
349
    return new MeshJoined(meshes);
350
    }
351

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353

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

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

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

    
372
    return new MeshJoined(meshes);
373
    }
374

    
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376

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

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

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

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

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

    
399
    return new MeshJoined(meshes);
400
    }
401

    
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403

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

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

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

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

    
430
    return new MeshJoined(meshes);
431
    }
432

    
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434

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

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

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

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

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

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

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

    
461
    return new MeshJoined(meshes);
462
    }
463

    
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465

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

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

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

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

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

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

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

    
496
    return new MeshJoined(meshes);
497
    }
498

    
499
///////////////////////////////////////////////////////////////////////////////////////////////////
500

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

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

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

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

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

    
529
    return new MeshJoined(meshes);
530
    }
531

    
532
///////////////////////////////////////////////////////////////////////////////////////////////////
533

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

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

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

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

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

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

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

    
576
    return new MeshJoined(meshes);
577
    }
578

    
579
///////////////////////////////////////////////////////////////////////////////////////////////////
580

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

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

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

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

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

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

    
608
    return new MeshJoined(meshes);
609
    }
610

    
611
///////////////////////////////////////////////////////////////////////////////////////////////////
612

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

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

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

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

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

    
632
    return new MeshJoined(meshes);
633
    }
634

    
635
///////////////////////////////////////////////////////////////////////////////////////////////////
636

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

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

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

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

    
651
    return new MeshJoined(meshes);
652
    }
653

    
654
///////////////////////////////////////////////////////////////////////////////////////////////////
655

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

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

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

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

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

    
683
    return new MeshJoined(meshes);
684
    }
685

    
686
///////////////////////////////////////////////////////////////////////////////////////////////////
687

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

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

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

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

    
718
    return new MeshJoined(meshes);
719
    }
720

    
721
///////////////////////////////////////////////////////////////////////////////////////////////////
722
// EFFECTS
723
///////////////////////////////////////////////////////////////////////////////////////////////////
724

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

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

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

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

    
750
    return effect;
751
    }
752

    
753
///////////////////////////////////////////////////////////////////////////////////////////////////
754

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

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

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

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

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

    
798
    return effect;
799
    }
800

    
801
///////////////////////////////////////////////////////////////////////////////////////////////////
802

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

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

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

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

    
826
    return effect;
827
    }
828

    
829
///////////////////////////////////////////////////////////////////////////////////////////////////
830

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

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

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

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

    
860
    return effect;
861
    }
862

    
863
///////////////////////////////////////////////////////////////////////////////////////////////////
864

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

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

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

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

    
893
    return effect;
894
    }
895

    
896
///////////////////////////////////////////////////////////////////////////////////////////////////
897

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

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

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

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

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

    
936
    return effect;
937
    }
938

    
939
///////////////////////////////////////////////////////////////////////////////////////////////////
940

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

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

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

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

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

    
984
    return effect;
985
    }
986

    
987
///////////////////////////////////////////////////////////////////////////////////////////////////
988

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

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

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

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

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

    
1034
    return effect;
1035
    }
1036

    
1037
///////////////////////////////////////////////////////////////////////////////////////////////////
1038

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

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

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

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

    
1085
    return effect;
1086
    }
1087

    
1088
///////////////////////////////////////////////////////////////////////////////////////////////////
1089

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

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

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

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

    
1119
    return effect;
1120
    }
1121

    
1122
///////////////////////////////////////////////////////////////////////////////////////////////////
1123

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

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

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

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

    
1145
    return effect;
1146
    }
1147

    
1148
///////////////////////////////////////////////////////////////////////////////////////////////////
1149

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

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

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

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

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

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

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

    
1201
    return effect;
1202
    }
1203

    
1204
///////////////////////////////////////////////////////////////////////////////////////////////////
1205

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

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

    
1215
    return effect;
1216
    }
1217

    
1218
///////////////////////////////////////////////////////////////////////////////////////////////////
1219

    
1220
  VertexEffect[] createVertexEffectsMinxCorner()
1221
    {
1222
    VertexEffect[] effect = new VertexEffect[10];
1223

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

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

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

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

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

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

    
1270
    return effect;
1271
    }
1272

    
1273
///////////////////////////////////////////////////////////////////////////////////////////////////
1274
// OBJECTS
1275
///////////////////////////////////////////////////////////////////////////////////////////////////
1276
// CUBE
1277

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

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

    
1295
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1296

    
1297
    mesh.mergeEffComponents();
1298

    
1299
    return mesh;
1300
    }
1301

    
1302
///////////////////////////////////////////////////////////////////////////////////////////////////
1303
// SKEWB
1304

    
1305
  MeshBase createSkewbCornerMesh()
1306
    {
1307
    MeshBase mesh = createFacesSkewbCorner();
1308
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1309
    for( VertexEffect effect : effects ) mesh.apply(effect);
1310

    
1311
    float E = 0.5f;
1312
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1313

    
1314
    Static3D[] verticesType1 = new Static3D[1];
1315
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1316
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1317

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

    
1324
    mesh.mergeEffComponents();
1325

    
1326
    return mesh;
1327
    }
1328

    
1329
///////////////////////////////////////////////////////////////////////////////////////////////////
1330

    
1331
  MeshBase createSkewbFaceMesh()
1332
    {
1333
    MeshBase mesh = createFacesSkewbFace();
1334
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1335
    for( VertexEffect effect : effects ) mesh.apply(effect);
1336

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

    
1346
    mesh.mergeEffComponents();
1347
    mesh.addEmptyTexComponent();
1348

    
1349
    return mesh;
1350
    }
1351

    
1352
///////////////////////////////////////////////////////////////////////////////////////////////////
1353
// SKEWB DIAMOND / PYRAMINX
1354

    
1355
  MeshBase createOctaMesh()
1356
    {
1357
    MeshBase mesh = createFacesOcta();
1358
    VertexEffect[] effects = createVertexEffectsOcta();
1359
    for( VertexEffect effect : effects ) mesh.apply(effect);
1360

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

    
1370
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1371

    
1372
    mesh.mergeEffComponents();
1373

    
1374
    return mesh;
1375
    }
1376

    
1377
///////////////////////////////////////////////////////////////////////////////////////////////////
1378

    
1379
  MeshBase createTetraMesh()
1380
    {
1381
    MeshBase mesh = createFacesTetra();
1382
    VertexEffect[] effects = createVertexEffectsTetra();
1383
    for( VertexEffect effect : effects ) mesh.apply(effect);
1384

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

    
1393
    mesh.mergeEffComponents();
1394
    mesh.addEmptyTexComponent();
1395
    mesh.addEmptyTexComponent();
1396
    mesh.addEmptyTexComponent();
1397
    mesh.addEmptyTexComponent();
1398

    
1399
    return mesh;
1400
    }
1401

    
1402
///////////////////////////////////////////////////////////////////////////////////////////////////
1403
// DINO
1404

    
1405
  MeshBase createDinoMesh()
1406
    {
1407
    MeshBase mesh = createFacesDino();
1408
    VertexEffect[] effects = createVertexEffectsDino();
1409
    for( VertexEffect effect : effects ) mesh.apply(effect);
1410

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

    
1420
    mesh.mergeEffComponents();
1421

    
1422
    return mesh;
1423
    }
1424

    
1425
///////////////////////////////////////////////////////////////////////////////////////////////////
1426
// Helicopter
1427

    
1428
  MeshBase createHelicopterCornerMesh()
1429
    {
1430
    MeshBase mesh = createFacesHelicopterCorner();
1431
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1432
    for( VertexEffect effect : effects ) mesh.apply(effect);
1433

    
1434
    float E = 0.5f;
1435
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1436

    
1437
    Static3D[] verticesType1 = new Static3D[1];
1438
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1439
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1440

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

    
1447
    mesh.mergeEffComponents();
1448

    
1449
    return mesh;
1450
    }
1451

    
1452
///////////////////////////////////////////////////////////////////////////////////////////////////
1453

    
1454
  MeshBase createHelicopterFaceMesh()
1455
    {
1456
    MeshBase mesh = createFacesHelicopterFace();
1457
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1458
    for( VertexEffect effect : effects ) mesh.apply(effect);
1459

    
1460
    float E = 0.5f;
1461
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1462

    
1463
    Static3D[] verticesType1 = new Static3D[1];
1464
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1465
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1466

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

    
1472
    mesh.mergeEffComponents();
1473
    mesh.addEmptyTexComponent();
1474
    mesh.addEmptyTexComponent();
1475

    
1476
    return mesh;
1477
    }
1478

    
1479
///////////////////////////////////////////////////////////////////////////////////////////////////
1480
// Redi cube
1481

    
1482
  MeshBase createRediEdgeMesh()
1483
    {
1484
    MeshBase mesh = createFacesRediEdge();
1485
    VertexEffect[] effects = createVertexEffectsRediEdge();
1486
    for( VertexEffect effect : effects ) mesh.apply(effect);
1487

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

    
1494
    mesh.mergeEffComponents();
1495

    
1496
    return mesh;
1497
    }
1498

    
1499
///////////////////////////////////////////////////////////////////////////////////////////////////
1500

    
1501
  MeshBase createRediCornerMesh()
1502
    {
1503
    MeshBase mesh = createFacesRediCorner();
1504
    VertexEffect[] effects = createVertexEffectsRediCorner();
1505
    for( VertexEffect effect : effects ) mesh.apply(effect);
1506

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

    
1518
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1519

    
1520
    mesh.mergeEffComponents();
1521

    
1522
    return mesh;
1523
    }
1524

    
1525
///////////////////////////////////////////////////////////////////////////////////////////////////
1526

    
1527
  MeshBase createIvyCornerMesh()
1528
    {
1529
    MeshBase mesh = createFacesIvyCorner();
1530
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1531
    for( VertexEffect effect : effects ) mesh.apply(effect);
1532

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

    
1540
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1541

    
1542
    mesh.mergeEffComponents();
1543

    
1544
    return mesh;
1545
    }
1546

    
1547
///////////////////////////////////////////////////////////////////////////////////////////////////
1548

    
1549
  MeshBase createIvyFaceMesh()
1550
    {
1551
    MeshBase mesh = createFacesIvyFace();
1552

    
1553
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1554
    Static3D[] vertices = new Static3D[2];
1555
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1556
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1557

    
1558
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1559

    
1560
    mesh.mergeEffComponents();
1561
    mesh.addEmptyTexComponent();
1562
    mesh.addEmptyTexComponent();
1563
    mesh.addEmptyTexComponent();
1564
    mesh.addEmptyTexComponent();
1565

    
1566
    return mesh;
1567
    }
1568

    
1569
///////////////////////////////////////////////////////////////////////////////////////////////////
1570

    
1571
  MeshBase createRexCornerMesh()
1572
    {
1573
    MeshBase mesh = createFacesRexCorner();
1574
    VertexEffect[] effects = createVertexEffectsRexCorner();
1575
    for( VertexEffect effect : effects ) mesh.apply(effect);
1576

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

    
1583
    mesh.mergeEffComponents();
1584
    mesh.addEmptyTexComponent();
1585
    mesh.addEmptyTexComponent();
1586
    mesh.addEmptyTexComponent();
1587
    mesh.addEmptyTexComponent();
1588

    
1589
    return mesh;
1590
    }
1591

    
1592
///////////////////////////////////////////////////////////////////////////////////////////////////
1593

    
1594
  MeshBase createRexFaceMesh()
1595
    {
1596
    MeshBase mesh = createFacesRexFace();
1597

    
1598
    mesh.mergeEffComponents();
1599
    mesh.addEmptyTexComponent();
1600
    mesh.addEmptyTexComponent();
1601
    mesh.addEmptyTexComponent();
1602
    mesh.addEmptyTexComponent();
1603

    
1604
    return mesh;
1605
    }
1606

    
1607
///////////////////////////////////////////////////////////////////////////////////////////////////
1608

    
1609
  MeshBase createRexEdgeMesh()
1610
    {
1611
    MeshBase mesh = createFacesRexEdge();
1612
    VertexEffect[] effects = createVertexEffectsRexEdge();
1613
    for( VertexEffect effect : effects ) mesh.apply(effect);
1614

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

    
1621
    mesh.mergeEffComponents();
1622

    
1623
    return mesh;
1624
    }
1625

    
1626
///////////////////////////////////////////////////////////////////////////////////////////////////
1627

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

    
1642
    return mesh;
1643
    }
1644
  }
(2-2/28)