Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 72b93c08

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.003f;
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 SQ6 = (float)Math.sqrt(6);
46

    
47
  private static final int IVY_N = 8;
48
  private static final int REX_N = 5;
49
  private static final Static1D RADIUS = new Static1D(1);
50
  private static FactoryCubit mThis;
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  private FactoryCubit()
55
    {
56

    
57
    }
58

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

    
61
  public static FactoryCubit getInstance()
62
    {
63
    if( mThis==null ) mThis = new FactoryCubit();
64

    
65
    return mThis;
66
    }
67

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

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  private float f(float D, float B, float x)
106
    {
107
    return ((D-B)*x + B*(1-D))/(1-B);
108
    }
109

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

    
112
  private float g(float R, float D, float x, float cosAlpha)
113
    {
114
    float d = x-D;
115
    return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
116
    }
117

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

    
120
  private float h(float R, float sinAlpha, float x)
121
    {
122
    return R*(sinAlpha-(float)Math.sin(x));
123
    }
124

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

    
127
  private float[] computeBands(float H, int alpha, float dist, float K, int N)
128
    {
129
    float[] bands = new float[2*N];
130

    
131
    bands[0] = 1.0f;
132
    bands[1] = 0.0f;
133

    
134
    float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
135
    float sinBeta = (float)Math.sin(beta);
136
    float cosBeta = (float)Math.cos(beta);
137
    float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
138
    float D = R*sinBeta;
139
    float B = h(R,sinBeta,K*beta);
140

    
141
    if( D>1.0f )
142
      {
143
      for(int i=1; i<N; i++)
144
        {
145
        bands[2*i  ] = (float)(N-1-i)/(N-1);
146
        bands[2*i+1] = H*(1-bands[2*i]);
147
        }
148
      }
149
    else
150
      {
151
      int K2 = (int)((N-3)*K);
152
      int K1 = (N-3)-K2;
153

    
154
      for(int i=0; i<=K1; i++)
155
        {
156
        float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
157
        float x = h(R,sinBeta,angle);
158
        bands[2*i+2] = 1.0f - x;
159
        bands[2*i+3] = g(R,D,x,cosBeta);
160
        }
161

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

    
170
    bands[2*N-2] = 0.0f;
171
    bands[2*N-1] =    H;
172

    
173
    return bands;
174
    }
175

    
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177

    
178
  private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
179
    {
180
    Static4D reg= new Static4D(0,0,0,regionRadius);
181

    
182
    float centX = center.get0();
183
    float centY = center.get1();
184
    float centZ = center.get2();
185

    
186
    for (Static3D vertex : vertices)
187
      {
188
      float x = strength*(centX - vertex.get0());
189
      float y = strength*(centY - vertex.get1());
190
      float z = strength*(centZ - vertex.get2());
191

    
192
      VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
193
      mesh.apply(effect);
194
      }
195
    }
196

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

    
202
  private void writeVertex( float cx, float cy, float px, float py, float radians, float[] array, int index)
203
    {
204
    float vx = px-cx;
205
    float vy = py-cy;
206

    
207
    float sinA = (float)Math.sin(radians);
208
    float cosA = (float)Math.cos(radians);
209

    
210
    float rvx = vx*cosA - vy*sinA;
211
    float rvy = vx*sinA + vy*cosA;
212

    
213
    array[index  ] = rvx + cx;
214
    array[index+1] = rvy + cy;
215
    }
216

    
217
///////////////////////////////////////////////////////////////////////////////////////////////////
218

    
219
  MeshBase createFacesCube(int sizeIndex)
220
    {
221
    MeshBase[] meshes = new MeshPolygon[6];
222

    
223
    float E = 0.5f;
224
    int extraI, extraV, num;
225

    
226
    switch(sizeIndex)
227
      {
228
      case 0 : num = 6; extraI = 2; extraV = 2; break;
229
      case 1 : num = 5; extraI = 2; extraV = 2; break;
230
      case 2 : num = 5; extraI = 1; extraV = 2; break;
231
      default: num = 4; extraI = 1; extraV = 1; break;
232
      }
233

    
234
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
235
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
236

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

    
250
    return new MeshJoined(meshes);
251
    }
252

    
253
///////////////////////////////////////////////////////////////////////////////////////////////////
254

    
255
  MeshBase createFacesSkewbCorner()
256
    {
257
    MeshBase[] meshes = new MeshBase[6];
258

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

    
265
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
266
    meshes[0].setEffectAssociation(0,1,0);
267
    meshes[1] = meshes[0].copy(true);
268
    meshes[1].setEffectAssociation(0,2,0);
269
    meshes[2] = meshes[0].copy(true);
270
    meshes[2].setEffectAssociation(0,4,0);
271

    
272
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
273
    float[] bands1 = computeBands(0,0,1,0,3);
274

    
275
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
276
    meshes[3].setEffectAssociation(0,8,0);
277
    meshes[4] = meshes[3].copy(true);
278
    meshes[4].setEffectAssociation(0,16,0);
279
    meshes[5] = meshes[3].copy(true);
280
    meshes[5].setEffectAssociation(0,32,0);
281

    
282
    return new MeshJoined(meshes);
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  MeshBase createFacesSkewbFace()
288
    {
289
    MeshBase[] meshes = new MeshBase[5];
290

    
291
    float E = SQ2/4;
292
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
293
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
294

    
295
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
296
    meshes[0].setEffectAssociation(0,1,0);
297

    
298
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
299
    float[] bands1 = computeBands(0,0,1,0,3);
300

    
301
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
302
    meshes[1].setEffectAssociation(0,2,0);
303
    meshes[2] = meshes[1].copy(true);
304
    meshes[2].setEffectAssociation(0,4,0);
305
    meshes[3] = meshes[1].copy(true);
306
    meshes[3].setEffectAssociation(0,8,0);
307
    meshes[4] = meshes[1].copy(true);
308
    meshes[4].setEffectAssociation(0,16,0);
309

    
310
    return new MeshJoined(meshes);
311
    }
312

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

    
315
  MeshBase createFacesOcta()
316
    {
317
    MeshBase[] meshes = new MeshPolygon[8];
318

    
319
    float E = 0.75f;
320
    float F = 0.5f;
321
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
322
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
323

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

    
341
    return new MeshJoined(meshes);
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

    
346
  MeshBase createFacesTetra()
347
    {
348
    MeshBase[] meshes = new MeshBase[4];
349

    
350
    float E = 0.75f;
351
    float F = 0.5f;
352
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
353
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
354

    
355
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
356
    meshes[0].setEffectAssociation(0,1,0);
357
    meshes[1] = meshes[0].copy(true);
358
    meshes[1].setEffectAssociation(0,2,0);
359
    meshes[2] = meshes[0].copy(true);
360
    meshes[2].setEffectAssociation(0,4,0);
361
    meshes[3] = meshes[0].copy(true);
362
    meshes[3].setEffectAssociation(0,8,0);
363

    
364
    return new MeshJoined(meshes);
365
    }
366

    
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368

    
369
  MeshBase createFacesDino()
370
    {
371
    MeshBase[] meshes = new MeshPolygon[4];
372

    
373
    float E = 0.5f*SQ2;
374
    float F = 0.5f;
375
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
376
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
377

    
378
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
379
    meshes[0].setEffectAssociation(0,1,0);
380
    meshes[1] = meshes[0].copy(true);
381
    meshes[1].setEffectAssociation(0,2,0);
382

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

    
386
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
387
    meshes[2].setEffectAssociation(0,4,0);
388
    meshes[3] = meshes[2].copy(true);
389
    meshes[3].setEffectAssociation(0,8,0);
390

    
391
    return new MeshJoined(meshes);
392
    }
393

    
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395

    
396
  MeshBase createFacesHelicopterCorner()
397
    {
398
    MeshBase[] meshes = new MeshBase[6];
399

    
400
    float E = 0.5f;
401
    float F = SQ2/4;
402
    float G = 1.0f/12;
403
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
404
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
405

    
406
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
407
    meshes[0].setEffectAssociation(0,1,0);
408
    meshes[1] = meshes[0].copy(true);
409
    meshes[1].setEffectAssociation(0,2,0);
410
    meshes[2] = meshes[0].copy(true);
411
    meshes[2].setEffectAssociation(0,4,0);
412

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

    
422
    return new MeshJoined(meshes);
423
    }
424

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426

    
427
  MeshBase createFacesHelicopterFace()
428
    {
429
    MeshBase[] meshes = new MeshBase[4];
430

    
431
    float E = 0.5f;
432
    float F = SQ2/4;
433
    float G = 1.0f/12;
434
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
435
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
436

    
437
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
438
    meshes[0].setEffectAssociation(0,1,0);
439

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

    
443
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
444
    meshes[1].setEffectAssociation(0,2,0);
445

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

    
448
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
449
    meshes[2].setEffectAssociation(0,4,0);
450
    meshes[3] = meshes[2].copy(true);
451
    meshes[3].setEffectAssociation(0,8,0);
452

    
453
    return new MeshJoined(meshes);
454
    }
455

    
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457

    
458
  MeshBase createFacesRediEdge()
459
    {
460
    MeshBase[] meshes = new MeshPolygon[6];
461

    
462
    float F = 0.25f;
463
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
464
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
465

    
466
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
467
    meshes[0].setEffectAssociation(0,1,0);
468
    meshes[1] = meshes[0].copy(true);
469
    meshes[1].setEffectAssociation(0,2,0);
470

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

    
474
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
475
    meshes[2].setEffectAssociation(0,4,0);
476
    meshes[3] = meshes[2].copy(true);
477
    meshes[3].setEffectAssociation(0,8,0);
478

    
479
    float X = 0.25f*SQ2;
480
    float Y = SQ6/16;
481
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
482

    
483
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
484
    meshes[4].setEffectAssociation(0,16,0);
485
    meshes[5] = meshes[4].copy(true);
486
    meshes[5].setEffectAssociation(0,32,0);
487

    
488
    return new MeshJoined(meshes);
489
    }
490

    
491
///////////////////////////////////////////////////////////////////////////////////////////////////
492

    
493
  MeshBase createFacesRediCorner()
494
    {
495
    MeshBase[] meshes = new MeshBase[6];
496

    
497
    float E = 0.5f;
498
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
499
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
500

    
501
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
502
    meshes[0].setEffectAssociation(0,1,0);
503
    meshes[1] = meshes[0].copy(true);
504
    meshes[1].setEffectAssociation(0,2,0);
505
    meshes[2] = meshes[0].copy(true);
506
    meshes[2].setEffectAssociation(0,4,0);
507

    
508
    float F = 0.5f;
509
    float X = 0.5f;
510
    float G = 0.72f;
511
    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 };
512
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
513

    
514
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
515
    meshes[3].setEffectAssociation(0,8,0);
516
    meshes[4] = meshes[3].copy(true);
517
    meshes[4].setEffectAssociation(0,16,0);
518
    meshes[5] = meshes[3].copy(true);
519
    meshes[5].setEffectAssociation(0,32,0);
520

    
521
    return new MeshJoined(meshes);
522
    }
523

    
524
///////////////////////////////////////////////////////////////////////////////////////////////////
525

    
526
  MeshBase createFacesIvyCorner()
527
    {
528
    MeshBase[] meshes = new MeshBase[6];
529

    
530
    final float angle = (float)Math.PI/(2*IVY_N);
531
    final float CORR  = 1.0f - 2*IVY_D;
532
    final float DIST  = -0.5f*CORR + IVY_D;
533
    float[] vertices  = new float[2*(IVY_N+1)+6];
534

    
535
    vertices[0] = (0.5f-IVY_M) * IVY_C;
536
    vertices[1] = (DIST-IVY_M) * IVY_C;
537
    vertices[2] = (0.5f-IVY_M) * IVY_C;
538
    vertices[3] = (0.5f-IVY_M) * IVY_C;
539
    vertices[4] = (DIST-IVY_M) * IVY_C;
540
    vertices[5] = (0.5f-IVY_M) * IVY_C;
541

    
542
    for(int i=0; i<=IVY_N; i++)
543
      {
544
      float ang = (IVY_N-i)*angle;
545
      float sin = (float)Math.sin(ang);
546
      float cos = (float)Math.cos(ang);
547

    
548
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
549
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
550
      }
551

    
552
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
553
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
554

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

    
568
    return new MeshJoined(meshes);
569
    }
570

    
571
///////////////////////////////////////////////////////////////////////////////////////////////////
572

    
573
  MeshBase createFacesIvyFace()
574
    {
575
    MeshBase[] meshes = new MeshBase[2];
576

    
577
    final float angle = (float)Math.PI/(2*IVY_N);
578
    final float CORR  = 1.0f - 2*IVY_D;
579
    float[] vertices = new float[4*IVY_N];
580

    
581
    for(int i=0; i<IVY_N; i++)
582
      {
583
      float sin = (float)Math.sin(i*angle);
584
      float cos = (float)Math.cos(i*angle);
585

    
586
      vertices[2*i          ] = CORR*(0.5f-cos);
587
      vertices[2*i+1        ] = CORR*(0.5f-sin);
588
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
589
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
590
      }
591

    
592
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
593
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
594

    
595
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
596
    meshes[0].setEffectAssociation(0,1,0);
597
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
598
    meshes[1].setEffectAssociation(0,2,0);
599

    
600
    return new MeshJoined(meshes);
601
    }
602

    
603
///////////////////////////////////////////////////////////////////////////////////////////////////
604

    
605
  MeshBase createFacesRexCorner()
606
    {
607
    MeshBase[] meshes = new MeshBase[2];
608

    
609
    final float angle = (float)Math.PI/(6*REX_N);
610
    float[] vertices = new float[6*REX_N];
611
    final float D = 0.5f - REX_D;
612
    final float F = D*SQ2*(SQ3-1);
613
    final float B = 2.5f;
614

    
615
    final float V1x = -F*0.5f;
616
    final float V1y = -F*SQ3/6;
617
    final float V2x = -V1x;
618
    final float V2y = V1y;
619
    final float V3x = 0.0f;
620
    final float V3y = -2*V1y;
621

    
622
    final float C1x = 0.0f;
623
    final float C1y = -F*(1+2*SQ3/3);
624
    final float C2x = B*V1x;
625
    final float C2y = B*V1y;
626
    final float C3x = B*V2x;
627
    final float C3y = B*V2y;
628

    
629
    for(int i=0; i<REX_N; i++)
630
      {
631
      writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i          );
632
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
633
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
634
      }
635

    
636
    float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
637
    float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
638

    
639
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
640
    meshes[0].setEffectAssociation(0,1,0);
641
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
642
    meshes[1].setEffectAssociation(0,2,0);
643

    
644
    return new MeshJoined(meshes);
645
    }
646

    
647
///////////////////////////////////////////////////////////////////////////////////////////////////
648

    
649
  MeshBase createFacesRexFace()
650
    {
651
    MeshBase[] meshes = new MeshBase[2];
652

    
653
    final float angle = (float)Math.PI/(6*REX_N);
654
    float[] vertices = new float[8*REX_N];
655
    final float D = 0.5f - REX_D;
656
    final float F = D*(SQ3-1);
657

    
658
    final float V1x = 0.0f;
659
    final float V1y = +F;
660
    final float V2x = -F;
661
    final float V2y = 0.0f;
662
    final float V3x = 0.0f;
663
    final float V3y = -F;
664
    final float V4x = +F;
665
    final float V4y = 0.0f;
666

    
667
    final float C1x = +D;
668
    final float C1y = -D;
669
    final float C2x = +D;
670
    final float C2y = +D;
671
    final float C3x = -D;
672
    final float C3y = +D;
673
    final float C4x = -D;
674
    final float C4y = -D;
675

    
676
    for(int i=0; i<REX_N; i++)
677
      {
678
      writeVertex(C1x,C1y,V1x,V1y, i*angle, vertices, 2*i          );
679
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
680
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
681
      writeVertex(C4x,C4y,V4x,V4y, i*angle, vertices, 2*i + 6*REX_N);
682
      }
683

    
684
    float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
685
    float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
686

    
687
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
688
    meshes[0].setEffectAssociation(0,1,0);
689
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
690
    meshes[1].setEffectAssociation(0,2,0);
691

    
692
    return new MeshJoined(meshes);
693
    }
694

    
695
///////////////////////////////////////////////////////////////////////////////////////////////////
696

    
697
  MeshBase createFacesRexEdge()
698
    {
699
    MeshBase[] meshes = new MeshBase[4];
700

    
701
    final float angle = (float)Math.PI/(6*REX_N);
702
    float[] vertices = new float[4*REX_N + 6];
703
    final float H = 1.0f - SQ3/2;
704
    final float D = 0.5f - REX_D;
705
    final float F = 0.5f*(0.5f - D*(SQ3-1));
706

    
707
    final float V1x = -D;
708
    final float V1y = +D + F - 0.5f;
709
    final float V2x = 0.0f;
710
    final float V2y = -F;
711

    
712
    final float C1x = -D;
713
    final float C1y = -D + F - 0.5f;
714
    final float C2x = +D;
715
    final float C2y = C1y;
716

    
717
    for(int i=0; i<REX_N; i++)
718
      {
719
      writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i          );
720
      writeVertex(C2x,C2y,V2x,V2y,-i*angle, vertices, 2*i + 2*REX_N);
721
      }
722

    
723
    vertices[4*REX_N  ] = +D;
724
    vertices[4*REX_N+1] = +F-REX_D;
725
    vertices[4*REX_N+2] = +D;
726
    vertices[4*REX_N+3] = +F;
727
    vertices[4*REX_N+4] = -D;
728
    vertices[4*REX_N+5] = +F;
729

    
730
    float[] bands0 = computeBands(+0.02f, 9,0.5f,0.5f,5);
731
    float[] bands1 = computeBands( 0.00f,45,0.5f,0.0f,2);
732

    
733
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
734
    meshes[0].setEffectAssociation(0,1,0);
735
    meshes[1] = meshes[0].copy(true);
736
    meshes[1].setEffectAssociation(0,2,0);
737
    meshes[2] = new MeshPolygon(vertices,bands1,0,0);
738
    meshes[2].setEffectAssociation(0,4,0);
739
    meshes[3] = meshes[2].copy(true);
740
    meshes[3].setEffectAssociation(0,8,0);
741

    
742
    return new MeshJoined(meshes);
743
    }
744

    
745
///////////////////////////////////////////////////////////////////////////////////////////////////
746
// EFFECTS
747
///////////////////////////////////////////////////////////////////////////////////////////////////
748

    
749
  VertexEffect[] createVertexEffectsCube()
750
    {
751
    Static3D axisY   = new Static3D(0,1,0);
752
    Static3D axisX   = new Static3D(1,0,0);
753
    Static3D center  = new Static3D(0,0,0);
754
    Static1D angle90 = new Static1D(90);
755
    Static1D angle180= new Static1D(180);
756
    Static1D angle270= new Static1D(270);
757

    
758
    VertexEffect[] effect = new VertexEffect[6];
759

    
760
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
761
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
762
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
763
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
764
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
765
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
766

    
767
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
768
    effect[1].setMeshAssociation(32,-1);  // back
769
    effect[2].setMeshAssociation( 8,-1);  // bottom
770
    effect[3].setMeshAssociation( 4,-1);  // top
771
    effect[4].setMeshAssociation( 2,-1);  // left
772
    effect[5].setMeshAssociation( 1,-1);  // right
773

    
774
    return effect;
775
    }
776

    
777
///////////////////////////////////////////////////////////////////////////////////////////////////
778

    
779
  VertexEffect[] createVertexEffectsSkewbCorner()
780
    {
781
    float E = 0.5f;
782

    
783
    Static3D axisX  = new Static3D(1,0,0);
784
    Static3D axisY  = new Static3D(0,1,0);
785
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
786
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
787
    Static1D angle1 = new Static1D(+90);
788
    Static1D angle2 = new Static1D(-90);
789
    Static1D angle3 = new Static1D(-15);
790
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
791
    Static1D angle5 = new Static1D(120);
792
    Static1D angle6 = new Static1D(240);
793
    Static3D center1= new Static3D(0,0,0);
794
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
795
    Static3D move1  = new Static3D(-E/4,-E/4,0);
796
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
797

    
798
    VertexEffect[] effect = new VertexEffect[10];
799

    
800
    effect[0] = new VertexEffectMove(move1);
801
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
802
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
803
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
804
    effect[4] = new VertexEffectMove(move2);
805
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
806
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
807
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
808
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
809
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
810

    
811
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
812
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
813
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
814
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
815
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
816
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
817
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
818
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
819
    effect[8].setMeshAssociation(16,-1);  // mesh 4
820
    effect[9].setMeshAssociation(32,-1);  // mesh 5
821

    
822
    return effect;
823
    }
824

    
825
///////////////////////////////////////////////////////////////////////////////////////////////////
826

    
827
  VertexEffect[] createVertexEffectsSkewbFace()
828
    {
829
    Static3D center = new Static3D(0,0,0);
830
    Static3D axisX  = new Static3D(1,0,0);
831
    Static3D axisZ  = new Static3D(0,0,1);
832
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
833

    
834
    VertexEffect[] effect = new VertexEffect[6];
835

    
836
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
837
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
838
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
839
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
840
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
841
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
842

    
843
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
844
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
845
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
846
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
847
    effect[4].setMeshAssociation(16,-1);  // mesh 4
848
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
849

    
850
    return effect;
851
    }
852

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

    
855
  VertexEffect[] createVertexEffectsOcta()
856
    {
857
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
858
    Static1D angle1= new Static1D( 90);
859
    Static1D angle2= new Static1D(180);
860
    Static1D angle3= new Static1D(270);
861
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
862
    Static3D axisX = new Static3D(1,0,0);
863
    Static3D axisY = new Static3D(0,1,0);
864
    Static3D cent0 = new Static3D(0,0,0);
865
    Static3D cent1 = new Static3D(0,SQ2/2,0);
866
    Static3D flipY = new Static3D( 1,-1, 1);
867
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
868

    
869
    VertexEffect[] effect = new VertexEffect[7];
870

    
871
    effect[0] = new VertexEffectScale(scale);
872
    effect[1] = new VertexEffectMove(move1);
873
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
874
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
875
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
876
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
877
    effect[6] = new VertexEffectScale(flipY);
878

    
879
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
880
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
881
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
882
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
883

    
884
    return effect;
885
    }
886

    
887
///////////////////////////////////////////////////////////////////////////////////////////////////
888

    
889
  VertexEffect[] createVertexEffectsTetra()
890
    {
891
    Static3D flipZ = new Static3D( 1, 1,-1);
892
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
893
    Static1D angle1= new Static1D( 90);
894
    Static1D angle2= new Static1D(180);
895
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
896
    Static3D axisX = new Static3D(1,0,0);
897
    Static3D axisY = new Static3D(0,1,0);
898
    Static3D axisZ = new Static3D(0,0,1);
899
    Static3D cent0 = new Static3D(0,0,0);
900
    Static3D cent1 = new Static3D(0,SQ2/4,0);
901
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
902

    
903
    VertexEffect[] effect = new VertexEffect[7];
904

    
905
    effect[0] = new VertexEffectScale(scale);
906
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
907
    effect[2] = new VertexEffectMove(move1);
908
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
909
    effect[4] = new VertexEffectScale(flipZ);
910
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
911
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
912

    
913
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
914
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
915
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
916

    
917
    return effect;
918
    }
919

    
920
///////////////////////////////////////////////////////////////////////////////////////////////////
921

    
922
  VertexEffect[] createVertexEffectsDino()
923
    {
924
    float E = 0.5f*SQ2;
925
    float F = 0.5f;
926
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
927

    
928
    Static1D angle1 = new Static1D(-ANGLE);
929
    Static1D angle2 = new Static1D(+ANGLE);
930
    Static3D axisX  = new Static3D(1,0,0);
931
    Static3D axisY  = new Static3D(0,1,0);
932
    Static3D axisZ  = new Static3D(0,-1,1);
933
    Static3D center0= new Static3D(0,0,0);
934
    Static3D center1= new Static3D(0,-3*F,0);
935

    
936
    VertexEffect[] effect = new VertexEffect[10];
937

    
938
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
939
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
940
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
941
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
942
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
943
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
944
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
945
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
946
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
947
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
948

    
949
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
950
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
951
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
952
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 0
953
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
954
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
955
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
956
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
957
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
958
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
959

    
960
    return effect;
961
    }
962

    
963
///////////////////////////////////////////////////////////////////////////////////////////////////
964

    
965
  VertexEffect[] createVertexEffectsHelicopterCorner()
966
    {
967
    float E = 0.5f;
968

    
969
    Static3D axisX  = new Static3D(1,0,0);
970
    Static3D axisY  = new Static3D(0,1,0);
971
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
972
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
973
    Static1D angle1 = new Static1D(+90);
974
    Static1D angle2 = new Static1D(-90);
975
    Static1D angle3 = new Static1D(-135);
976
    Static1D angle4 = new Static1D(90);
977
    Static1D angle5 = new Static1D(120);
978
    Static1D angle6 = new Static1D(240);
979
    Static3D center1= new Static3D(0,0,0);
980
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
981
    Static3D move1  = new Static3D(-E/4,-E/4,0);
982
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
983

    
984
    VertexEffect[] effect = new VertexEffect[10];
985

    
986
    effect[0] = new VertexEffectMove(move1);
987
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
988
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
989
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
990
    effect[4] = new VertexEffectMove(move2);
991
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
992
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
993
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
994
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
995
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
996

    
997
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
998
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
999
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1000
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1001
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1002
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1003
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1004
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1005
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1006
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1007

    
1008
    return effect;
1009
    }
1010

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

    
1013
  VertexEffect[] createVertexEffectsHelicopterFace()
1014
    {
1015
    float E = 0.5f;
1016
    float F = SQ2/4;
1017

    
1018
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1019
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1020
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1021
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1022
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1023
    Static1D angle1 = new Static1D(135);
1024
    Static1D angle2 = new Static1D(90);
1025
    Static1D angle3 = new Static1D(-90);
1026
    Static1D angle4 = new Static1D(-135);
1027
    Static3D axisX  = new Static3D(1,0,0);
1028
    Static3D axisY  = new Static3D(0,1,0);
1029
    Static3D axisZ  = new Static3D(0,0,1);
1030
    Static3D axis1  = new Static3D(1,-1,0);
1031
    Static3D center = new Static3D(0,0,0);
1032
    Static3D center1= new Static3D(-E/2,-E/2,0);
1033

    
1034
    VertexEffect[] effect = new VertexEffect[10];
1035

    
1036
    effect[0] = new VertexEffectMove(move0);
1037
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1038
    effect[2] = new VertexEffectMove(move1);
1039
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1040
    effect[4] = new VertexEffectMove(move2);
1041
    effect[5] = new VertexEffectMove(move3);
1042
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1043
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1044
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1045
    effect[9] = new VertexEffectMove(move4);
1046

    
1047
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1048
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1049
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1050
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1051
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1052
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1053
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1054
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1055
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1056
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1057

    
1058
    return effect;
1059
    }
1060

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

    
1063
  VertexEffect[] createVertexEffectsRediEdge()
1064
    {
1065
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1066
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1067
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1068
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1069
    Static3D flipZ = new Static3D(1,1,-1);
1070
    Static3D flipX = new Static3D(-1,1,1);
1071
    Static3D scale = new Static3D(2,2,2);
1072
    Static3D cent0 = new Static3D(0,0, 0);
1073
    Static3D cent1 = new Static3D(0,0, -1.5f);
1074
    Static3D axisX = new Static3D(1,0, 0);
1075
    Static3D axisY = new Static3D(0,1, 0);
1076
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1077
    Static1D angle1= new Static1D(90);
1078
    Static1D angle2= new Static1D(45);
1079
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1080

    
1081
    VertexEffect[] effect = new VertexEffect[12];
1082

    
1083
    effect[0] = new VertexEffectScale(scale);
1084
    effect[1] = new VertexEffectMove(move0);
1085
    effect[2] = new VertexEffectScale(flipZ);
1086
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1087
    effect[4] = new VertexEffectMove(move1);
1088
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1089
    effect[6] = new VertexEffectMove(move2);
1090
    effect[7] = new VertexEffectScale(flipX);
1091
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1092
    effect[9] = new VertexEffectMove(move3);
1093
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1094
    effect[11]= new VertexEffectScale(flipX);
1095

    
1096
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1097
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1098
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1099
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1100
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1101
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1102
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1103
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1104
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1105
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1106
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1107
    effect[11].setMeshAssociation(32,-1); // mesh 5
1108

    
1109
    return effect;
1110
    }
1111

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

    
1114
  VertexEffect[] createVertexEffectsRediCorner()
1115
    {
1116
    Static3D axisY   = new Static3D(0,1,0);
1117
    Static3D axisX   = new Static3D(1,0,0);
1118
    Static3D axisZ   = new Static3D(0,0,1);
1119
    Static3D center  = new Static3D(0,0,0);
1120
    Static1D angle90 = new Static1D(90);
1121
    Static1D angle270= new Static1D(270);
1122
    Static1D angle45 = new Static1D(-45);
1123
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1124

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

    
1127
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1128
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1129
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1130
    effect[3] = new VertexEffectScale(scale);
1131
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1132
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1133
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1134

    
1135
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1136
    effect[1].setMeshAssociation( 2,-1);  // 1
1137
    effect[2].setMeshAssociation( 4,-1);  // 2
1138
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1139
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1140
    effect[5].setMeshAssociation(16,-1);  // 4
1141
    effect[6].setMeshAssociation(32,-1);  // 5
1142

    
1143
    return effect;
1144
    }
1145

    
1146
///////////////////////////////////////////////////////////////////////////////////////////////////
1147

    
1148
  VertexEffect[] createVertexEffectsIvyCorner()
1149
    {
1150
    Static3D axisX  = new Static3D(1,0,0);
1151
    Static3D axisY  = new Static3D(0,1,0);
1152
    Static1D angle1 = new Static1D(+90);
1153
    Static1D angle2 = new Static1D(-90);
1154
    Static3D center = new Static3D(0,0,0);
1155
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1156

    
1157
    VertexEffect[] effect = new VertexEffect[5];
1158

    
1159
    effect[0] = new VertexEffectScale(1/IVY_C);
1160
    effect[1] = new VertexEffectMove(move1);
1161
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1162
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1163
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1164

    
1165
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1166
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1167
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1168

    
1169
    return effect;
1170
    }
1171

    
1172
///////////////////////////////////////////////////////////////////////////////////////////////////
1173

    
1174
  VertexEffect[] createVertexEffectsRexEdge()
1175
    {
1176
    final float D = 0.5f - REX_D;
1177
    final float F = 0.5f*(0.5f - D*(SQ3-1));
1178

    
1179
    Static3D move  = new Static3D(0.0f,   -F, 0.0f);
1180
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1181
    Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f);
1182
    Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f);
1183

    
1184
    Static1D angle180 = new Static1D(180);
1185
    Static1D angle90  = new Static1D( 90);
1186

    
1187
    VertexEffect[] effect = new VertexEffect[3];
1188

    
1189
    effect[0] = new VertexEffectMove(move);
1190
    effect[1] = new VertexEffectRotate(angle180, axisY, center);
1191
    effect[2] = new VertexEffectRotate(angle90 , axisX, center);
1192

    
1193
    effect[1].setMeshAssociation(10,-1);  // meshes 1 & 3
1194
    effect[2].setMeshAssociation(10,-1);  // meshes 1 & 3
1195

    
1196
    return effect;
1197
    }
1198

    
1199
///////////////////////////////////////////////////////////////////////////////////////////////////
1200

    
1201
  VertexEffect[] createVertexEffectsRexCorner()
1202
    {
1203
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1204
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1205
    Static1D angle = new Static1D(225);
1206

    
1207
    VertexEffect[] effect = new VertexEffect[1];
1208
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1209

    
1210
    return effect;
1211
    }
1212

    
1213
///////////////////////////////////////////////////////////////////////////////////////////////////
1214
// OBJECTS
1215
///////////////////////////////////////////////////////////////////////////////////////////////////
1216
// CUBE
1217

    
1218
  MeshBase createCubeMesh(int index)
1219
    {
1220
    MeshBase mesh = createFacesCube(index);
1221
    VertexEffect[] effects = createVertexEffectsCube();
1222
    for( VertexEffect effect : effects ) mesh.apply(effect);
1223

    
1224
    Static3D roundingCenter  = new Static3D(0,0,0);
1225
    Static3D[] vertices = new Static3D[8];
1226
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1227
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1228
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1229
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1230
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1231
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1232
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1233
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1234

    
1235
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1236

    
1237
    mesh.mergeEffComponents();
1238

    
1239
    return mesh;
1240
    }
1241

    
1242
///////////////////////////////////////////////////////////////////////////////////////////////////
1243
// SKEWB
1244

    
1245
  MeshBase createSkewbCornerMesh()
1246
    {
1247
    MeshBase mesh = createFacesSkewbCorner();
1248
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1249
    for( VertexEffect effect : effects ) mesh.apply(effect);
1250

    
1251
    float E = 0.5f;
1252
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1253

    
1254
    Static3D[] verticesType1 = new Static3D[1];
1255
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1256
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1257

    
1258
    Static3D[] verticesType2 = new Static3D[3];
1259
    verticesType2[0] = new Static3D(-E, 0, 0);
1260
    verticesType2[1] = new Static3D( 0,-E, 0);
1261
    verticesType2[2] = new Static3D( 0, 0,-E);
1262
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1263

    
1264
    mesh.mergeEffComponents();
1265

    
1266
    return mesh;
1267
    }
1268

    
1269
///////////////////////////////////////////////////////////////////////////////////////////////////
1270

    
1271
  MeshBase createSkewbFaceMesh()
1272
    {
1273
    MeshBase mesh = createFacesSkewbFace();
1274
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1275
    for( VertexEffect effect : effects ) mesh.apply(effect);
1276

    
1277
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1278
    float E = SQ2/4;
1279
    Static3D[] vertices = new Static3D[4];
1280
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1281
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1282
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1283
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1284
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1285

    
1286
    mesh.mergeEffComponents();
1287
    mesh.addEmptyTexComponent();
1288

    
1289
    return mesh;
1290
    }
1291

    
1292
///////////////////////////////////////////////////////////////////////////////////////////////////
1293
// SKEWB DIAMOND / PYRAMINX
1294

    
1295
  MeshBase createOctaMesh()
1296
    {
1297
    MeshBase mesh = createFacesOcta();
1298
    VertexEffect[] effects = createVertexEffectsOcta();
1299
    for( VertexEffect effect : effects ) mesh.apply(effect);
1300

    
1301
    Static3D roundingCenter = new Static3D(0,0,0);
1302
    Static3D[] vertices = new Static3D[6];
1303
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1304
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1305
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1306
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1307
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1308
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1309

    
1310
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1311

    
1312
    mesh.mergeEffComponents();
1313

    
1314
    return mesh;
1315
    }
1316

    
1317
///////////////////////////////////////////////////////////////////////////////////////////////////
1318

    
1319
  MeshBase createTetraMesh()
1320
    {
1321
    MeshBase mesh = createFacesTetra();
1322
    VertexEffect[] effects = createVertexEffectsTetra();
1323
    for( VertexEffect effect : effects ) mesh.apply(effect);
1324

    
1325
    Static3D roundingCenter = new Static3D(0,0,0);
1326
    Static3D[] verticesRound = new Static3D[4];
1327
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1328
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1329
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1330
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1331
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1332

    
1333
    mesh.mergeEffComponents();
1334
    mesh.addEmptyTexComponent();
1335
    mesh.addEmptyTexComponent();
1336
    mesh.addEmptyTexComponent();
1337
    mesh.addEmptyTexComponent();
1338

    
1339
    return mesh;
1340
    }
1341

    
1342
///////////////////////////////////////////////////////////////////////////////////////////////////
1343
// DINO
1344

    
1345
  MeshBase createDinoMesh()
1346
    {
1347
    MeshBase mesh = createFacesDino();
1348
    VertexEffect[] effects = createVertexEffectsDino();
1349
    for( VertexEffect effect : effects ) mesh.apply(effect);
1350

    
1351
    float F = 0.5f;
1352
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1353
    Static3D[] verticesRound = new Static3D[4];
1354
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1355
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1356
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1357
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1358
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1359

    
1360
    mesh.mergeEffComponents();
1361

    
1362
    return mesh;
1363
    }
1364

    
1365
///////////////////////////////////////////////////////////////////////////////////////////////////
1366
// Helicopter
1367

    
1368
  MeshBase createHelicopterCornerMesh()
1369
    {
1370
    MeshBase mesh = createFacesHelicopterCorner();
1371
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1372
    for( VertexEffect effect : effects ) mesh.apply(effect);
1373

    
1374
    float E = 0.5f;
1375
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1376

    
1377
    Static3D[] verticesType1 = new Static3D[1];
1378
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1379
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1380

    
1381
    Static3D[] verticesType2 = new Static3D[3];
1382
    verticesType2[0] = new Static3D(-E, 0, 0);
1383
    verticesType2[1] = new Static3D( 0,-E, 0);
1384
    verticesType2[2] = new Static3D( 0, 0,-E);
1385
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1386

    
1387
    mesh.mergeEffComponents();
1388

    
1389
    return mesh;
1390
    }
1391

    
1392
///////////////////////////////////////////////////////////////////////////////////////////////////
1393

    
1394
  MeshBase createHelicopterFaceMesh()
1395
    {
1396
    MeshBase mesh = createFacesHelicopterFace();
1397
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1398
    for( VertexEffect effect : effects ) mesh.apply(effect);
1399

    
1400
    float E = 0.5f;
1401
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1402

    
1403
    Static3D[] verticesType1 = new Static3D[1];
1404
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1405
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1406

    
1407
    Static3D[] verticesType2 = new Static3D[2];
1408
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1409
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1410
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1411

    
1412
    mesh.mergeEffComponents();
1413
    mesh.addEmptyTexComponent();
1414
    mesh.addEmptyTexComponent();
1415

    
1416
    return mesh;
1417
    }
1418

    
1419
///////////////////////////////////////////////////////////////////////////////////////////////////
1420
// Redi cube
1421

    
1422
  MeshBase createRediEdgeMesh()
1423
    {
1424
    MeshBase mesh = createFacesRediEdge();
1425
    VertexEffect[] effects = createVertexEffectsRediEdge();
1426
    for( VertexEffect effect : effects ) mesh.apply(effect);
1427

    
1428
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1429
    Static3D[] vertices = new Static3D[2];
1430
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1431
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1432
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1433

    
1434
    mesh.mergeEffComponents();
1435

    
1436
    return mesh;
1437
    }
1438

    
1439
///////////////////////////////////////////////////////////////////////////////////////////////////
1440

    
1441
  MeshBase createRediCornerMesh()
1442
    {
1443
    MeshBase mesh = createFacesRediCorner();
1444
    VertexEffect[] effects = createVertexEffectsRediCorner();
1445
    for( VertexEffect effect : effects ) mesh.apply(effect);
1446

    
1447
    Static3D center = new Static3D(0,0,0);
1448
    Static3D[] vertices = new Static3D[8];
1449
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1450
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1451
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1452
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1453
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1454
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1455
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1456
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1457

    
1458
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1459

    
1460
    mesh.mergeEffComponents();
1461

    
1462
    return mesh;
1463
    }
1464

    
1465
///////////////////////////////////////////////////////////////////////////////////////////////////
1466

    
1467
  MeshBase createIvyCornerMesh()
1468
    {
1469
    MeshBase mesh = createFacesIvyCorner();
1470
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1471
    for( VertexEffect effect : effects ) mesh.apply(effect);
1472

    
1473
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1474
    Static3D[] vertices = new Static3D[4];
1475
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1476
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1477
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1478
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1479

    
1480
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1481

    
1482
    mesh.mergeEffComponents();
1483

    
1484
    return mesh;
1485
    }
1486

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

    
1489
  MeshBase createIvyFaceMesh()
1490
    {
1491
    MeshBase mesh = createFacesIvyFace();
1492

    
1493
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1494
    Static3D[] vertices = new Static3D[2];
1495
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1496
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1497

    
1498
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1499

    
1500
    mesh.mergeEffComponents();
1501
    mesh.addEmptyTexComponent();
1502
    mesh.addEmptyTexComponent();
1503
    mesh.addEmptyTexComponent();
1504
    mesh.addEmptyTexComponent();
1505

    
1506
    return mesh;
1507
    }
1508

    
1509
///////////////////////////////////////////////////////////////////////////////////////////////////
1510

    
1511
  MeshBase createRexCornerMesh()
1512
    {
1513
    MeshBase mesh = createFacesRexCorner();
1514
    VertexEffect[] effects = createVertexEffectsRexCorner();
1515
    for( VertexEffect effect : effects ) mesh.apply(effect);
1516

    
1517
    final float F = (0.5f-REX_D)*SQ2*(SQ3-1);
1518
    final float H = F*SQ3/3;
1519
    final float G = H*SQ2/2;
1520

    
1521
    Static3D center = new Static3D(0.0f,0.0f,-H);
1522
    Static3D[] vertices = new Static3D[1];
1523
    vertices[0] = new Static3D(+G,-G,+0.0f);
1524
    roundCorners(mesh,center,vertices,0.12f,0.15f);
1525

    
1526
    mesh.mergeEffComponents();
1527
    mesh.addEmptyTexComponent();
1528
    mesh.addEmptyTexComponent();
1529

    
1530
    return mesh;
1531
    }
1532

    
1533
///////////////////////////////////////////////////////////////////////////////////////////////////
1534

    
1535
  MeshBase createRexFaceMesh()
1536
    {
1537
    MeshBase mesh = createFacesRexFace();
1538

    
1539
    mesh.mergeEffComponents();
1540
    mesh.addEmptyTexComponent();
1541
    mesh.addEmptyTexComponent();
1542

    
1543
    return mesh;
1544
    }
1545

    
1546
///////////////////////////////////////////////////////////////////////////////////////////////////
1547

    
1548
  MeshBase createRexEdgeMesh()
1549
    {
1550
    MeshBase mesh = createFacesRexEdge();
1551
    VertexEffect[] effects = createVertexEffectsRexEdge();
1552
    for( VertexEffect effect : effects ) mesh.apply(effect);
1553

    
1554
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1555
    Static3D[] vertices = new Static3D[2];
1556
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1557
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1558
    roundCorners(mesh,center,vertices,0.08f,0.15f);
1559

    
1560
    mesh.mergeEffComponents();
1561

    
1562
    return mesh;
1563
    }
1564
  }
(2-2/26)