Project

General

Profile

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

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

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