Project

General

Profile

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

examples / src / main / java / org / distorted / examples / meshfile / FactoryCubit.java @ e0838536

1 7edab735 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 55f20739 Leszek Koltunski
class FactoryCubit
37 7edab735 Leszek Koltunski
  {
38
  private static final float SQ2 = (float)Math.sqrt(2);
39
  private static final float SQ3 = (float)Math.sqrt(3);
40 fe032f52 Leszek Koltunski
  private static final float SQ5 = (float)Math.sqrt(5);
41 7edab735 Leszek Koltunski
  private static final float SQ6 = (float)Math.sqrt(6);
42
43 1c41c4c9 Leszek Koltunski
  private static final float IVY_D = 0.003f;
44 55f20739 Leszek Koltunski
  private static final int   IVY_N = 8;
45 1c41c4c9 Leszek Koltunski
  private static final float IVY_C = 0.59f;
46
  private static final float IVY_M = 0.35f;
47 f7936f2f Leszek Koltunski
  private static final float REX_D = 0.2f;
48 7cd30f7c Leszek Koltunski
  private static final int   REX_N = 5;
49 55f20739 Leszek Koltunski
50 fe032f52 Leszek Koltunski
  static final float MINX_C0 = (SQ5-1)/4;
51
  static final float MINX_C1 = (SQ5+1)/4;                         // sin(54 deg)
52
  static final float MINX_C3 = (float)(Math.sqrt(10-2*SQ5)/4);    // cos(54 deg)
53
  static final float MINX_C4 = (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
54
  static final float MINX_C5 = (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
55
56 7edab735 Leszek Koltunski
  private static final Static1D RADIUS = new Static1D(1);
57
58 55f20739 Leszek Koltunski
  private static FactoryCubit mThis;
59 7edab735 Leszek Koltunski
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61
62 55f20739 Leszek Koltunski
  private FactoryCubit()
63 7edab735 Leszek Koltunski
    {
64
65
    }
66
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
69 55f20739 Leszek Koltunski
  public static FactoryCubit getInstance()
70 7edab735 Leszek Koltunski
    {
71 55f20739 Leszek Koltunski
    if( mThis==null ) mThis = new FactoryCubit();
72 7edab735 Leszek Koltunski
73
    return mThis;
74
    }
75
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77
// H - height of the band in the middle
78
// alpha - angle of the edge  [0,90]
79
// dist - often in a polygon the distance from edge to center is not 1, but something else.
80
// This is the distance.
81
// K - where to begin the second, much more flat part of the band. [0,1]
82
// N - number of bands. N>=3
83
//
84
// theory: two distinct parts to the band:
85
// 1) (0,B) - steep
86
// 2) (B,1) - flat
87
//
88
// In first part, we have y = g(x) ; in second - y = g(f(x)) where
89
//
90
// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha)
91
// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B)
92
// h(x) = R*(sin(alpha) - sin(x))
93
// R = H/(1-cos(alpha))
94
// D = H*sin(alpha)
95
// B = h(K*alpha)
96
//
97
// The N points are taken at:
98
//
99
// 1) in the second part, there are K2 = (N-3)/3 such points
100
// 2) in the first - K1 = (N-3) - K2
101
// 3) also, the 3 points 0,B,1
102
//
103
// so we have the sequence A[i] of N points
104
//
105
// 0
106
// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1)
107
// B
108
// (1-B)*(i+1)/(K2+1) + B   (i=0,i,...,K2-1)
109
// 1
110
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
113
  private float f(float D, float B, float x)
114
    {
115
    return ((D-B)*x + B*(1-D))/(1-B);
116
    }
117
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119
120
  private float g(float R, float D, float x, float cosAlpha)
121
    {
122
    float d = x-D;
123
    return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
124
    }
125
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127
128
  private float h(float R, float sinAlpha, float x)
129
    {
130
    return R*(sinAlpha-(float)Math.sin(x));
131
    }
132
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134
135 55f20739 Leszek Koltunski
  float[] computeBands(float H, int alpha, float dist, float K, int N)
136 7edab735 Leszek Koltunski
    {
137
    float[] bands = new float[2*N];
138
139
    bands[0] = 1.0f;
140
    bands[1] = 0.0f;
141
142
    float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
143
    float sinBeta = (float)Math.sin(beta);
144
    float cosBeta = (float)Math.cos(beta);
145
    float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
146
    float D = R*sinBeta;
147
    float B = h(R,sinBeta,K*beta);
148
149
    if( D>1.0f )
150
      {
151
      for(int i=1; i<N; i++)
152
        {
153
        bands[2*i  ] = (float)(N-1-i)/(N-1);
154
        bands[2*i+1] = H*(1-bands[2*i]);
155
        }
156
      }
157
    else
158
      {
159 55f20739 Leszek Koltunski
      int K2 = (int)((N-3)*K);
160 7edab735 Leszek Koltunski
      int K1 = (N-3)-K2;
161
162
      for(int i=0; i<=K1; i++)
163
        {
164
        float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
165
        float x = h(R,sinBeta,angle);
166
        bands[2*i+2] = 1.0f - x;
167
        bands[2*i+3] = g(R,D,x,cosBeta);
168
        }
169
170
      for(int i=0; i<=K2; i++)
171
        {
172
        float x = (1-B)*(i+1)/(K2+1) + B;
173
        bands[2*K1+2 + 2*i+2] = 1.0f - x;
174
        bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
175
        }
176
      }
177
178 55f20739 Leszek Koltunski
    bands[2*N-2] = 0.0f;
179
    bands[2*N-1] =    H;
180
181 7edab735 Leszek Koltunski
    return bands;
182
    }
183
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185
186
  private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
187
    {
188
    Static4D reg= new Static4D(0,0,0,regionRadius);
189
190
    float centX = center.get0();
191
    float centY = center.get1();
192
    float centZ = center.get2();
193
194
    for (Static3D vertex : vertices)
195
      {
196
      float x = strength*(centX - vertex.get0());
197
      float y = strength*(centY - vertex.get1());
198
      float z = strength*(centZ - vertex.get2());
199
200
      VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
201
      mesh.apply(effect);
202
      }
203
    }
204
205 7cd30f7c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
206 63fb0859 Leszek Koltunski
// Compute (rx,ry) - coords of a point which is the result of rotation by angle 'radians' of the point
207
// (px,py) along axis Z. Center of rotation: (cx,cy). Rotation is counterclockwise!
208 7cd30f7c Leszek Koltunski
// Write (rx,ry) to array[index] and array[index+1].
209
210 63fb0859 Leszek Koltunski
  private void writeVertex( float cx, float cy, float px, float py, float radians, float[] array, int index)
211 7cd30f7c Leszek Koltunski
    {
212
    float vx = px-cx;
213
    float vy = py-cy;
214
215 63fb0859 Leszek Koltunski
    float sinA = (float)Math.sin(radians);
216
    float cosA = (float)Math.cos(radians);
217 7cd30f7c Leszek Koltunski
218 63fb0859 Leszek Koltunski
    float rvx = vx*cosA - vy*sinA;
219
    float rvy = vx*sinA + vy*cosA;
220 7cd30f7c Leszek Koltunski
221
    array[index  ] = rvx + cx;
222
    array[index+1] = rvy + cy;
223
    }
224
225 7edab735 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
226
227 55f20739 Leszek Koltunski
  MeshBase createFacesCube(int sizeIndex)
228 7edab735 Leszek Koltunski
    {
229 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[6];
230 7edab735 Leszek Koltunski
231 55f20739 Leszek Koltunski
    float E = 0.5f;
232
    int extraI, extraV, num;
233 7edab735 Leszek Koltunski
234 55f20739 Leszek Koltunski
    switch(sizeIndex)
235 7edab735 Leszek Koltunski
      {
236 55f20739 Leszek Koltunski
      case 0 : num = 6; extraI = 2; extraV = 2; break;
237
      case 1 : num = 5; extraI = 2; extraV = 2; break;
238
      case 2 : num = 5; extraI = 1; extraV = 2; break;
239
      default: num = 4; extraI = 1; extraV = 1; break;
240 7edab735 Leszek Koltunski
      }
241
242 55f20739 Leszek Koltunski
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
243
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
244 7edab735 Leszek Koltunski
245 55f20739 Leszek Koltunski
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
246
    meshes[0].setEffectAssociation(0,1,0);
247
    meshes[1] = meshes[0].copy(true);
248
    meshes[1].setEffectAssociation(0,2,0);
249
    meshes[2] = meshes[0].copy(true);
250
    meshes[2].setEffectAssociation(0,4,0);
251
    meshes[3] = meshes[0].copy(true);
252
    meshes[3].setEffectAssociation(0,8,0);
253
    meshes[4] = meshes[0].copy(true);
254
    meshes[4].setEffectAssociation(0,16,0);
255
    meshes[5] = meshes[0].copy(true);
256
    meshes[5].setEffectAssociation(0,32,0);
257 7edab735 Leszek Koltunski
258
    return new MeshJoined(meshes);
259
    }
260
261
///////////////////////////////////////////////////////////////////////////////////////////////////
262
263
  MeshBase createFacesSkewbCorner()
264
    {
265
    MeshBase[] meshes = new MeshBase[6];
266
267
    float E = 0.5f;
268
    float F = SQ2/2;
269 55f20739 Leszek Koltunski
    float G = SQ6/16;
270 7edab735 Leszek Koltunski
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
271 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
272 7edab735 Leszek Koltunski
273
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
274
    meshes[0].setEffectAssociation(0,1,0);
275
    meshes[1] = meshes[0].copy(true);
276
    meshes[1].setEffectAssociation(0,2,0);
277
    meshes[2] = meshes[0].copy(true);
278
    meshes[2].setEffectAssociation(0,4,0);
279
280 55f20739 Leszek Koltunski
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
281 7edab735 Leszek Koltunski
    float[] bands1 = computeBands(0,0,1,0,3);
282
283
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
284
    meshes[3].setEffectAssociation(0,8,0);
285
    meshes[4] = meshes[3].copy(true);
286
    meshes[4].setEffectAssociation(0,16,0);
287
    meshes[5] = meshes[3].copy(true);
288
    meshes[5].setEffectAssociation(0,32,0);
289
290
    return new MeshJoined(meshes);
291
    }
292
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294
295
  MeshBase createFacesSkewbFace()
296
    {
297
    MeshBase[] meshes = new MeshBase[5];
298
299
    float E = SQ2/4;
300
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
301 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
302 7edab735 Leszek Koltunski
303
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
304
    meshes[0].setEffectAssociation(0,1,0);
305
306 6af1e973 Leszek Koltunski
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
307 7edab735 Leszek Koltunski
    float[] bands1 = computeBands(0,0,1,0,3);
308
309
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
310
    meshes[1].setEffectAssociation(0,2,0);
311
    meshes[2] = meshes[1].copy(true);
312
    meshes[2].setEffectAssociation(0,4,0);
313
    meshes[3] = meshes[1].copy(true);
314
    meshes[3].setEffectAssociation(0,8,0);
315
    meshes[4] = meshes[1].copy(true);
316
    meshes[4].setEffectAssociation(0,16,0);
317
318
    return new MeshJoined(meshes);
319
    }
320
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322
323
  MeshBase createFacesOcta()
324
    {
325 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[8];
326 7edab735 Leszek Koltunski
327 55f20739 Leszek Koltunski
    float E = 0.75f;
328 7edab735 Leszek Koltunski
    float F = 0.5f;
329
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
330 55f20739 Leszek Koltunski
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
331 7edab735 Leszek Koltunski
332
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
333 55f20739 Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
334
    meshes[1] = meshes[0].copy(true);
335
    meshes[1].setEffectAssociation(0,2,0);
336
    meshes[2] = meshes[0].copy(true);
337
    meshes[2].setEffectAssociation(0,4,0);
338
    meshes[3] = meshes[0].copy(true);
339
    meshes[3].setEffectAssociation(0,8,0);
340
    meshes[4] = meshes[0].copy(true);
341
    meshes[4].setEffectAssociation(0,16,0);
342
    meshes[5] = meshes[0].copy(true);
343
    meshes[5].setEffectAssociation(0,32,0);
344
    meshes[6] = meshes[0].copy(true);
345
    meshes[6].setEffectAssociation(0,64,0);
346
    meshes[7] = meshes[0].copy(true);
347
    meshes[7].setEffectAssociation(0,128,0);
348 7edab735 Leszek Koltunski
349
    return new MeshJoined(meshes);
350
    }
351
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353
354
  MeshBase createFacesTetra()
355
    {
356
    MeshBase[] meshes = new MeshBase[4];
357
358 55f20739 Leszek Koltunski
    float E = 0.75f;
359 7edab735 Leszek Koltunski
    float F = 0.5f;
360
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
361 55f20739 Leszek Koltunski
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
362 7edab735 Leszek Koltunski
363
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
364 55f20739 Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
365
    meshes[1] = meshes[0].copy(true);
366
    meshes[1].setEffectAssociation(0,2,0);
367
    meshes[2] = meshes[0].copy(true);
368
    meshes[2].setEffectAssociation(0,4,0);
369
    meshes[3] = meshes[0].copy(true);
370
    meshes[3].setEffectAssociation(0,8,0);
371 7edab735 Leszek Koltunski
372
    return new MeshJoined(meshes);
373
    }
374
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376
377
  MeshBase createFacesDino()
378
    {
379 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[4];
380 7edab735 Leszek Koltunski
381
    float E = 0.5f*SQ2;
382
    float F = 0.5f;
383
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
384 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
385 7edab735 Leszek Koltunski
386
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
387
    meshes[0].setEffectAssociation(0,1,0);
388
    meshes[1] = meshes[0].copy(true);
389
    meshes[1].setEffectAssociation(0,2,0);
390
391
    float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
392
    float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3);
393
394
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
395
    meshes[2].setEffectAssociation(0,4,0);
396
    meshes[3] = meshes[2].copy(true);
397
    meshes[3].setEffectAssociation(0,8,0);
398
399
    return new MeshJoined(meshes);
400
    }
401
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403
404
  MeshBase createFacesHelicopterCorner()
405
    {
406
    MeshBase[] meshes = new MeshBase[6];
407
408
    float E = 0.5f;
409
    float F = SQ2/4;
410
    float G = 1.0f/12;
411
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
412 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
413 7edab735 Leszek Koltunski
414
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
415
    meshes[0].setEffectAssociation(0,1,0);
416
    meshes[1] = meshes[0].copy(true);
417
    meshes[1].setEffectAssociation(0,2,0);
418
    meshes[2] = meshes[0].copy(true);
419
    meshes[2].setEffectAssociation(0,4,0);
420
421
    float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
422
    float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
423
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
424
    meshes[3].setEffectAssociation(0,8,0);
425
    meshes[4] = meshes[3].copy(true);
426
    meshes[4].setEffectAssociation(0,16,0);
427
    meshes[5] = meshes[3].copy(true);
428
    meshes[5].setEffectAssociation(0,32,0);
429
430
    return new MeshJoined(meshes);
431
    }
432
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434
435
  MeshBase createFacesHelicopterFace()
436
    {
437
    MeshBase[] meshes = new MeshBase[4];
438
439
    float E = 0.5f;
440
    float F = SQ2/4;
441
    float G = 1.0f/12;
442
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
443 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
444 7edab735 Leszek Koltunski
445
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
446
    meshes[0].setEffectAssociation(0,1,0);
447
448
    float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
449
    float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
450
451
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
452
    meshes[1].setEffectAssociation(0,2,0);
453
454
    float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
455
456
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
457
    meshes[2].setEffectAssociation(0,4,0);
458
    meshes[3] = meshes[2].copy(true);
459
    meshes[3].setEffectAssociation(0,8,0);
460
461
    return new MeshJoined(meshes);
462
    }
463
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465
466
  MeshBase createFacesRediEdge()
467
    {
468 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[6];
469 7edab735 Leszek Koltunski
470 55f20739 Leszek Koltunski
    float F = 0.25f;
471 7edab735 Leszek Koltunski
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
472 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
473 7edab735 Leszek Koltunski
474
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
475
    meshes[0].setEffectAssociation(0,1,0);
476
    meshes[1] = meshes[0].copy(true);
477
    meshes[1].setEffectAssociation(0,2,0);
478
479 55f20739 Leszek Koltunski
    float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
480 7edab735 Leszek Koltunski
    float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
481
482
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
483
    meshes[2].setEffectAssociation(0,4,0);
484
    meshes[3] = meshes[2].copy(true);
485
    meshes[3].setEffectAssociation(0,8,0);
486
487
    float X = 0.25f*SQ2;
488
    float Y = SQ6/16;
489
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
490
491
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
492
    meshes[4].setEffectAssociation(0,16,0);
493
    meshes[5] = meshes[4].copy(true);
494
    meshes[5].setEffectAssociation(0,32,0);
495
496
    return new MeshJoined(meshes);
497
    }
498
499
///////////////////////////////////////////////////////////////////////////////////////////////////
500
501
  MeshBase createFacesRediCorner()
502
    {
503 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshBase[6];
504 7edab735 Leszek Koltunski
505
    float E = 0.5f;
506 55f20739 Leszek Koltunski
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
507
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
508 7edab735 Leszek Koltunski
509 55f20739 Leszek Koltunski
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
510 7edab735 Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
511
    meshes[1] = meshes[0].copy(true);
512
    meshes[1].setEffectAssociation(0,2,0);
513
    meshes[2] = meshes[0].copy(true);
514
    meshes[2].setEffectAssociation(0,4,0);
515
516 55f20739 Leszek Koltunski
    float F = 0.5f;
517 7edab735 Leszek Koltunski
    float X = 0.5f;
518
    float G = 0.72f;
519 55f20739 Leszek Koltunski
    float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F };
520
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
521 7edab735 Leszek Koltunski
522 55f20739 Leszek Koltunski
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
523 7edab735 Leszek Koltunski
    meshes[3].setEffectAssociation(0,8,0);
524
    meshes[4] = meshes[3].copy(true);
525
    meshes[4].setEffectAssociation(0,16,0);
526
    meshes[5] = meshes[3].copy(true);
527
    meshes[5].setEffectAssociation(0,32,0);
528
529
    return new MeshJoined(meshes);
530
    }
531
532 55f20739 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
533
534
  MeshBase createFacesIvyCorner()
535
    {
536
    MeshBase[] meshes = new MeshBase[6];
537
538
    final float angle = (float)Math.PI/(2*IVY_N);
539 1c41c4c9 Leszek Koltunski
    final float CORR  = 1.0f - 2*IVY_D;
540
    final float DIST  = -0.5f*CORR + IVY_D;
541
    float[] vertices  = new float[2*(IVY_N+1)+6];
542 55f20739 Leszek Koltunski
543 1c41c4c9 Leszek Koltunski
    vertices[0] = (0.5f-IVY_M) * IVY_C;
544
    vertices[1] = (DIST-IVY_M) * IVY_C;
545
    vertices[2] = (0.5f-IVY_M) * IVY_C;
546
    vertices[3] = (0.5f-IVY_M) * IVY_C;
547
    vertices[4] = (DIST-IVY_M) * IVY_C;
548
    vertices[5] = (0.5f-IVY_M) * IVY_C;
549 55f20739 Leszek Koltunski
550
    for(int i=0; i<=IVY_N; i++)
551
      {
552 1c41c4c9 Leszek Koltunski
      float ang = (IVY_N-i)*angle;
553
      float sin = (float)Math.sin(ang);
554
      float cos = (float)Math.cos(ang);
555 55f20739 Leszek Koltunski
556 1c41c4c9 Leszek Koltunski
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
557
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
558 55f20739 Leszek Koltunski
      }
559
560 1c41c4c9 Leszek Koltunski
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
561
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
562 55f20739 Leszek Koltunski
563 1c41c4c9 Leszek Koltunski
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
564 55f20739 Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
565
    meshes[1] = meshes[0].copy(true);
566
    meshes[1].setEffectAssociation(0,2,0);
567
    meshes[2] = meshes[0].copy(true);
568
    meshes[2].setEffectAssociation(0,4,0);
569 1c41c4c9 Leszek Koltunski
    meshes[3] = new MeshPolygon(vertices,bands1,1,2);
570 55f20739 Leszek Koltunski
    meshes[3].setEffectAssociation(0,8,0);
571
    meshes[4] = meshes[3].copy(true);
572
    meshes[4].setEffectAssociation(0,16,0);
573
    meshes[5] = meshes[3].copy(true);
574
    meshes[5].setEffectAssociation(0,32,0);
575
576
    return new MeshJoined(meshes);
577
    }
578
579
///////////////////////////////////////////////////////////////////////////////////////////////////
580
581
  MeshBase createFacesIvyFace()
582
    {
583
    MeshBase[] meshes = new MeshBase[2];
584
585
    final float angle = (float)Math.PI/(2*IVY_N);
586
    final float CORR  = 1.0f - IVY_D*SQ2;
587
    float[] vertices = new float[4*IVY_N];
588
589
    for(int i=0; i<IVY_N; i++)
590
      {
591
      float sin = (float)Math.sin(i*angle);
592
      float cos = (float)Math.cos(i*angle);
593
594
      vertices[2*i          ] = CORR*(0.5f-cos);
595
      vertices[2*i+1        ] = CORR*(0.5f-sin);
596
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
597
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
598
      }
599
600
    float[] bands0 = computeBands(+0.05f,35,0.5f,0.5f,5);
601
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
602
603
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
604
    meshes[0].setEffectAssociation(0,1,0);
605
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
606
    meshes[1].setEffectAssociation(0,2,0);
607
608
    return new MeshJoined(meshes);
609
    }
610
611 7cd30f7c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
612
613
  MeshBase createFacesRexCorner()
614
    {
615
    MeshBase[] meshes = new MeshBase[2];
616
617
    final float angle = (float)Math.PI/(6*REX_N);
618
    float[] vertices = new float[6*REX_N];
619
    final float D = 0.5f - REX_D;
620 63fb0859 Leszek Koltunski
    final float F = D*SQ2*(SQ3-1);
621
    final float B = 2.5f;
622 7cd30f7c Leszek Koltunski
623
    final float V1x = -F*0.5f;
624
    final float V1y = -F*SQ3/6;
625
    final float V2x = -V1x;
626
    final float V2y = V1y;
627
    final float V3x = 0.0f;
628
    final float V3y = -2*V1y;
629
630
    final float C1x = 0.0f;
631 63fb0859 Leszek Koltunski
    final float C1y = -F*(1+2*SQ3/3);
632
    final float C2x = B*V1x;
633
    final float C2y = B*V1y;
634
    final float C3x = B*V2x;
635
    final float C3y = B*V2y;
636 7cd30f7c Leszek Koltunski
637
    for(int i=0; i<REX_N; i++)
638
      {
639 63fb0859 Leszek Koltunski
      writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i          );
640 7cd30f7c Leszek Koltunski
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
641
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
642
      }
643
644 63fb0859 Leszek Koltunski
    float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
645 7cd30f7c Leszek Koltunski
    float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
646
647
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
648
    meshes[0].setEffectAssociation(0,1,0);
649
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
650
    meshes[1].setEffectAssociation(0,2,0);
651
652
    return new MeshJoined(meshes);
653
    }
654
655
///////////////////////////////////////////////////////////////////////////////////////////////////
656
657
  MeshBase createFacesRexFace()
658
    {
659
    MeshBase[] meshes = new MeshBase[2];
660
661
    final float angle = (float)Math.PI/(6*REX_N);
662
    float[] vertices = new float[8*REX_N];
663
    final float D = 0.5f - REX_D;
664 63fb0859 Leszek Koltunski
    final float F = D*(SQ3-1);
665 7cd30f7c Leszek Koltunski
666
    final float V1x = 0.0f;
667
    final float V1y = +F;
668 63fb0859 Leszek Koltunski
    final float V2x = -F;
669 7cd30f7c Leszek Koltunski
    final float V2y = 0.0f;
670
    final float V3x = 0.0f;
671
    final float V3y = -F;
672 63fb0859 Leszek Koltunski
    final float V4x = +F;
673 7cd30f7c Leszek Koltunski
    final float V4y = 0.0f;
674
675 63fb0859 Leszek Koltunski
    final float C1x = +D;
676 7cd30f7c Leszek Koltunski
    final float C1y = -D;
677 63fb0859 Leszek Koltunski
    final float C2x = +D;
678 7cd30f7c Leszek Koltunski
    final float C2y = +D;
679 63fb0859 Leszek Koltunski
    final float C3x = -D;
680 7cd30f7c Leszek Koltunski
    final float C3y = +D;
681 63fb0859 Leszek Koltunski
    final float C4x = -D;
682 7cd30f7c Leszek Koltunski
    final float C4y = -D;
683
684
    for(int i=0; i<REX_N; i++)
685
      {
686
      writeVertex(C1x,C1y,V1x,V1y, i*angle, vertices, 2*i          );
687
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
688
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
689
      writeVertex(C4x,C4y,V4x,V4y, i*angle, vertices, 2*i + 6*REX_N);
690
      }
691
692 63fb0859 Leszek Koltunski
    float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
693 7cd30f7c Leszek Koltunski
    float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
694
695
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
696
    meshes[0].setEffectAssociation(0,1,0);
697
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
698
    meshes[1].setEffectAssociation(0,2,0);
699
700
    return new MeshJoined(meshes);
701
    }
702
703
///////////////////////////////////////////////////////////////////////////////////////////////////
704
705
  MeshBase createFacesRexEdge()
706
    {
707 f7936f2f Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[6];
708 63fb0859 Leszek Koltunski
709 f7936f2f Leszek Koltunski
    float E = 0.5f - REX_D;
710
    float F = 0.5f;
711
    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
712
    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
713 7cd30f7c Leszek Koltunski
714 f7936f2f Leszek Koltunski
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
715 7cd30f7c Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
716
    meshes[1] = meshes[0].copy(true);
717
    meshes[1].setEffectAssociation(0,2,0);
718 f7936f2f Leszek Koltunski
719
    float G = (float)Math.sqrt(E*E+F*F);
720
    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
721
    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
722
723
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
724 7cd30f7c Leszek Koltunski
    meshes[2].setEffectAssociation(0,4,0);
725
    meshes[3] = meshes[2].copy(true);
726
    meshes[3].setEffectAssociation(0,8,0);
727 f7936f2f Leszek Koltunski
    meshes[4] = meshes[2].copy(true);
728
    meshes[4].setEffectAssociation(0,16,0);
729
    meshes[5] = meshes[2].copy(true);
730
    meshes[5].setEffectAssociation(0,32,0);
731
732 7cd30f7c Leszek Koltunski
    return new MeshJoined(meshes);
733
    }
734
735 fe032f52 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
736
737
  MeshBase createFacesMinxCorner()
738
    {
739
    MeshBase[] meshes = new MeshPolygon[6];
740
741
    float X1= (SQ5+1)/8;
742
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
743
    float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
744
    float H = 0.5f*MINX_C1/MINX_C3;
745
    float X2= H*MINX_C5;
746
    float Y3= H/(2*MINX_C4);
747
    float Y4= H*(1/(2*MINX_C4) - MINX_C4);
748
749
    float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
750
    float[] bands0 = computeBands(0.03f,39,0.3f,0.2f,5);
751
    float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 };
752 e0838536 Leszek Koltunski
    float[] bands1 = computeBands(0.00f,27,0.25f,0.5f,5);
753 fe032f52 Leszek Koltunski
754
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
755
    meshes[0].setEffectAssociation(0, 1,0);
756
    meshes[1] = meshes[0].copy(true);
757
    meshes[1].setEffectAssociation(0, 2,0);
758
    meshes[2] = meshes[0].copy(true);
759
    meshes[2].setEffectAssociation(0, 4,0);
760 e0838536 Leszek Koltunski
    meshes[3] = new MeshPolygon(vertices1, bands1, 1, 1);
761 fe032f52 Leszek Koltunski
    meshes[3].setEffectAssociation(0, 8,0);
762
    meshes[4] = meshes[3].copy(true);
763
    meshes[4].setEffectAssociation(0,16,0);
764
    meshes[5] = meshes[3].copy(true);
765
    meshes[5].setEffectAssociation(0,32,0);
766
767
    return new MeshJoined(meshes);
768
    }
769
770 55f20739 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
771
// EFFECTS
772 7edab735 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
773
774
  VertexEffect[] createVertexEffectsCube()
775
    {
776
    Static3D axisY   = new Static3D(0,1,0);
777
    Static3D axisX   = new Static3D(1,0,0);
778
    Static3D center  = new Static3D(0,0,0);
779
    Static1D angle90 = new Static1D(90);
780
    Static1D angle180= new Static1D(180);
781
    Static1D angle270= new Static1D(270);
782
783
    VertexEffect[] effect = new VertexEffect[6];
784
785
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
786
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
787
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
788
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
789
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
790
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
791
792
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
793
    effect[1].setMeshAssociation(32,-1);  // back
794
    effect[2].setMeshAssociation( 8,-1);  // bottom
795
    effect[3].setMeshAssociation( 4,-1);  // top
796
    effect[4].setMeshAssociation( 2,-1);  // left
797
    effect[5].setMeshAssociation( 1,-1);  // right
798
799
    return effect;
800
    }
801
802
///////////////////////////////////////////////////////////////////////////////////////////////////
803
804
  VertexEffect[] createVertexEffectsSkewbCorner()
805
    {
806
    float E = 0.5f;
807
808
    Static3D axisX  = new Static3D(1,0,0);
809
    Static3D axisY  = new Static3D(0,1,0);
810
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
811
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
812
    Static1D angle1 = new Static1D(+90);
813
    Static1D angle2 = new Static1D(-90);
814
    Static1D angle3 = new Static1D(-15);
815
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
816
    Static1D angle5 = new Static1D(120);
817
    Static1D angle6 = new Static1D(240);
818
    Static3D center1= new Static3D(0,0,0);
819
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
820
    Static3D move1  = new Static3D(-E/4,-E/4,0);
821 55f20739 Leszek Koltunski
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
822 7edab735 Leszek Koltunski
823
    VertexEffect[] effect = new VertexEffect[10];
824
825
    effect[0] = new VertexEffectMove(move1);
826
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
827
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
828
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
829
    effect[4] = new VertexEffectMove(move2);
830
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
831
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
832
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
833
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
834
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
835
836
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
837
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
838
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
839
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
840
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
841
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
842
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
843
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
844
    effect[8].setMeshAssociation(16,-1);  // mesh 4
845
    effect[9].setMeshAssociation(32,-1);  // mesh 5
846
847
    return effect;
848
    }
849
850
///////////////////////////////////////////////////////////////////////////////////////////////////
851
852
  VertexEffect[] createVertexEffectsSkewbFace()
853
    {
854
    Static3D center = new Static3D(0,0,0);
855
    Static3D axisX  = new Static3D(1,0,0);
856
    Static3D axisZ  = new Static3D(0,0,1);
857
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
858
859
    VertexEffect[] effect = new VertexEffect[6];
860
861
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
862
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
863
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
864
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
865
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
866
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
867
868
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
869
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
870
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
871
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
872
    effect[4].setMeshAssociation(16,-1);  // mesh 4
873
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
874
875
    return effect;
876
    }
877
878
///////////////////////////////////////////////////////////////////////////////////////////////////
879
880
  VertexEffect[] createVertexEffectsOcta()
881
    {
882
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
883
    Static1D angle1= new Static1D( 90);
884
    Static1D angle2= new Static1D(180);
885
    Static1D angle3= new Static1D(270);
886
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
887
    Static3D axisX = new Static3D(1,0,0);
888
    Static3D axisY = new Static3D(0,1,0);
889
    Static3D cent0 = new Static3D(0,0,0);
890
    Static3D cent1 = new Static3D(0,SQ2/2,0);
891
    Static3D flipY = new Static3D( 1,-1, 1);
892 55f20739 Leszek Koltunski
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
893 7edab735 Leszek Koltunski
894 55f20739 Leszek Koltunski
    VertexEffect[] effect = new VertexEffect[7];
895 7edab735 Leszek Koltunski
896 55f20739 Leszek Koltunski
    effect[0] = new VertexEffectScale(scale);
897
    effect[1] = new VertexEffectMove(move1);
898
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
899
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
900
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
901
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
902
    effect[6] = new VertexEffectScale(flipY);
903 7edab735 Leszek Koltunski
904 55f20739 Leszek Koltunski
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
905
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
906
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
907
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
908 7edab735 Leszek Koltunski
909
    return effect;
910
    }
911
912
///////////////////////////////////////////////////////////////////////////////////////////////////
913
914
  VertexEffect[] createVertexEffectsTetra()
915
    {
916
    Static3D flipZ = new Static3D( 1, 1,-1);
917
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
918
    Static1D angle1= new Static1D( 90);
919
    Static1D angle2= new Static1D(180);
920
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
921
    Static3D axisX = new Static3D(1,0,0);
922
    Static3D axisY = new Static3D(0,1,0);
923
    Static3D axisZ = new Static3D(0,0,1);
924
    Static3D cent0 = new Static3D(0,0,0);
925
    Static3D cent1 = new Static3D(0,SQ2/4,0);
926 55f20739 Leszek Koltunski
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
927 7edab735 Leszek Koltunski
928 55f20739 Leszek Koltunski
    VertexEffect[] effect = new VertexEffect[7];
929 7edab735 Leszek Koltunski
930 55f20739 Leszek Koltunski
    effect[0] = new VertexEffectScale(scale);
931
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
932
    effect[2] = new VertexEffectMove(move1);
933
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
934
    effect[4] = new VertexEffectScale(flipZ);
935
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
936
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
937
938
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
939 7edab735 Leszek Koltunski
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
940 55f20739 Leszek Koltunski
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
941 7edab735 Leszek Koltunski
942
    return effect;
943
    }
944
945
///////////////////////////////////////////////////////////////////////////////////////////////////
946
947
  VertexEffect[] createVertexEffectsDino()
948
    {
949
    float E = 0.5f*SQ2;
950
    float F = 0.5f;
951
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
952
953
    Static1D angle1 = new Static1D(-ANGLE);
954
    Static1D angle2 = new Static1D(+ANGLE);
955
    Static3D axisX  = new Static3D(1,0,0);
956
    Static3D axisY  = new Static3D(0,1,0);
957
    Static3D axisZ  = new Static3D(0,-1,1);
958
    Static3D center0= new Static3D(0,0,0);
959
    Static3D center1= new Static3D(0,-3*F,0);
960
961
    VertexEffect[] effect = new VertexEffect[10];
962
963
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
964
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
965
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
966
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
967
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
968
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
969
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
970
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
971
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
972
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
973
974
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
975
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
976
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
977
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 0
978
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
979
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
980
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
981
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
982
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
983
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
984
985
    return effect;
986
    }
987
988
///////////////////////////////////////////////////////////////////////////////////////////////////
989
990
  VertexEffect[] createVertexEffectsHelicopterCorner()
991
    {
992
    float E = 0.5f;
993
994
    Static3D axisX  = new Static3D(1,0,0);
995
    Static3D axisY  = new Static3D(0,1,0);
996
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
997
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
998
    Static1D angle1 = new Static1D(+90);
999
    Static1D angle2 = new Static1D(-90);
1000
    Static1D angle3 = new Static1D(-135);
1001
    Static1D angle4 = new Static1D(90);
1002
    Static1D angle5 = new Static1D(120);
1003
    Static1D angle6 = new Static1D(240);
1004
    Static3D center1= new Static3D(0,0,0);
1005
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
1006
    Static3D move1  = new Static3D(-E/4,-E/4,0);
1007
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
1008
1009
    VertexEffect[] effect = new VertexEffect[10];
1010
1011
    effect[0] = new VertexEffectMove(move1);
1012
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
1013
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
1014
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
1015
    effect[4] = new VertexEffectMove(move2);
1016
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
1017
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1018
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1019
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1020
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1021
1022
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1023
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1024
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1025
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1026
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1027
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1028
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1029
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1030
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1031
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1032
1033
    return effect;
1034
    }
1035
1036
///////////////////////////////////////////////////////////////////////////////////////////////////
1037
1038
  VertexEffect[] createVertexEffectsHelicopterFace()
1039
    {
1040
    float E = 0.5f;
1041
    float F = SQ2/4;
1042
1043
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1044
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1045
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1046
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1047
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1048
    Static1D angle1 = new Static1D(135);
1049
    Static1D angle2 = new Static1D(90);
1050
    Static1D angle3 = new Static1D(-90);
1051
    Static1D angle4 = new Static1D(-135);
1052
    Static3D axisX  = new Static3D(1,0,0);
1053
    Static3D axisY  = new Static3D(0,1,0);
1054
    Static3D axisZ  = new Static3D(0,0,1);
1055
    Static3D axis1  = new Static3D(1,-1,0);
1056
    Static3D center = new Static3D(0,0,0);
1057
    Static3D center1= new Static3D(-E/2,-E/2,0);
1058
1059
    VertexEffect[] effect = new VertexEffect[10];
1060
1061
    effect[0] = new VertexEffectMove(move0);
1062
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1063
    effect[2] = new VertexEffectMove(move1);
1064
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1065
    effect[4] = new VertexEffectMove(move2);
1066
    effect[5] = new VertexEffectMove(move3);
1067
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1068
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1069
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1070
    effect[9] = new VertexEffectMove(move4);
1071
1072
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1073
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1074
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1075
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1076
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1077
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1078
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1079
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1080
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1081
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1082
1083
    return effect;
1084
    }
1085
1086
///////////////////////////////////////////////////////////////////////////////////////////////////
1087
1088
  VertexEffect[] createVertexEffectsRediEdge()
1089
    {
1090
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1091
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1092
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1093
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1094
    Static3D flipZ = new Static3D(1,1,-1);
1095
    Static3D flipX = new Static3D(-1,1,1);
1096
    Static3D scale = new Static3D(2,2,2);
1097
    Static3D cent0 = new Static3D(0,0, 0);
1098
    Static3D cent1 = new Static3D(0,0, -1.5f);
1099
    Static3D axisX = new Static3D(1,0, 0);
1100
    Static3D axisY = new Static3D(0,1, 0);
1101
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1102
    Static1D angle1= new Static1D(90);
1103
    Static1D angle2= new Static1D(45);
1104
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1105
1106
    VertexEffect[] effect = new VertexEffect[12];
1107
1108
    effect[0] = new VertexEffectScale(scale);
1109
    effect[1] = new VertexEffectMove(move0);
1110
    effect[2] = new VertexEffectScale(flipZ);
1111
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1112
    effect[4] = new VertexEffectMove(move1);
1113
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1114
    effect[6] = new VertexEffectMove(move2);
1115
    effect[7] = new VertexEffectScale(flipX);
1116
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1117
    effect[9] = new VertexEffectMove(move3);
1118
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1119
    effect[11]= new VertexEffectScale(flipX);
1120
1121
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1122
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1123
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1124
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1125
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1126
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1127
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1128
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1129
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1130
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1131
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1132
    effect[11].setMeshAssociation(32,-1); // mesh 5
1133
1134
    return effect;
1135
    }
1136
1137
///////////////////////////////////////////////////////////////////////////////////////////////////
1138
1139
  VertexEffect[] createVertexEffectsRediCorner()
1140
    {
1141
    Static3D axisY   = new Static3D(0,1,0);
1142
    Static3D axisX   = new Static3D(1,0,0);
1143
    Static3D axisZ   = new Static3D(0,0,1);
1144
    Static3D center  = new Static3D(0,0,0);
1145
    Static1D angle90 = new Static1D(90);
1146
    Static1D angle270= new Static1D(270);
1147
    Static1D angle45 = new Static1D(-45);
1148 55f20739 Leszek Koltunski
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1149 7edab735 Leszek Koltunski
1150 55f20739 Leszek Koltunski
    VertexEffect[] effect = new VertexEffect[7];
1151 7edab735 Leszek Koltunski
1152
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1153
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1154
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1155 55f20739 Leszek Koltunski
    effect[3] = new VertexEffectScale(scale);
1156
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1157
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1158
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1159 7edab735 Leszek Koltunski
1160
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1161
    effect[1].setMeshAssociation( 2,-1);  // 1
1162
    effect[2].setMeshAssociation( 4,-1);  // 2
1163 55f20739 Leszek Koltunski
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1164
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1165
    effect[5].setMeshAssociation(16,-1);  // 4
1166
    effect[6].setMeshAssociation(32,-1);  // 5
1167
1168
    return effect;
1169
    }
1170
1171
///////////////////////////////////////////////////////////////////////////////////////////////////
1172
1173
  VertexEffect[] createVertexEffectsIvyCorner()
1174
    {
1175
    Static3D axisX  = new Static3D(1,0,0);
1176
    Static3D axisY  = new Static3D(0,1,0);
1177
    Static1D angle1 = new Static1D(+90);
1178
    Static1D angle2 = new Static1D(-90);
1179
    Static3D center = new Static3D(0,0,0);
1180 1c41c4c9 Leszek Koltunski
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1181 55f20739 Leszek Koltunski
1182
    VertexEffect[] effect = new VertexEffect[5];
1183
1184 1c41c4c9 Leszek Koltunski
    effect[0] = new VertexEffectScale(1/IVY_C);
1185 55f20739 Leszek Koltunski
    effect[1] = new VertexEffectMove(move1);
1186
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1187
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1188
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1189
1190
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1191
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1192
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1193 7edab735 Leszek Koltunski
1194
    return effect;
1195
    }
1196
1197 7cd30f7c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1198
1199
  VertexEffect[] createVertexEffectsRexEdge()
1200
    {
1201 f7936f2f Leszek Koltunski
    float E = 0.5f - REX_D;
1202
    float F = 0.5f;
1203
    float G = (float)Math.sqrt(E*E+F*F);
1204
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1205 7cd30f7c Leszek Koltunski
1206 f7936f2f Leszek Koltunski
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1207
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1208
1209
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1210
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1211
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1212
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1213
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1214
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1215 7cd30f7c Leszek Koltunski
1216
    Static1D angle180 = new Static1D(180);
1217
    Static1D angle90  = new Static1D( 90);
1218 f7936f2f Leszek Koltunski
    Static1D angle270 = new Static1D(270);
1219
    Static1D angle1   = new Static1D(+A);
1220
    Static1D angle2   = new Static1D(-A);
1221 7cd30f7c Leszek Koltunski
1222 f7936f2f Leszek Koltunski
    VertexEffect[] effect = new VertexEffect[12];
1223 7cd30f7c Leszek Koltunski
1224 f7936f2f Leszek Koltunski
    effect[0] = new VertexEffectMove(move1);
1225
    effect[1] = new VertexEffectMove(move2);
1226
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1227
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1228
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1229
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1230
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1231
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1232
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1233
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1234
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1235
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1236
1237
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1238
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1239
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1240
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1241
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1242
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1243
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1244
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1245
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1246
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1247
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1248
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1249 7cd30f7c Leszek Koltunski
1250
    return effect;
1251
    }
1252
1253
///////////////////////////////////////////////////////////////////////////////////////////////////
1254
1255
  VertexEffect[] createVertexEffectsRexCorner()
1256
    {
1257
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1258
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1259
    Static1D angle = new Static1D(45);
1260
1261
    VertexEffect[] effect = new VertexEffect[1];
1262
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1263
1264
    return effect;
1265
    }
1266
1267 fe032f52 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1268
1269
  VertexEffect[] createVertexEffectsMinxCorner()
1270
    {
1271
    VertexEffect[] effect = new VertexEffect[9];
1272
1273
    float H = 0.5f*(MINX_C1/MINX_C3);
1274
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1275
    float Y2= H/(2*MINX_C4);
1276
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1277
    float sin18 = MINX_C0;
1278
    float cos18 = (float)(Math.sqrt(1-MINX_C0*MINX_C0));
1279
    float LEN   = (float)Math.sqrt(H*H/(MINX_C4*MINX_C4) + 0.25f);
1280
1281
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1282
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1283
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1284
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*MINX_C5/(MINX_C4*LEN));
1285
1286
    Static3D move1 = new Static3D(0,-Y1,0);
1287
    Static3D move2 = new Static3D(0,-Y2,0);
1288
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1289
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1290
1291
    Static1D angle1 = new Static1D(54);
1292
    Static1D angle2 = new Static1D(A/2+18);
1293
    Static1D angle3 = new Static1D(90);
1294
    Static1D angle4 = new Static1D(120);
1295
    Static1D angle5 = new Static1D(240);
1296
    Static1D angle6 = new Static1D(90-A/2);
1297
1298
    effect[0] = new VertexEffectMove(move1);
1299
    effect[1] = new VertexEffectMove(move2);
1300
    effect[2] = new VertexEffectRotate(angle1, axisZ, center);
1301
    effect[3] = new VertexEffectRotate(angle2, axisZ, center);
1302
    effect[4] = new VertexEffectRotate(angle3, axisA, center);
1303
    effect[5] = new VertexEffectMove(move3);
1304
    effect[6] = new VertexEffectRotate(angle4, axisC, center);
1305
    effect[7] = new VertexEffectRotate(angle5, axisC, center);
1306
    effect[8] = new VertexEffectRotate(angle6, axisY, center);
1307
1308
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1309
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1310
    effect[2].setMeshAssociation( 7,-1);  // meshes 0,1,2
1311
    effect[3].setMeshAssociation(56,-1);  // meshes 3,4,5
1312
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1313
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1314
    effect[6].setMeshAssociation(18,-1);  // meshes 1,4
1315
    effect[7].setMeshAssociation(36,-1);  // meshes 2,5
1316
1317
    return effect;
1318
    }
1319
1320 7edab735 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1321
// OBJECTS
1322
///////////////////////////////////////////////////////////////////////////////////////////////////
1323
// CUBE
1324
1325
  MeshBase createCubeMesh(int index)
1326
    {
1327
    MeshBase mesh = createFacesCube(index);
1328
    VertexEffect[] effects = createVertexEffectsCube();
1329
    for( VertexEffect effect : effects ) mesh.apply(effect);
1330
1331
    Static3D roundingCenter  = new Static3D(0,0,0);
1332
    Static3D[] vertices = new Static3D[8];
1333
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1334
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1335
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1336
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1337
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1338
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1339
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1340
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1341 55f20739 Leszek Koltunski
1342 7edab735 Leszek Koltunski
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1343
1344 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1345
1346 7edab735 Leszek Koltunski
    return mesh;
1347
    }
1348
1349
///////////////////////////////////////////////////////////////////////////////////////////////////
1350
// SKEWB
1351
1352
  MeshBase createSkewbCornerMesh()
1353
    {
1354
    MeshBase mesh = createFacesSkewbCorner();
1355
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1356
    for( VertexEffect effect : effects ) mesh.apply(effect);
1357
1358
    float E = 0.5f;
1359
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1360
1361
    Static3D[] verticesType1 = new Static3D[1];
1362
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1363
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1364
1365
    Static3D[] verticesType2 = new Static3D[3];
1366
    verticesType2[0] = new Static3D(-E, 0, 0);
1367
    verticesType2[1] = new Static3D( 0,-E, 0);
1368
    verticesType2[2] = new Static3D( 0, 0,-E);
1369
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1370
1371 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1372
1373 7edab735 Leszek Koltunski
    return mesh;
1374
    }
1375
1376
///////////////////////////////////////////////////////////////////////////////////////////////////
1377
1378
  MeshBase createSkewbFaceMesh()
1379
    {
1380
    MeshBase mesh = createFacesSkewbFace();
1381
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1382
    for( VertexEffect effect : effects ) mesh.apply(effect);
1383
1384
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1385
    float E = SQ2/4;
1386
    Static3D[] vertices = new Static3D[4];
1387
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1388
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1389
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1390
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1391 55f20739 Leszek Koltunski
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1392
1393
    mesh.mergeEffComponents();
1394
    mesh.addEmptyTexComponent();
1395 7edab735 Leszek Koltunski
1396
    return mesh;
1397
    }
1398
1399
///////////////////////////////////////////////////////////////////////////////////////////////////
1400
// SKEWB DIAMOND / PYRAMINX
1401
1402
  MeshBase createOctaMesh()
1403
    {
1404
    MeshBase mesh = createFacesOcta();
1405
    VertexEffect[] effects = createVertexEffectsOcta();
1406
    for( VertexEffect effect : effects ) mesh.apply(effect);
1407
1408
    Static3D roundingCenter = new Static3D(0,0,0);
1409
    Static3D[] vertices = new Static3D[6];
1410
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1411
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1412
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1413
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1414
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1415
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1416 55f20739 Leszek Koltunski
1417 7edab735 Leszek Koltunski
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1418
1419 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1420
1421 7edab735 Leszek Koltunski
    return mesh;
1422
    }
1423
1424
///////////////////////////////////////////////////////////////////////////////////////////////////
1425
1426
  MeshBase createTetraMesh()
1427
    {
1428
    MeshBase mesh = createFacesTetra();
1429
    VertexEffect[] effects = createVertexEffectsTetra();
1430
    for( VertexEffect effect : effects ) mesh.apply(effect);
1431
1432
    Static3D roundingCenter = new Static3D(0,0,0);
1433
    Static3D[] verticesRound = new Static3D[4];
1434
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1435
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1436
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1437
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1438
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1439
1440 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1441
    mesh.addEmptyTexComponent();
1442
    mesh.addEmptyTexComponent();
1443
    mesh.addEmptyTexComponent();
1444
    mesh.addEmptyTexComponent();
1445
1446 7edab735 Leszek Koltunski
    return mesh;
1447
    }
1448
1449
///////////////////////////////////////////////////////////////////////////////////////////////////
1450
// DINO
1451
1452
  MeshBase createDinoMesh()
1453
    {
1454
    MeshBase mesh = createFacesDino();
1455
    VertexEffect[] effects = createVertexEffectsDino();
1456
    for( VertexEffect effect : effects ) mesh.apply(effect);
1457
1458
    float F = 0.5f;
1459
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1460
    Static3D[] verticesRound = new Static3D[4];
1461
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1462
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1463
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1464
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1465
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1466
1467 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1468
1469 7edab735 Leszek Koltunski
    return mesh;
1470
    }
1471
1472
///////////////////////////////////////////////////////////////////////////////////////////////////
1473
// Helicopter
1474
1475
  MeshBase createHelicopterCornerMesh()
1476
    {
1477
    MeshBase mesh = createFacesHelicopterCorner();
1478
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1479
    for( VertexEffect effect : effects ) mesh.apply(effect);
1480
1481
    float E = 0.5f;
1482
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1483
1484
    Static3D[] verticesType1 = new Static3D[1];
1485
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1486
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1487
1488
    Static3D[] verticesType2 = new Static3D[3];
1489
    verticesType2[0] = new Static3D(-E, 0, 0);
1490
    verticesType2[1] = new Static3D( 0,-E, 0);
1491
    verticesType2[2] = new Static3D( 0, 0,-E);
1492 55f20739 Leszek Koltunski
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1493
1494
    mesh.mergeEffComponents();
1495 7edab735 Leszek Koltunski
1496
    return mesh;
1497
    }
1498
1499
///////////////////////////////////////////////////////////////////////////////////////////////////
1500
1501
  MeshBase createHelicopterFaceMesh()
1502
    {
1503
    MeshBase mesh = createFacesHelicopterFace();
1504
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1505
    for( VertexEffect effect : effects ) mesh.apply(effect);
1506
1507
    float E = 0.5f;
1508
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1509
1510
    Static3D[] verticesType1 = new Static3D[1];
1511
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1512
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1513
1514
    Static3D[] verticesType2 = new Static3D[2];
1515
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1516
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1517 55f20739 Leszek Koltunski
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1518
1519
    mesh.mergeEffComponents();
1520
    mesh.addEmptyTexComponent();
1521
    mesh.addEmptyTexComponent();
1522 7edab735 Leszek Koltunski
1523
    return mesh;
1524
    }
1525
1526
///////////////////////////////////////////////////////////////////////////////////////////////////
1527
// Redi cube
1528
1529
  MeshBase createRediEdgeMesh()
1530
    {
1531
    MeshBase mesh = createFacesRediEdge();
1532
    VertexEffect[] effects = createVertexEffectsRediEdge();
1533
    for( VertexEffect effect : effects ) mesh.apply(effect);
1534
1535
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1536 55f20739 Leszek Koltunski
    Static3D[] vertices = new Static3D[2];
1537 7edab735 Leszek Koltunski
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1538
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1539
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1540
1541 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1542
1543 7edab735 Leszek Koltunski
    return mesh;
1544
    }
1545
1546
///////////////////////////////////////////////////////////////////////////////////////////////////
1547
1548
  MeshBase createRediCornerMesh()
1549
    {
1550
    MeshBase mesh = createFacesRediCorner();
1551
    VertexEffect[] effects = createVertexEffectsRediCorner();
1552
    for( VertexEffect effect : effects ) mesh.apply(effect);
1553
1554
    Static3D center = new Static3D(0,0,0);
1555
    Static3D[] vertices = new Static3D[8];
1556
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1557
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1558
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1559
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1560
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1561
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1562
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1563
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1564
1565
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1566
1567 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1568
1569
    return mesh;
1570
    }
1571
1572
///////////////////////////////////////////////////////////////////////////////////////////////////
1573
1574
  MeshBase createIvyCornerMesh()
1575
    {
1576
    MeshBase mesh = createFacesIvyCorner();
1577
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1578
    for( VertexEffect effect : effects ) mesh.apply(effect);
1579
1580
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1581
    Static3D[] vertices = new Static3D[4];
1582 1c41c4c9 Leszek Koltunski
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1583
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1584
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1585
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1586 55f20739 Leszek Koltunski
1587 1c41c4c9 Leszek Koltunski
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1588 55f20739 Leszek Koltunski
1589
    mesh.mergeEffComponents();
1590
1591
    return mesh;
1592
    }
1593
1594
///////////////////////////////////////////////////////////////////////////////////////////////////
1595
1596
  MeshBase createIvyFaceMesh()
1597
    {
1598
    MeshBase mesh = createFacesIvyFace();
1599
1600 1c41c4c9 Leszek Koltunski
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1601 55f20739 Leszek Koltunski
    Static3D[] vertices = new Static3D[2];
1602 1c41c4c9 Leszek Koltunski
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1603
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1604 55f20739 Leszek Koltunski
1605 1c41c4c9 Leszek Koltunski
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1606 55f20739 Leszek Koltunski
1607
    mesh.mergeEffComponents();
1608
    mesh.addEmptyTexComponent();
1609
    mesh.addEmptyTexComponent();
1610
    mesh.addEmptyTexComponent();
1611
    mesh.addEmptyTexComponent();
1612
1613 7cd30f7c Leszek Koltunski
    return mesh;
1614
    }
1615
1616
///////////////////////////////////////////////////////////////////////////////////////////////////
1617
1618
  MeshBase createRexCornerMesh()
1619
    {
1620
    MeshBase mesh = createFacesRexCorner();
1621
    VertexEffect[] effects = createVertexEffectsRexCorner();
1622
    for( VertexEffect effect : effects ) mesh.apply(effect);
1623
1624
    Static3D center = new Static3D(0.0f,0.0f,-0.25f);
1625
    Static3D[] vertices = new Static3D[1];
1626
    vertices[0] = new Static3D(+0.25f,+0.25f,+0.0f);
1627
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1628
1629
    mesh.mergeEffComponents();
1630
    mesh.addEmptyTexComponent();
1631
    mesh.addEmptyTexComponent();
1632
1633
    return mesh;
1634
    }
1635
1636
///////////////////////////////////////////////////////////////////////////////////////////////////
1637
1638
  MeshBase createRexFaceMesh()
1639
    {
1640
    MeshBase mesh = createFacesRexFace();
1641
1642
    mesh.mergeEffComponents();
1643
    mesh.addEmptyTexComponent();
1644
    mesh.addEmptyTexComponent();
1645
1646
    return mesh;
1647
    }
1648
1649
///////////////////////////////////////////////////////////////////////////////////////////////////
1650
1651
  MeshBase createRexEdgeMesh()
1652
    {
1653
    MeshBase mesh = createFacesRexEdge();
1654
    VertexEffect[] effects = createVertexEffectsRexEdge();
1655
    for( VertexEffect effect : effects ) mesh.apply(effect);
1656 fe032f52 Leszek Koltunski
1657 7cd30f7c Leszek Koltunski
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1658
    Static3D[] vertices = new Static3D[2];
1659
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1660
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1661 fe032f52 Leszek Koltunski
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1662 7cd30f7c Leszek Koltunski
1663
    mesh.mergeEffComponents();
1664 fe032f52 Leszek Koltunski
1665
    return mesh;
1666
    }
1667
1668
///////////////////////////////////////////////////////////////////////////////////////////////////
1669
1670
  MeshBase createMinxCornerMesh()
1671
    {
1672
    MeshBase mesh = createFacesMinxCorner();
1673
    VertexEffect[] effects = createVertexEffectsMinxCorner();
1674
    for( VertexEffect effect : effects ) mesh.apply(effect);
1675 e0838536 Leszek Koltunski
1676
    float A = (2*SQ3/3)*MINX_C1;
1677
    float B = 0.4f;
1678
    float X = MINX_C5*MINX_C1*MINX_C3;
1679
    float Y = MINX_C1*MINX_C1 - 0.5f;
1680
    float Z = MINX_C4*MINX_C1*MINX_C3;
1681
1682
    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
1683
1684
    Static3D[] vertices = new Static3D[4];
1685
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1686
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1687
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1688
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1689
1690
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1691
1692 fe032f52 Leszek Koltunski
    //mesh.mergeEffComponents();
1693
1694 7edab735 Leszek Koltunski
    return mesh;
1695
    }
1696
  }