Project

General

Profile

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

examples / src / main / java / org / distorted / examples / meshfile / FactoryCubit.java @ 1c41c4c9

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

    
20
package org.distorted.examples.meshfile;
21

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

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

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

    
42
  private static final float IVY_D = 0.003f;
43
  private static final int   IVY_N = 8;
44
  private static final float IVY_C = 0.59f;
45
  private static final float IVY_M = 0.35f;
46

    
47
  private static final Static1D RADIUS = new Static1D(1);
48

    
49
  private static FactoryCubit mThis;
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  private FactoryCubit()
54
    {
55

    
56
    }
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

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

    
64
    return mThis;
65
    }
66

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

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

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

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

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

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

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

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

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

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

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

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

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

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

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

    
172
    return bands;
173
    }
174

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

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

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

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

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

    
196
///////////////////////////////////////////////////////////////////////////////////////////////////
197

    
198
  MeshBase createFacesCube(int sizeIndex)
199
    {
200
    MeshBase[] meshes = new MeshPolygon[6];
201

    
202
    float E = 0.5f;
203
    int extraI, extraV, num;
204

    
205
    switch(sizeIndex)
206
      {
207
      case 0 : num = 6; extraI = 2; extraV = 2; break;
208
      case 1 : num = 5; extraI = 2; extraV = 2; break;
209
      case 2 : num = 5; extraI = 1; extraV = 2; break;
210
      default: num = 4; extraI = 1; extraV = 1; break;
211
      }
212

    
213
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
214
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
215

    
216
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
217
    meshes[0].setEffectAssociation(0,1,0);
218
    meshes[1] = meshes[0].copy(true);
219
    meshes[1].setEffectAssociation(0,2,0);
220
    meshes[2] = meshes[0].copy(true);
221
    meshes[2].setEffectAssociation(0,4,0);
222
    meshes[3] = meshes[0].copy(true);
223
    meshes[3].setEffectAssociation(0,8,0);
224
    meshes[4] = meshes[0].copy(true);
225
    meshes[4].setEffectAssociation(0,16,0);
226
    meshes[5] = meshes[0].copy(true);
227
    meshes[5].setEffectAssociation(0,32,0);
228

    
229
    return new MeshJoined(meshes);
230
    }
231

    
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233

    
234
  MeshBase createFacesSkewbCorner()
235
    {
236
    MeshBase[] meshes = new MeshBase[6];
237

    
238
    float E = 0.5f;
239
    float F = SQ2/2;
240
    float G = SQ6/16;
241
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
242
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
243

    
244
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
245
    meshes[0].setEffectAssociation(0,1,0);
246
    meshes[1] = meshes[0].copy(true);
247
    meshes[1].setEffectAssociation(0,2,0);
248
    meshes[2] = meshes[0].copy(true);
249
    meshes[2].setEffectAssociation(0,4,0);
250

    
251
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
252
    float[] bands1 = computeBands(0,0,1,0,3);
253

    
254
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
255
    meshes[3].setEffectAssociation(0,8,0);
256
    meshes[4] = meshes[3].copy(true);
257
    meshes[4].setEffectAssociation(0,16,0);
258
    meshes[5] = meshes[3].copy(true);
259
    meshes[5].setEffectAssociation(0,32,0);
260

    
261
    return new MeshJoined(meshes);
262
    }
263

    
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265

    
266
  MeshBase createFacesSkewbFace()
267
    {
268
    MeshBase[] meshes = new MeshBase[5];
269

    
270
    float E = SQ2/4;
271
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
272
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
273

    
274
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
275
    meshes[0].setEffectAssociation(0,1,0);
276

    
277
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
278
    float[] bands1 = computeBands(0,0,1,0,3);
279

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

    
289
    return new MeshJoined(meshes);
290
    }
291

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

    
294
  MeshBase createFacesOcta()
295
    {
296
    MeshBase[] meshes = new MeshPolygon[8];
297

    
298
    float E = 0.75f;
299
    float F = 0.5f;
300
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
301
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
302

    
303
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
304
    meshes[0].setEffectAssociation(0,1,0);
305
    meshes[1] = meshes[0].copy(true);
306
    meshes[1].setEffectAssociation(0,2,0);
307
    meshes[2] = meshes[0].copy(true);
308
    meshes[2].setEffectAssociation(0,4,0);
309
    meshes[3] = meshes[0].copy(true);
310
    meshes[3].setEffectAssociation(0,8,0);
311
    meshes[4] = meshes[0].copy(true);
312
    meshes[4].setEffectAssociation(0,16,0);
313
    meshes[5] = meshes[0].copy(true);
314
    meshes[5].setEffectAssociation(0,32,0);
315
    meshes[6] = meshes[0].copy(true);
316
    meshes[6].setEffectAssociation(0,64,0);
317
    meshes[7] = meshes[0].copy(true);
318
    meshes[7].setEffectAssociation(0,128,0);
319

    
320
    return new MeshJoined(meshes);
321
    }
322

    
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

    
325
  MeshBase createFacesTetra()
326
    {
327
    MeshBase[] meshes = new MeshBase[4];
328

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

    
334
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
335
    meshes[0].setEffectAssociation(0,1,0);
336
    meshes[1] = meshes[0].copy(true);
337
    meshes[1].setEffectAssociation(0,2,0);
338
    meshes[2] = meshes[0].copy(true);
339
    meshes[2].setEffectAssociation(0,4,0);
340
    meshes[3] = meshes[0].copy(true);
341
    meshes[3].setEffectAssociation(0,8,0);
342

    
343
    return new MeshJoined(meshes);
344
    }
345

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347

    
348
  MeshBase createFacesDino()
349
    {
350
    MeshBase[] meshes = new MeshPolygon[4];
351

    
352
    float E = 0.5f*SQ2;
353
    float F = 0.5f;
354
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
355
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
356

    
357
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
358
    meshes[0].setEffectAssociation(0,1,0);
359
    meshes[1] = meshes[0].copy(true);
360
    meshes[1].setEffectAssociation(0,2,0);
361

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

    
365
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
366
    meshes[2].setEffectAssociation(0,4,0);
367
    meshes[3] = meshes[2].copy(true);
368
    meshes[3].setEffectAssociation(0,8,0);
369

    
370
    return new MeshJoined(meshes);
371
    }
372

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

    
375
  MeshBase createFacesHelicopterCorner()
376
    {
377
    MeshBase[] meshes = new MeshBase[6];
378

    
379
    float E = 0.5f;
380
    float F = SQ2/4;
381
    float G = 1.0f/12;
382
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
383
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
384

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

    
392
    float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
393
    float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
394
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
395
    meshes[3].setEffectAssociation(0,8,0);
396
    meshes[4] = meshes[3].copy(true);
397
    meshes[4].setEffectAssociation(0,16,0);
398
    meshes[5] = meshes[3].copy(true);
399
    meshes[5].setEffectAssociation(0,32,0);
400

    
401
    return new MeshJoined(meshes);
402
    }
403

    
404
///////////////////////////////////////////////////////////////////////////////////////////////////
405

    
406
  MeshBase createFacesHelicopterFace()
407
    {
408
    MeshBase[] meshes = new MeshBase[4];
409

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

    
416
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
417
    meshes[0].setEffectAssociation(0,1,0);
418

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

    
422
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
423
    meshes[1].setEffectAssociation(0,2,0);
424

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

    
427
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
428
    meshes[2].setEffectAssociation(0,4,0);
429
    meshes[3] = meshes[2].copy(true);
430
    meshes[3].setEffectAssociation(0,8,0);
431

    
432
    return new MeshJoined(meshes);
433
    }
434

    
435
///////////////////////////////////////////////////////////////////////////////////////////////////
436

    
437
  MeshBase createFacesRediEdge()
438
    {
439
    MeshBase[] meshes = new MeshPolygon[6];
440

    
441
    float F = 0.25f;
442
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
443
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
444

    
445
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
446
    meshes[0].setEffectAssociation(0,1,0);
447
    meshes[1] = meshes[0].copy(true);
448
    meshes[1].setEffectAssociation(0,2,0);
449

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

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

    
458
    float X = 0.25f*SQ2;
459
    float Y = SQ6/16;
460
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
461

    
462
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
463
    meshes[4].setEffectAssociation(0,16,0);
464
    meshes[5] = meshes[4].copy(true);
465
    meshes[5].setEffectAssociation(0,32,0);
466

    
467
    return new MeshJoined(meshes);
468
    }
469

    
470
///////////////////////////////////////////////////////////////////////////////////////////////////
471

    
472
  MeshBase createFacesRediCorner()
473
    {
474
    MeshBase[] meshes = new MeshBase[6];
475

    
476
    float E = 0.5f;
477
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
478
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
479

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

    
487
    float F = 0.5f;
488
    float X = 0.5f;
489
    float G = 0.72f;
490
    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 };
491
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
492

    
493
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
494
    meshes[3].setEffectAssociation(0,8,0);
495
    meshes[4] = meshes[3].copy(true);
496
    meshes[4].setEffectAssociation(0,16,0);
497
    meshes[5] = meshes[3].copy(true);
498
    meshes[5].setEffectAssociation(0,32,0);
499

    
500
    return new MeshJoined(meshes);
501
    }
502

    
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504

    
505
  MeshBase createFacesIvyCorner()
506
    {
507
    MeshBase[] meshes = new MeshBase[6];
508

    
509
    final float angle = (float)Math.PI/(2*IVY_N);
510
    final float CORR  = 1.0f - 2*IVY_D;
511
    final float DIST  = -0.5f*CORR + IVY_D;
512
    float[] vertices  = new float[2*(IVY_N+1)+6];
513

    
514
    vertices[0] = (0.5f-IVY_M) * IVY_C;
515
    vertices[1] = (DIST-IVY_M) * IVY_C;
516
    vertices[2] = (0.5f-IVY_M) * IVY_C;
517
    vertices[3] = (0.5f-IVY_M) * IVY_C;
518
    vertices[4] = (DIST-IVY_M) * IVY_C;
519
    vertices[5] = (0.5f-IVY_M) * IVY_C;
520

    
521
    for(int i=0; i<=IVY_N; i++)
522
      {
523
      float ang = (IVY_N-i)*angle;
524
      float sin = (float)Math.sin(ang);
525
      float cos = (float)Math.cos(ang);
526

    
527
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
528
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
529
      }
530

    
531
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
532
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
533

    
534
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
535
    meshes[0].setEffectAssociation(0,1,0);
536
    meshes[1] = meshes[0].copy(true);
537
    meshes[1].setEffectAssociation(0,2,0);
538
    meshes[2] = meshes[0].copy(true);
539
    meshes[2].setEffectAssociation(0,4,0);
540
    meshes[3] = new MeshPolygon(vertices,bands1,1,2);
541
    meshes[3].setEffectAssociation(0,8,0);
542
    meshes[4] = meshes[3].copy(true);
543
    meshes[4].setEffectAssociation(0,16,0);
544
    meshes[5] = meshes[3].copy(true);
545
    meshes[5].setEffectAssociation(0,32,0);
546

    
547
    return new MeshJoined(meshes);
548
    }
549

    
550
///////////////////////////////////////////////////////////////////////////////////////////////////
551

    
552
  MeshBase createFacesIvyFace()
553
    {
554
    MeshBase[] meshes = new MeshBase[2];
555

    
556
    final float angle = (float)Math.PI/(2*IVY_N);
557
    final float CORR  = 1.0f - IVY_D*SQ2;
558
    float[] vertices = new float[4*IVY_N];
559

    
560
    for(int i=0; i<IVY_N; i++)
561
      {
562
      float sin = (float)Math.sin(i*angle);
563
      float cos = (float)Math.cos(i*angle);
564

    
565
      vertices[2*i          ] = CORR*(0.5f-cos);
566
      vertices[2*i+1        ] = CORR*(0.5f-sin);
567
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
568
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
569
      }
570

    
571
    float[] bands0 = computeBands(+0.05f,35,0.5f,0.5f,5);
572
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
573

    
574
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
575
    meshes[0].setEffectAssociation(0,1,0);
576
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
577
    meshes[1].setEffectAssociation(0,2,0);
578

    
579
    return new MeshJoined(meshes);
580
    }
581

    
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583
// EFFECTS
584
///////////////////////////////////////////////////////////////////////////////////////////////////
585

    
586
  VertexEffect[] createVertexEffectsCube()
587
    {
588
    Static3D axisY   = new Static3D(0,1,0);
589
    Static3D axisX   = new Static3D(1,0,0);
590
    Static3D center  = new Static3D(0,0,0);
591
    Static1D angle90 = new Static1D(90);
592
    Static1D angle180= new Static1D(180);
593
    Static1D angle270= new Static1D(270);
594

    
595
    VertexEffect[] effect = new VertexEffect[6];
596

    
597
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
598
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
599
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
600
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
601
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
602
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
603

    
604
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
605
    effect[1].setMeshAssociation(32,-1);  // back
606
    effect[2].setMeshAssociation( 8,-1);  // bottom
607
    effect[3].setMeshAssociation( 4,-1);  // top
608
    effect[4].setMeshAssociation( 2,-1);  // left
609
    effect[5].setMeshAssociation( 1,-1);  // right
610

    
611
    return effect;
612
    }
613

    
614
///////////////////////////////////////////////////////////////////////////////////////////////////
615

    
616
  VertexEffect[] createVertexEffectsSkewbCorner()
617
    {
618
    float E = 0.5f;
619

    
620
    Static3D axisX  = new Static3D(1,0,0);
621
    Static3D axisY  = new Static3D(0,1,0);
622
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
623
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
624
    Static1D angle1 = new Static1D(+90);
625
    Static1D angle2 = new Static1D(-90);
626
    Static1D angle3 = new Static1D(-15);
627
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
628
    Static1D angle5 = new Static1D(120);
629
    Static1D angle6 = new Static1D(240);
630
    Static3D center1= new Static3D(0,0,0);
631
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
632
    Static3D move1  = new Static3D(-E/4,-E/4,0);
633
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
634

    
635
    VertexEffect[] effect = new VertexEffect[10];
636

    
637
    effect[0] = new VertexEffectMove(move1);
638
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
639
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
640
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
641
    effect[4] = new VertexEffectMove(move2);
642
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
643
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
644
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
645
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
646
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
647

    
648
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
649
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
650
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
651
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
652
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
653
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
654
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
655
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
656
    effect[8].setMeshAssociation(16,-1);  // mesh 4
657
    effect[9].setMeshAssociation(32,-1);  // mesh 5
658

    
659
    return effect;
660
    }
661

    
662
///////////////////////////////////////////////////////////////////////////////////////////////////
663

    
664
  VertexEffect[] createVertexEffectsSkewbFace()
665
    {
666
    Static3D center = new Static3D(0,0,0);
667
    Static3D axisX  = new Static3D(1,0,0);
668
    Static3D axisZ  = new Static3D(0,0,1);
669
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
670

    
671
    VertexEffect[] effect = new VertexEffect[6];
672

    
673
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
674
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
675
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
676
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
677
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
678
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
679

    
680
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
681
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
682
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
683
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
684
    effect[4].setMeshAssociation(16,-1);  // mesh 4
685
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
686

    
687
    return effect;
688
    }
689

    
690
///////////////////////////////////////////////////////////////////////////////////////////////////
691

    
692
  VertexEffect[] createVertexEffectsOcta()
693
    {
694
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
695
    Static1D angle1= new Static1D( 90);
696
    Static1D angle2= new Static1D(180);
697
    Static1D angle3= new Static1D(270);
698
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
699
    Static3D axisX = new Static3D(1,0,0);
700
    Static3D axisY = new Static3D(0,1,0);
701
    Static3D cent0 = new Static3D(0,0,0);
702
    Static3D cent1 = new Static3D(0,SQ2/2,0);
703
    Static3D flipY = new Static3D( 1,-1, 1);
704
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
705

    
706
    VertexEffect[] effect = new VertexEffect[7];
707

    
708
    effect[0] = new VertexEffectScale(scale);
709
    effect[1] = new VertexEffectMove(move1);
710
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
711
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
712
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
713
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
714
    effect[6] = new VertexEffectScale(flipY);
715

    
716
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
717
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
718
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
719
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
720

    
721
    return effect;
722
    }
723

    
724
///////////////////////////////////////////////////////////////////////////////////////////////////
725

    
726
  VertexEffect[] createVertexEffectsTetra()
727
    {
728
    Static3D flipZ = new Static3D( 1, 1,-1);
729
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
730
    Static1D angle1= new Static1D( 90);
731
    Static1D angle2= new Static1D(180);
732
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
733
    Static3D axisX = new Static3D(1,0,0);
734
    Static3D axisY = new Static3D(0,1,0);
735
    Static3D axisZ = new Static3D(0,0,1);
736
    Static3D cent0 = new Static3D(0,0,0);
737
    Static3D cent1 = new Static3D(0,SQ2/4,0);
738
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
739

    
740
    VertexEffect[] effect = new VertexEffect[7];
741

    
742
    effect[0] = new VertexEffectScale(scale);
743
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
744
    effect[2] = new VertexEffectMove(move1);
745
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
746
    effect[4] = new VertexEffectScale(flipZ);
747
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
748
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
749

    
750
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
751
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
752
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
753

    
754
    return effect;
755
    }
756

    
757
///////////////////////////////////////////////////////////////////////////////////////////////////
758

    
759
  VertexEffect[] createVertexEffectsDino()
760
    {
761
    float E = 0.5f*SQ2;
762
    float F = 0.5f;
763
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
764

    
765
    Static1D angle1 = new Static1D(-ANGLE);
766
    Static1D angle2 = new Static1D(+ANGLE);
767
    Static3D axisX  = new Static3D(1,0,0);
768
    Static3D axisY  = new Static3D(0,1,0);
769
    Static3D axisZ  = new Static3D(0,-1,1);
770
    Static3D center0= new Static3D(0,0,0);
771
    Static3D center1= new Static3D(0,-3*F,0);
772

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

    
775
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
776
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
777
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
778
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
779
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
780
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
781
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
782
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
783
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
784
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
785

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

    
797
    return effect;
798
    }
799

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

    
802
  VertexEffect[] createVertexEffectsHelicopterCorner()
803
    {
804
    float E = 0.5f;
805

    
806
    Static3D axisX  = new Static3D(1,0,0);
807
    Static3D axisY  = new Static3D(0,1,0);
808
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
809
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
810
    Static1D angle1 = new Static1D(+90);
811
    Static1D angle2 = new Static1D(-90);
812
    Static1D angle3 = new Static1D(-135);
813
    Static1D angle4 = new Static1D(90);
814
    Static1D angle5 = new Static1D(120);
815
    Static1D angle6 = new Static1D(240);
816
    Static3D center1= new Static3D(0,0,0);
817
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
818
    Static3D move1  = new Static3D(-E/4,-E/4,0);
819
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
820

    
821
    VertexEffect[] effect = new VertexEffect[10];
822

    
823
    effect[0] = new VertexEffectMove(move1);
824
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
825
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
826
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
827
    effect[4] = new VertexEffectMove(move2);
828
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
829
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
830
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
831
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
832
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
833

    
834
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
835
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
836
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
837
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
838
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
839
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
840
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
841
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
842
    effect[8].setMeshAssociation(16,-1);  // mesh 4
843
    effect[9].setMeshAssociation(32,-1);  // mesh 5
844

    
845
    return effect;
846
    }
847

    
848
///////////////////////////////////////////////////////////////////////////////////////////////////
849

    
850
  VertexEffect[] createVertexEffectsHelicopterFace()
851
    {
852
    float E = 0.5f;
853
    float F = SQ2/4;
854

    
855
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
856
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
857
    Static3D move2  = new Static3D(-E/2, F/3, 0);
858
    Static3D move3  = new Static3D(+E/2, F/3, 0);
859
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
860
    Static1D angle1 = new Static1D(135);
861
    Static1D angle2 = new Static1D(90);
862
    Static1D angle3 = new Static1D(-90);
863
    Static1D angle4 = new Static1D(-135);
864
    Static3D axisX  = new Static3D(1,0,0);
865
    Static3D axisY  = new Static3D(0,1,0);
866
    Static3D axisZ  = new Static3D(0,0,1);
867
    Static3D axis1  = new Static3D(1,-1,0);
868
    Static3D center = new Static3D(0,0,0);
869
    Static3D center1= new Static3D(-E/2,-E/2,0);
870

    
871
    VertexEffect[] effect = new VertexEffect[10];
872

    
873
    effect[0] = new VertexEffectMove(move0);
874
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
875
    effect[2] = new VertexEffectMove(move1);
876
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
877
    effect[4] = new VertexEffectMove(move2);
878
    effect[5] = new VertexEffectMove(move3);
879
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
880
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
881
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
882
    effect[9] = new VertexEffectMove(move4);
883

    
884
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
885
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
886
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
887
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
888
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
889
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
890
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
891
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
892
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
893
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
894

    
895
    return effect;
896
    }
897

    
898
///////////////////////////////////////////////////////////////////////////////////////////////////
899

    
900
  VertexEffect[] createVertexEffectsRediEdge()
901
    {
902
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
903
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
904
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
905
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
906
    Static3D flipZ = new Static3D(1,1,-1);
907
    Static3D flipX = new Static3D(-1,1,1);
908
    Static3D scale = new Static3D(2,2,2);
909
    Static3D cent0 = new Static3D(0,0, 0);
910
    Static3D cent1 = new Static3D(0,0, -1.5f);
911
    Static3D axisX = new Static3D(1,0, 0);
912
    Static3D axisY = new Static3D(0,1, 0);
913
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
914
    Static1D angle1= new Static1D(90);
915
    Static1D angle2= new Static1D(45);
916
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
917

    
918
    VertexEffect[] effect = new VertexEffect[12];
919

    
920
    effect[0] = new VertexEffectScale(scale);
921
    effect[1] = new VertexEffectMove(move0);
922
    effect[2] = new VertexEffectScale(flipZ);
923
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
924
    effect[4] = new VertexEffectMove(move1);
925
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
926
    effect[6] = new VertexEffectMove(move2);
927
    effect[7] = new VertexEffectScale(flipX);
928
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
929
    effect[9] = new VertexEffectMove(move3);
930
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
931
    effect[11]= new VertexEffectScale(flipX);
932

    
933
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
934
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
935
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
936
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
937
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
938
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
939
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
940
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
941
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
942
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
943
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
944
    effect[11].setMeshAssociation(32,-1); // mesh 5
945

    
946
    return effect;
947
    }
948

    
949
///////////////////////////////////////////////////////////////////////////////////////////////////
950

    
951
  VertexEffect[] createVertexEffectsRediCorner()
952
    {
953
    Static3D axisY   = new Static3D(0,1,0);
954
    Static3D axisX   = new Static3D(1,0,0);
955
    Static3D axisZ   = new Static3D(0,0,1);
956
    Static3D center  = new Static3D(0,0,0);
957
    Static1D angle90 = new Static1D(90);
958
    Static1D angle270= new Static1D(270);
959
    Static1D angle45 = new Static1D(-45);
960
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
961

    
962
    VertexEffect[] effect = new VertexEffect[7];
963

    
964
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
965
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
966
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
967
    effect[3] = new VertexEffectScale(scale);
968
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
969
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
970
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
971

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

    
980
    return effect;
981
    }
982

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

    
985
  VertexEffect[] createVertexEffectsIvyCorner()
986
    {
987
    Static3D axisX  = new Static3D(1,0,0);
988
    Static3D axisY  = new Static3D(0,1,0);
989
    Static1D angle1 = new Static1D(+90);
990
    Static1D angle2 = new Static1D(-90);
991
    Static3D center = new Static3D(0,0,0);
992
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
993

    
994
    VertexEffect[] effect = new VertexEffect[5];
995

    
996
    effect[0] = new VertexEffectScale(1/IVY_C);
997
    effect[1] = new VertexEffectMove(move1);
998
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
999
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1000
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1001

    
1002
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1003
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1004
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1005

    
1006
    return effect;
1007
    }
1008

    
1009
///////////////////////////////////////////////////////////////////////////////////////////////////
1010
// OBJECTS
1011
///////////////////////////////////////////////////////////////////////////////////////////////////
1012
// CUBE
1013

    
1014
  MeshBase createCubeMesh(int index)
1015
    {
1016
    MeshBase mesh = createFacesCube(index);
1017
    VertexEffect[] effects = createVertexEffectsCube();
1018
    for( VertexEffect effect : effects ) mesh.apply(effect);
1019

    
1020
    Static3D roundingCenter  = new Static3D(0,0,0);
1021
    Static3D[] vertices = new Static3D[8];
1022
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1023
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1024
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1025
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1026
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1027
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1028
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1029
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1030

    
1031
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1032

    
1033
    mesh.mergeEffComponents();
1034

    
1035
    return mesh;
1036
    }
1037

    
1038
///////////////////////////////////////////////////////////////////////////////////////////////////
1039
// SKEWB
1040

    
1041
  MeshBase createSkewbCornerMesh()
1042
    {
1043
    MeshBase mesh = createFacesSkewbCorner();
1044
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1045
    for( VertexEffect effect : effects ) mesh.apply(effect);
1046

    
1047
    float E = 0.5f;
1048
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1049

    
1050
    Static3D[] verticesType1 = new Static3D[1];
1051
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1052
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1053

    
1054
    Static3D[] verticesType2 = new Static3D[3];
1055
    verticesType2[0] = new Static3D(-E, 0, 0);
1056
    verticesType2[1] = new Static3D( 0,-E, 0);
1057
    verticesType2[2] = new Static3D( 0, 0,-E);
1058
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1059

    
1060
    mesh.mergeEffComponents();
1061

    
1062
    return mesh;
1063
    }
1064

    
1065
///////////////////////////////////////////////////////////////////////////////////////////////////
1066

    
1067
  MeshBase createSkewbFaceMesh()
1068
    {
1069
    MeshBase mesh = createFacesSkewbFace();
1070
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1071
    for( VertexEffect effect : effects ) mesh.apply(effect);
1072

    
1073
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1074
    float E = SQ2/4;
1075
    Static3D[] vertices = new Static3D[4];
1076
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1077
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1078
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1079
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1080
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1081

    
1082
    mesh.mergeEffComponents();
1083
    mesh.addEmptyTexComponent();
1084

    
1085
    return mesh;
1086
    }
1087

    
1088
///////////////////////////////////////////////////////////////////////////////////////////////////
1089
// SKEWB DIAMOND / PYRAMINX
1090

    
1091
  MeshBase createOctaMesh()
1092
    {
1093
    MeshBase mesh = createFacesOcta();
1094
    VertexEffect[] effects = createVertexEffectsOcta();
1095
    for( VertexEffect effect : effects ) mesh.apply(effect);
1096

    
1097
    Static3D roundingCenter = new Static3D(0,0,0);
1098
    Static3D[] vertices = new Static3D[6];
1099
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1100
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1101
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1102
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1103
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1104
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1105

    
1106
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1107

    
1108
    mesh.mergeEffComponents();
1109

    
1110
    return mesh;
1111
    }
1112

    
1113
///////////////////////////////////////////////////////////////////////////////////////////////////
1114

    
1115
  MeshBase createTetraMesh()
1116
    {
1117
    MeshBase mesh = createFacesTetra();
1118
    VertexEffect[] effects = createVertexEffectsTetra();
1119
    for( VertexEffect effect : effects ) mesh.apply(effect);
1120

    
1121
    Static3D roundingCenter = new Static3D(0,0,0);
1122
    Static3D[] verticesRound = new Static3D[4];
1123
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1124
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1125
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1126
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1127
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1128

    
1129
    mesh.mergeEffComponents();
1130
    mesh.addEmptyTexComponent();
1131
    mesh.addEmptyTexComponent();
1132
    mesh.addEmptyTexComponent();
1133
    mesh.addEmptyTexComponent();
1134

    
1135
    return mesh;
1136
    }
1137

    
1138
///////////////////////////////////////////////////////////////////////////////////////////////////
1139
// DINO
1140

    
1141
  MeshBase createDinoMesh()
1142
    {
1143
    MeshBase mesh = createFacesDino();
1144
    VertexEffect[] effects = createVertexEffectsDino();
1145
    for( VertexEffect effect : effects ) mesh.apply(effect);
1146

    
1147
    float F = 0.5f;
1148
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1149
    Static3D[] verticesRound = new Static3D[4];
1150
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1151
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1152
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1153
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1154
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1155

    
1156
    mesh.mergeEffComponents();
1157

    
1158
    return mesh;
1159
    }
1160

    
1161
///////////////////////////////////////////////////////////////////////////////////////////////////
1162
// Helicopter
1163

    
1164
  MeshBase createHelicopterCornerMesh()
1165
    {
1166
    MeshBase mesh = createFacesHelicopterCorner();
1167
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1168
    for( VertexEffect effect : effects ) mesh.apply(effect);
1169

    
1170
    float E = 0.5f;
1171
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1172

    
1173
    Static3D[] verticesType1 = new Static3D[1];
1174
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1175
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1176

    
1177
    Static3D[] verticesType2 = new Static3D[3];
1178
    verticesType2[0] = new Static3D(-E, 0, 0);
1179
    verticesType2[1] = new Static3D( 0,-E, 0);
1180
    verticesType2[2] = new Static3D( 0, 0,-E);
1181
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1182

    
1183
    mesh.mergeEffComponents();
1184

    
1185
    return mesh;
1186
    }
1187

    
1188
///////////////////////////////////////////////////////////////////////////////////////////////////
1189

    
1190
  MeshBase createHelicopterFaceMesh()
1191
    {
1192
    MeshBase mesh = createFacesHelicopterFace();
1193
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1194
    for( VertexEffect effect : effects ) mesh.apply(effect);
1195

    
1196
    float E = 0.5f;
1197
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1198

    
1199
    Static3D[] verticesType1 = new Static3D[1];
1200
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1201
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1202

    
1203
    Static3D[] verticesType2 = new Static3D[2];
1204
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1205
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1206
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1207

    
1208
    mesh.mergeEffComponents();
1209
    mesh.addEmptyTexComponent();
1210
    mesh.addEmptyTexComponent();
1211

    
1212
    return mesh;
1213
    }
1214

    
1215
///////////////////////////////////////////////////////////////////////////////////////////////////
1216
// Redi cube
1217

    
1218
  MeshBase createRediEdgeMesh()
1219
    {
1220
    MeshBase mesh = createFacesRediEdge();
1221
    VertexEffect[] effects = createVertexEffectsRediEdge();
1222
    for( VertexEffect effect : effects ) mesh.apply(effect);
1223

    
1224
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1225
    Static3D[] vertices = new Static3D[2];
1226
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1227
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1228
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1229

    
1230
    mesh.mergeEffComponents();
1231

    
1232
    return mesh;
1233
    }
1234

    
1235
///////////////////////////////////////////////////////////////////////////////////////////////////
1236

    
1237
  MeshBase createRediCornerMesh()
1238
    {
1239
    MeshBase mesh = createFacesRediCorner();
1240
    VertexEffect[] effects = createVertexEffectsRediCorner();
1241
    for( VertexEffect effect : effects ) mesh.apply(effect);
1242

    
1243
    Static3D center = new Static3D(0,0,0);
1244
    Static3D[] vertices = new Static3D[8];
1245
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1246
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1247
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1248
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1249
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1250
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1251
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1252
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1253

    
1254
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1255

    
1256
    mesh.mergeEffComponents();
1257

    
1258
    return mesh;
1259
    }
1260

    
1261
///////////////////////////////////////////////////////////////////////////////////////////////////
1262

    
1263
  MeshBase createIvyCornerMesh()
1264
    {
1265
    MeshBase mesh = createFacesIvyCorner();
1266
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1267
    for( VertexEffect effect : effects ) mesh.apply(effect);
1268

    
1269
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1270
    Static3D[] vertices = new Static3D[4];
1271
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1272
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1273
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1274
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1275

    
1276
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1277

    
1278
    mesh.mergeEffComponents();
1279

    
1280
    return mesh;
1281
    }
1282

    
1283
///////////////////////////////////////////////////////////////////////////////////////////////////
1284

    
1285
  MeshBase createIvyFaceMesh()
1286
    {
1287
    MeshBase mesh = createFacesIvyFace();
1288

    
1289
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1290
    Static3D[] vertices = new Static3D[2];
1291
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1292
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1293

    
1294
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1295

    
1296
    mesh.mergeEffComponents();
1297
    mesh.addEmptyTexComponent();
1298
    mesh.addEmptyTexComponent();
1299
    mesh.addEmptyTexComponent();
1300
    mesh.addEmptyTexComponent();
1301

    
1302
    return mesh;
1303
    }
1304
  }
(1-1/5)