1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted 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
|
// Distorted 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 Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.examples.meshfile;
|
21
|
|
22
|
import android.content.Context;
|
23
|
import android.content.res.Resources;
|
24
|
import android.graphics.Bitmap;
|
25
|
import android.graphics.Canvas;
|
26
|
import android.graphics.Paint;
|
27
|
import android.opengl.GLSurfaceView;
|
28
|
|
29
|
import org.distorted.examples.R;
|
30
|
import org.distorted.library.effect.Effect;
|
31
|
import org.distorted.library.effect.EffectType;
|
32
|
import org.distorted.library.effect.MatrixEffectQuaternion;
|
33
|
import org.distorted.library.effect.MatrixEffectScale;
|
34
|
import org.distorted.library.effect.VertexEffectDisappear;
|
35
|
import org.distorted.library.main.DistortedEffects;
|
36
|
import org.distorted.library.main.DistortedLibrary;
|
37
|
import org.distorted.library.main.DistortedScreen;
|
38
|
import org.distorted.library.main.DistortedTexture;
|
39
|
import org.distorted.library.mesh.MeshBase;
|
40
|
import org.distorted.library.mesh.MeshFile;
|
41
|
import org.distorted.library.mesh.MeshPolygon;
|
42
|
import org.distorted.library.type.DynamicQuat;
|
43
|
import org.distorted.library.type.Static3D;
|
44
|
import org.distorted.library.type.Static4D;
|
45
|
|
46
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
47
|
|
48
|
import java.io.DataInputStream;
|
49
|
import java.io.IOException;
|
50
|
import java.io.InputStream;
|
51
|
|
52
|
import javax.microedition.khronos.egl.EGLConfig;
|
53
|
import javax.microedition.khronos.opengles.GL10;
|
54
|
|
55
|
import static org.distorted.examples.meshfile.MeshFileActivity.POLYGON;
|
56
|
import static org.distorted.examples.meshfile.MeshFileActivity.PROCEDURAL;
|
57
|
|
58
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59
|
|
60
|
class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
61
|
{
|
62
|
private static final float SQ2 = (float)Math.sqrt(2);
|
63
|
private static final float SQ3 = (float)Math.sqrt(3);
|
64
|
private static final float SQ5 = (float)Math.sqrt(5);
|
65
|
private static final float SQ6 = (float)Math.sqrt(6);
|
66
|
private final float DEFAULT_SCALE = 0.3f;
|
67
|
|
68
|
private final GLSurfaceView mView;
|
69
|
private DistortedTexture mTexture;
|
70
|
private final DistortedScreen mScreen;
|
71
|
private final DistortedEffects mEffects;
|
72
|
private final Static3D mScale;
|
73
|
private long mTime;
|
74
|
private float mCurrentScale;
|
75
|
private MeshBase mMesh;
|
76
|
|
77
|
Static4D mQuat1, mQuat2;
|
78
|
int mScreenMin;
|
79
|
|
80
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
81
|
|
82
|
MeshFileRenderer(GLSurfaceView v)
|
83
|
{
|
84
|
mView = v;
|
85
|
mScreen = new DistortedScreen();
|
86
|
mScale= new Static3D(1,1,1);
|
87
|
Static3D center=new Static3D(0,0,0);
|
88
|
|
89
|
mCurrentScale = DEFAULT_SCALE;
|
90
|
|
91
|
mQuat1 = new Static4D(0,0,0,1);
|
92
|
mQuat2 = new Static4D(0,0,0,1);
|
93
|
|
94
|
DynamicQuat quatInt1 = new DynamicQuat(0,0.5f);
|
95
|
DynamicQuat quatInt2 = new DynamicQuat(0,0.5f);
|
96
|
|
97
|
quatInt1.add(mQuat1);
|
98
|
quatInt2.add(mQuat2);
|
99
|
|
100
|
VertexEffectDisappear disappear = new VertexEffectDisappear();
|
101
|
disappear.setMeshAssociation(1,-1);
|
102
|
|
103
|
mEffects = new DistortedEffects();
|
104
|
mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
|
105
|
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
|
106
|
mEffects.apply( new MatrixEffectScale(mScale));
|
107
|
|
108
|
mEffects.apply( disappear );
|
109
|
|
110
|
mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
111
|
mScreen.showFPS();
|
112
|
}
|
113
|
|
114
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
115
|
|
116
|
public void onDrawFrame(GL10 glUnused)
|
117
|
{
|
118
|
mScreen.render( System.currentTimeMillis() );
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
|
123
|
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
124
|
{
|
125
|
mScreenMin = Math.min(width, height);
|
126
|
float factor = mCurrentScale*mScreenMin;
|
127
|
mScale.set(factor,factor,factor);
|
128
|
mScreen.resize(width, height);
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
134
|
{
|
135
|
if( mTexture==null ) mTexture = new DistortedTexture();
|
136
|
|
137
|
Effect.enableEffects(EffectType.VERTEX);
|
138
|
DistortedLibrary.setMax(EffectType.VERTEX, 20);
|
139
|
DistortedLibrary.needTransformFeedback();
|
140
|
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
141
|
}
|
142
|
|
143
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144
|
|
145
|
public void distortedException(Exception ex)
|
146
|
{
|
147
|
android.util.Log.e("MeshFile", ex.getMessage() );
|
148
|
}
|
149
|
|
150
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151
|
// 0 ---> 0
|
152
|
// 50 ---> DEFAULT_SCALE
|
153
|
// 100 ---> 4*DEFAULT_SCALE
|
154
|
|
155
|
void setScale(int scale)
|
156
|
{
|
157
|
if( scale<= 50 )
|
158
|
{
|
159
|
mCurrentScale = DEFAULT_SCALE * scale / 50.0f;
|
160
|
}
|
161
|
else
|
162
|
{
|
163
|
mCurrentScale = DEFAULT_SCALE * ( 3*(scale/50.0f) - 2.0f);
|
164
|
}
|
165
|
|
166
|
float factor = mCurrentScale*mScreenMin;
|
167
|
mScale.set(factor,factor,factor);
|
168
|
}
|
169
|
|
170
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
171
|
|
172
|
void open(int resourceID)
|
173
|
{
|
174
|
if( mTexture==null ) mTexture = new DistortedTexture();
|
175
|
mTexture.setTexture( createTexture(resourceID) );
|
176
|
|
177
|
long t1 = System.currentTimeMillis();
|
178
|
|
179
|
if( resourceID==PROCEDURAL )
|
180
|
{
|
181
|
createMesh();
|
182
|
}
|
183
|
else if( resourceID==POLYGON )
|
184
|
{
|
185
|
createPolygon();
|
186
|
}
|
187
|
else
|
188
|
{
|
189
|
openMesh(resourceID);
|
190
|
}
|
191
|
|
192
|
long t2 = System.currentTimeMillis();
|
193
|
|
194
|
mTime = t2-t1;
|
195
|
|
196
|
mScreen.detachAll();
|
197
|
mScreen.attach(mTexture,mEffects,mMesh);
|
198
|
}
|
199
|
|
200
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
201
|
|
202
|
private Bitmap createTexture(int resourceID)
|
203
|
{
|
204
|
TextureFactory factory = TextureFactory.getInstance();
|
205
|
|
206
|
float[] vertices;
|
207
|
int[] colors;
|
208
|
float F = 0.5f;
|
209
|
float E = SQ3/2;
|
210
|
|
211
|
switch(resourceID)
|
212
|
{
|
213
|
case R.raw.deferredjob:
|
214
|
case R.raw.meshjoin :
|
215
|
case PROCEDURAL :
|
216
|
case POLYGON :
|
217
|
case R.raw.predeform : return createWhiteTexture();
|
218
|
|
219
|
case R.raw.cube2 :
|
220
|
case R.raw.cube3 :
|
221
|
case R.raw.cube4 :
|
222
|
case R.raw.cube5 : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
|
223
|
vertices = new float[] { -F,-F, +F,-F, +F,+F, -F,+F};
|
224
|
return factory.createTexture(vertices,colors,0.10f, 0.10f, true);
|
225
|
case R.raw.pyra3 :
|
226
|
case R.raw.pyra4 :
|
227
|
case R.raw.pyra5 : colors = new int[] { 0xffffff00, 0xff00ff00, 0xff0000ff, 0xffff0000 };
|
228
|
vertices = new float[] { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
229
|
return factory.createTexture(vertices,colors,0.05f, 0.05f, true);
|
230
|
|
231
|
case R.raw.dino : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
|
232
|
vertices = new float[] { -F,F/3, 0,-2*F/3, +F,F/3 };
|
233
|
return factory.createTexture(vertices,colors,0.05f, 0.03f, true);
|
234
|
|
235
|
case R.raw.skewb : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
|
236
|
//vertices = new float[] { -G,-G, +G,-G, +G,+G, -G,+G };
|
237
|
|
238
|
vertices = new float[] { -F+F/4,F/4, F/4,-F+F/4, F/4,F/4};
|
239
|
return factory.createTexture(vertices,colors,0.05f, 0.08f, true);
|
240
|
}
|
241
|
|
242
|
return null;
|
243
|
}
|
244
|
|
245
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
246
|
|
247
|
private Bitmap createWhiteTexture()
|
248
|
{
|
249
|
int SIZE = 1;
|
250
|
Bitmap bitmap = Bitmap.createBitmap(SIZE,SIZE, Bitmap.Config.ARGB_8888);
|
251
|
Canvas canvas = new Canvas(bitmap);
|
252
|
|
253
|
Paint paint = new Paint();
|
254
|
paint.setColor(0xffffff55);
|
255
|
paint.setStyle(Paint.Style.FILL);
|
256
|
canvas.drawRect(0, 0, SIZE, SIZE, paint);
|
257
|
|
258
|
return bitmap;
|
259
|
}
|
260
|
|
261
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
262
|
|
263
|
private void createPolygon()
|
264
|
{
|
265
|
float A = 0.5f;
|
266
|
float B = 0.1f;
|
267
|
|
268
|
int extraIndex = 1;
|
269
|
int extraVertices = 2;
|
270
|
int numBands = 3;
|
271
|
|
272
|
float[] vertices = new float[] { -A,-A, A,-A, A,A, -A,A };
|
273
|
float[] bands = new float[2*numBands];
|
274
|
|
275
|
for(int i=0; i<numBands; i++)
|
276
|
{
|
277
|
bands[2*i ] = 1 + i/(1.0f-numBands);
|
278
|
bands[2*i+1] = B/(numBands-1)*i;
|
279
|
}
|
280
|
|
281
|
mMesh = new MeshPolygon(vertices,bands,extraIndex,extraVertices);
|
282
|
mMesh.setEffectAssociation(0,0,0);
|
283
|
mMesh.setShowNormals(true);
|
284
|
}
|
285
|
|
286
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
287
|
|
288
|
private void createMesh()
|
289
|
{
|
290
|
int mode = 5;
|
291
|
int numComponents = 0;
|
292
|
double[][] vertices = null;
|
293
|
int[][] vertIndexes = null;
|
294
|
float[][] bands = null;
|
295
|
int[] bandIndexes = null;
|
296
|
float[][] corners = null;
|
297
|
int[] cornerIndexes = null;
|
298
|
float[][] centers = null;
|
299
|
int[] centerIndexes = null;
|
300
|
float[] convexCenter= null;
|
301
|
|
302
|
///// CUBE ////////////////////////////////////////////////////////////////////////////////
|
303
|
|
304
|
if( mode==0 )
|
305
|
{
|
306
|
vertices = new double[][]
|
307
|
{
|
308
|
{ 0.5, 0.5, 0.5 },
|
309
|
{ 0.5, 0.5,-0.5 },
|
310
|
{ 0.5,-0.5, 0.5 },
|
311
|
{ 0.5,-0.5,-0.5 },
|
312
|
{-0.5, 0.5, 0.5 },
|
313
|
{-0.5, 0.5,-0.5 },
|
314
|
{-0.5,-0.5, 0.5 },
|
315
|
{-0.5,-0.5,-0.5 },
|
316
|
};
|
317
|
|
318
|
vertIndexes = new int[][]
|
319
|
{
|
320
|
{2,3,1,0}, // counterclockwise!
|
321
|
{7,6,4,5},
|
322
|
{4,0,1,5},
|
323
|
{7,3,2,6},
|
324
|
{6,2,0,4},
|
325
|
{3,7,5,1}
|
326
|
};
|
327
|
|
328
|
bands = new float[][]
|
329
|
{
|
330
|
{0.05f,40,0.5f,0.2f,5, 2,2}
|
331
|
};
|
332
|
|
333
|
bandIndexes = new int[] { 0,0,0,0,0,0 };
|
334
|
|
335
|
corners = new float[][]
|
336
|
{
|
337
|
{ 0.01f, 0.10f }
|
338
|
};
|
339
|
|
340
|
cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
341
|
|
342
|
centers = new float[][]
|
343
|
{
|
344
|
{ 0.0f, 0.0f, 0.0f }
|
345
|
};
|
346
|
|
347
|
centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
348
|
|
349
|
numComponents = 8;
|
350
|
}
|
351
|
|
352
|
///// TETRAHEDRON //////////////////////////////////////////////////////////////////////////
|
353
|
|
354
|
else if( mode==1 )
|
355
|
{
|
356
|
vertices = new double[][]
|
357
|
{
|
358
|
{-0.5, SQ2/4, 0.0},
|
359
|
{ 0.5, SQ2/4, 0.0},
|
360
|
{ 0.0,-SQ2/4, 0.5},
|
361
|
{ 0.0,-SQ2/4,-0.5}
|
362
|
};
|
363
|
|
364
|
vertIndexes = new int[][]
|
365
|
{
|
366
|
{2,1,0}, // counterclockwise!
|
367
|
{2,3,1},
|
368
|
{3,2,0},
|
369
|
{3,0,1}
|
370
|
};
|
371
|
|
372
|
bands = new float[][]
|
373
|
{
|
374
|
{0.05f,30,0.6f,0.5f,5, 2,2}
|
375
|
};
|
376
|
|
377
|
bandIndexes = new int[] { 0,0,0,0 };
|
378
|
|
379
|
corners = new float[][]
|
380
|
{
|
381
|
{ 0.02f, 0.10f }
|
382
|
};
|
383
|
|
384
|
cornerIndexes = new int[] { 0,0,0,0 };
|
385
|
|
386
|
centers = new float[][]
|
387
|
{
|
388
|
{ 0.0f, 0.0f, 0.0f }
|
389
|
};
|
390
|
|
391
|
centerIndexes = new int[] { 0,0,0,0 };
|
392
|
|
393
|
numComponents = 4;
|
394
|
}
|
395
|
|
396
|
///// DINO ////////////////////////////////////////////////////////////////////////////////
|
397
|
|
398
|
else if( mode==2 )
|
399
|
{
|
400
|
vertices = new double[][]
|
401
|
{
|
402
|
{-1.5, 0.0, 0.0},
|
403
|
{ 1.5, 0.0, 0.0},
|
404
|
{ 0.0,-1.5, 0.0},
|
405
|
{ 0.0, 0.0,-1.5}
|
406
|
};
|
407
|
|
408
|
vertIndexes = new int[][]
|
409
|
{
|
410
|
{2,1,0}, // counterclockwise!
|
411
|
{3,0,1},
|
412
|
{2,3,1},
|
413
|
{3,2,0},
|
414
|
};
|
415
|
|
416
|
bands = new float[][]
|
417
|
{
|
418
|
{0.035f,30,0.16f,0.8f,6,2,2},
|
419
|
{0.010f,45,0.16f,0.2f,6,2,2}
|
420
|
};
|
421
|
|
422
|
bandIndexes = new int[] { 0,0,1,1 };
|
423
|
|
424
|
corners = new float[][]
|
425
|
{
|
426
|
{0.07f,0.40f},
|
427
|
{0.05f,0.30f}
|
428
|
};
|
429
|
|
430
|
cornerIndexes = new int[] { 0,0,1,1 };
|
431
|
|
432
|
centers = new float[][]
|
433
|
{
|
434
|
{ 0.0f,-0.75f,-0.75f }
|
435
|
};
|
436
|
|
437
|
centerIndexes = new int[] { 0,0,0,0 };
|
438
|
|
439
|
numComponents = 4;
|
440
|
}
|
441
|
|
442
|
///// OCTAHEDRON ////////////////////////////////////////////////////////////////////////////
|
443
|
|
444
|
else if( mode==3 )
|
445
|
{
|
446
|
vertices = new double[][]
|
447
|
{
|
448
|
{ 0.5, 0.0, 0.5},
|
449
|
{ 0.5, 0.0,-0.5},
|
450
|
{-0.5, 0.0,-0.5},
|
451
|
{-0.5, 0.0, 0.5},
|
452
|
{ 0.0, SQ2/2, 0.0},
|
453
|
{ 0.0,-SQ2/2, 0.0},
|
454
|
};
|
455
|
|
456
|
vertIndexes = new int[][]
|
457
|
{
|
458
|
{3,0,4}, // counterclockwise!
|
459
|
{0,1,4},
|
460
|
{1,2,4},
|
461
|
{2,3,4},
|
462
|
{5,0,3},
|
463
|
{5,1,0},
|
464
|
{5,2,1},
|
465
|
{5,3,2}
|
466
|
};
|
467
|
|
468
|
bands = new float[][]
|
469
|
{
|
470
|
{0.05f,17,0.5f,0.2f,5, 2,2}
|
471
|
};
|
472
|
|
473
|
bandIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
474
|
|
475
|
corners = new float[][]
|
476
|
{
|
477
|
{ 0.03f, 0.12f }
|
478
|
};
|
479
|
|
480
|
cornerIndexes = new int[] { 0,0,0,0,0,0 };
|
481
|
|
482
|
centers = new float[][]
|
483
|
{
|
484
|
{ 0.0f, 0.0f, 0.0f }
|
485
|
};
|
486
|
|
487
|
centerIndexes = new int[] { 0,0,0,0,0,0 };
|
488
|
|
489
|
numComponents = 8;
|
490
|
}
|
491
|
|
492
|
///// KILOMINX EDGE ////////////////////////////////////////////////////////////////////////
|
493
|
|
494
|
else if( mode==4 )
|
495
|
{
|
496
|
double SQ5 = Math.sqrt(5);
|
497
|
double SIN18= (SQ5-1)/4;
|
498
|
double COS18= 0.25*Math.sqrt(10.0+2.0*SQ5);
|
499
|
double H = 1.0;
|
500
|
double L = 2.0;
|
501
|
double X = H*Math.sqrt((5+SQ5)/10);
|
502
|
double Y = H*Math.sqrt((5-SQ5)/10);
|
503
|
double D = H*SIN18/COS18;
|
504
|
|
505
|
vertices = new double[][]
|
506
|
{
|
507
|
{ 0.0, Y, L/2},
|
508
|
{ X, 0.0, L/2},
|
509
|
{ 0.0, -Y, L/2},
|
510
|
{ -X, 0.0, L/2},
|
511
|
{ 0.0, Y, -L/2 +D},
|
512
|
{ X, 0.0,-L/2 },
|
513
|
{ 0.0, -Y, -L/2-D },
|
514
|
{ -X, 0.0,-L/2 }
|
515
|
};
|
516
|
|
517
|
vertIndexes = new int[][]
|
518
|
{
|
519
|
{3,2,1,0}, // counterclockwise!
|
520
|
{0,1,5,4},
|
521
|
{3,0,4,7},
|
522
|
{2,1,5,6},
|
523
|
{3,2,6,7},
|
524
|
{4,5,6,7}
|
525
|
};
|
526
|
|
527
|
bands = new float[][]
|
528
|
{
|
529
|
{0.04f,13,(float)(L/3),(float)L/8, 5,2,3},
|
530
|
{0.00f, 0,(float)(L/2),(float)L/4, 5,2,3}
|
531
|
};
|
532
|
|
533
|
bandIndexes = new int[] { 1,0,0,1,1,1 };
|
534
|
|
535
|
corners = new float[][]
|
536
|
{
|
537
|
{ 0.04f, 0.12f }
|
538
|
};
|
539
|
|
540
|
cornerIndexes = new int[] { 0,-1,-1,-1,0,-1,-1,-1 };
|
541
|
|
542
|
centers = new float[][]
|
543
|
{
|
544
|
{ 0.0f, 0.0f, 0.0f }
|
545
|
};
|
546
|
|
547
|
centerIndexes = new int[] { 0,-1,-1,-1,0,-1,-1,-1 };
|
548
|
|
549
|
numComponents = 6;
|
550
|
}
|
551
|
|
552
|
///// IVY_CORNER ////////////////////////////////////////////////////////////////////////
|
553
|
|
554
|
else if( mode==5 )
|
555
|
{
|
556
|
int IVY_N = 8;
|
557
|
final float IVY_D = 0.003f;
|
558
|
final double angle = Math.PI/(2*IVY_N);
|
559
|
final double CORR = 1.0 - 2*IVY_D;
|
560
|
|
561
|
vertices = new double[3*IVY_N+7][3];
|
562
|
vertIndexes = new int[6][IVY_N+4];
|
563
|
|
564
|
vertices[0][0] = 0.0;
|
565
|
vertices[0][1] = 0.0;
|
566
|
vertices[0][2] = 0.0;
|
567
|
vertices[1][0] =-1.0;
|
568
|
vertices[1][1] = 0.0;
|
569
|
vertices[1][2] = 0.0;
|
570
|
vertices[2][0] = 0.0;
|
571
|
vertices[2][1] =-1.0;
|
572
|
vertices[2][2] = 0.0;
|
573
|
vertices[3][0] = 0.0;
|
574
|
vertices[3][1] = 0.0;
|
575
|
vertices[3][2] =-1.0;
|
576
|
|
577
|
vertIndexes[0][0] = 2;
|
578
|
vertIndexes[0][1] = 0;
|
579
|
vertIndexes[0][2] = 1;
|
580
|
vertIndexes[3][0] = 2;
|
581
|
vertIndexes[3][1] = 0;
|
582
|
vertIndexes[3][2] = 1;
|
583
|
|
584
|
vertIndexes[1][0] = 3;
|
585
|
vertIndexes[1][1] = 0;
|
586
|
vertIndexes[1][2] = 2;
|
587
|
vertIndexes[4][0] = 3;
|
588
|
vertIndexes[4][1] = 0;
|
589
|
vertIndexes[4][2] = 2;
|
590
|
|
591
|
vertIndexes[2][0] = 1;
|
592
|
vertIndexes[2][1] = 0;
|
593
|
vertIndexes[2][2] = 3;
|
594
|
vertIndexes[5][0] = 1;
|
595
|
vertIndexes[5][1] = 0;
|
596
|
vertIndexes[5][2] = 3;
|
597
|
|
598
|
int N1 = 4;
|
599
|
int N2 = N1 + IVY_N + 1;
|
600
|
int N3 = N2 + IVY_N + 1;
|
601
|
|
602
|
for(int i=0; i<=IVY_N; i++)
|
603
|
{
|
604
|
double cos1 = Math.cos((IVY_N-i)*angle);
|
605
|
double sin1 = Math.sin((IVY_N-i)*angle);
|
606
|
double cos2 = Math.cos(( i)*angle);
|
607
|
double sin2 = Math.sin(( i)*angle);
|
608
|
|
609
|
vertices[N1+i][0] = CORR*(cos1-0.5) - 0.5;
|
610
|
vertices[N1+i][1] = CORR*(sin1-0.5) - 0.5;
|
611
|
vertices[N1+i][2] = 0.0;
|
612
|
|
613
|
vertices[N2+i][0] = 0.0;
|
614
|
vertices[N2+i][1] = CORR*(sin2-0.5) - 0.5;
|
615
|
vertices[N2+i][2] = CORR*(cos2-0.5) - 0.5;
|
616
|
|
617
|
vertices[N3+i][0] = CORR*(cos2-0.5) - 0.5;
|
618
|
vertices[N3+i][1] = 0.0;
|
619
|
vertices[N3+i][2] = CORR*(sin2-0.5) - 0.5;
|
620
|
|
621
|
vertIndexes[0][i+3] = N1 + i;
|
622
|
vertIndexes[1][i+3] = N2 + i;
|
623
|
vertIndexes[2][i+3] = N3 + i;
|
624
|
vertIndexes[3][i+3] = N1 + i;
|
625
|
vertIndexes[4][i+3] = N2 + i;
|
626
|
vertIndexes[5][i+3] = N3 + i;
|
627
|
}
|
628
|
|
629
|
bands = new float[][]
|
630
|
{
|
631
|
{+0.012f,20,0.2f,0.5f,7,1,2},
|
632
|
{-0.100f,20,0.2f,0.0f,2,1,2}
|
633
|
};
|
634
|
|
635
|
bandIndexes = new int[] { 0,0,0,1,1,1 };
|
636
|
|
637
|
corners = new float[][]
|
638
|
{
|
639
|
{ 0.04f, 0.12f }
|
640
|
};
|
641
|
|
642
|
cornerIndexes = new int[3*IVY_N+7];
|
643
|
|
644
|
centers = new float[][]
|
645
|
{
|
646
|
{-0.5f,-0.5f,-0.5f}
|
647
|
};
|
648
|
|
649
|
centerIndexes = new int[3*IVY_N+7];
|
650
|
|
651
|
for(int i=0; i<4; i++)
|
652
|
{
|
653
|
cornerIndexes[i] = 0;
|
654
|
centerIndexes[i] = 0;
|
655
|
}
|
656
|
for(int i=4; i<3*IVY_N+7; i++)
|
657
|
{
|
658
|
cornerIndexes[i] = -1;
|
659
|
centerIndexes[i] = -1;
|
660
|
}
|
661
|
|
662
|
float C = 0.5f - SQ2/4;
|
663
|
convexCenter = new float[] {-C,-C,-C};
|
664
|
|
665
|
numComponents = 6;
|
666
|
}
|
667
|
|
668
|
///// IVY_FACE ////////////////////////////////////////////////////////////////////////
|
669
|
|
670
|
else if( mode==6 )
|
671
|
{
|
672
|
int IVY_N = 6;
|
673
|
final float IVY_D = 0.003f;
|
674
|
final double angle = Math.PI/(2*IVY_N);
|
675
|
final double CORR = 1.0 - 2*IVY_D;
|
676
|
|
677
|
vertices = new double[2*IVY_N][3];
|
678
|
vertIndexes= new int[2][2*IVY_N];
|
679
|
|
680
|
for(int i=0; i<IVY_N; i++)
|
681
|
{
|
682
|
double cos = Math.cos(i*angle);
|
683
|
double sin = Math.sin(i*angle);
|
684
|
|
685
|
vertices[i ][0] = CORR*(0.5-cos);
|
686
|
vertices[i ][1] = CORR*(0.5-sin);
|
687
|
vertices[i ][2] = 0.0;
|
688
|
vertices[i+IVY_N][0] = CORR*(cos-0.5);
|
689
|
vertices[i+IVY_N][1] = CORR*(sin-0.5);
|
690
|
vertices[i+IVY_N][2] = 0.0;
|
691
|
|
692
|
vertIndexes[0][i ] = i;
|
693
|
vertIndexes[0][i+IVY_N] = i+IVY_N;
|
694
|
vertIndexes[1][i ] = i;
|
695
|
vertIndexes[1][i+IVY_N] = i+IVY_N;
|
696
|
}
|
697
|
|
698
|
bands = new float[][]
|
699
|
{
|
700
|
{+0.012f,20,0.2f,0.5f,7,1,2},
|
701
|
{-0.100f,20,0.2f,0.0f,2,1,2},
|
702
|
};
|
703
|
|
704
|
bandIndexes = new int[] { 0,1 };
|
705
|
|
706
|
corners = new float[][]
|
707
|
{
|
708
|
{0.03f,0.10f}
|
709
|
};
|
710
|
|
711
|
centers = new float[][]
|
712
|
{
|
713
|
{-0.0f,-0.0f,-0.5f}
|
714
|
};
|
715
|
|
716
|
cornerIndexes = new int[2*IVY_N];
|
717
|
centerIndexes = new int[2*IVY_N];
|
718
|
|
719
|
for(int i=0; i<2*IVY_N; i++)
|
720
|
{
|
721
|
cornerIndexes[i] = -1;
|
722
|
centerIndexes[i] = -1;
|
723
|
}
|
724
|
|
725
|
cornerIndexes[0 ] = 0;
|
726
|
cornerIndexes[IVY_N] = 0;
|
727
|
centerIndexes[0 ] = 0;
|
728
|
centerIndexes[IVY_N] = 0;
|
729
|
|
730
|
numComponents = 2;
|
731
|
}
|
732
|
|
733
|
///// SKEWB Ultimate SMALL /////////////////////////////////////////////////////////////
|
734
|
|
735
|
else if( mode==7 )
|
736
|
{
|
737
|
double S = (SQ5+1)/4;
|
738
|
|
739
|
vertices = new double[][]
|
740
|
{
|
741
|
{ 0.0 , 0.0 , 0.0 },
|
742
|
{ -0.5*S , 0.5*S+0.25, -0.25 },
|
743
|
{-0.25 , -S/2 , (-2*S-1)/4},
|
744
|
{ 0.5*S+0.25, 0.25 , -S/2 },
|
745
|
{ 0.0 , 0.5 , -S-0.5 },
|
746
|
{ 0.0 , 0.5 , 0.0 },
|
747
|
{ -0.5*S ,-0.5*S+0.25, -0.25 },
|
748
|
{ 0.5*S ,-0.5*S+0.25, -0.25 }
|
749
|
};
|
750
|
|
751
|
vertIndexes = new int[][]
|
752
|
{
|
753
|
{6,0,5,1}, // counterclockwise!
|
754
|
{0,7,3,5},
|
755
|
{0,6,2,7},
|
756
|
{4,3,5,1},
|
757
|
{4,2,7,3},
|
758
|
{4,1,6,2},
|
759
|
};
|
760
|
|
761
|
bands = new float[][]
|
762
|
{
|
763
|
{0.04f,17,0.5f,0.2f,5, 2,2},
|
764
|
{0.01f, 1,0.5f,0.2f,5, 2,2}
|
765
|
};
|
766
|
|
767
|
bandIndexes = new int[] { 0,0,0,1,1,1 };
|
768
|
|
769
|
corners = new float[][]
|
770
|
{
|
771
|
{ 0.013f, 0.08f }
|
772
|
};
|
773
|
|
774
|
cornerIndexes = new int[] { 0, 0, 0, 0,-1,0,0,0 };
|
775
|
|
776
|
centers = new float[][]
|
777
|
{
|
778
|
{ 0.0f,-0.5f, (float)(-S-0.5) }
|
779
|
};
|
780
|
|
781
|
centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
782
|
|
783
|
numComponents = 8;
|
784
|
}
|
785
|
|
786
|
///// SKEWB Ultimate BIG ///////////////////////////////////////////////////////////////
|
787
|
|
788
|
else if( mode==8 )
|
789
|
{
|
790
|
double S = (SQ5+1)/4;
|
791
|
|
792
|
vertices = new double[][]
|
793
|
{
|
794
|
{-S/2 ,-S/2+0.25, 0.25},
|
795
|
{ S/2 , S/2-0.25, -0.25},
|
796
|
{-S , 0.00, 0.00},
|
797
|
{ 0.25, S/2 ,-S/2-0.25},
|
798
|
{-S/2 ,-S/2-0.25, 0.25},
|
799
|
{ S/2+0.25, -0.25,-S/2 },
|
800
|
{-S , -0.50, 0.00},
|
801
|
{ 0.50, 0.00,-S },
|
802
|
{-S +0.25, S/2 ,-S/2-0.25},
|
803
|
{ 0.25,-S/2-0.50,-S/2+0.25},
|
804
|
{-S/2 ,-S/2-0.25,-S -0.25}
|
805
|
};
|
806
|
|
807
|
vertIndexes = new int[][]
|
808
|
{
|
809
|
{0,1,3,8,2}, // counterclockwise!
|
810
|
{0,4,9,5,1},
|
811
|
{ 0,2,6,4},
|
812
|
{ 1,5,7,3},
|
813
|
{10,9,4,6},
|
814
|
{10,9,5,7},
|
815
|
{10,8,3,7},
|
816
|
{10,8,2,6}
|
817
|
};
|
818
|
|
819
|
bands = new float[][]
|
820
|
{
|
821
|
{0.04f,17,0.5f,0.2f,5, 2,2},
|
822
|
{0.04f,17,0.5f,0.2f,5, 2,2},
|
823
|
{0.01f, 1,0.5f,0.2f,5, 2,2}
|
824
|
};
|
825
|
|
826
|
bandIndexes = new int[] { 0,0,1,1,2,2,2,2 };
|
827
|
|
828
|
corners = new float[][]
|
829
|
{
|
830
|
{ 0.013f, 0.08f }
|
831
|
};
|
832
|
|
833
|
cornerIndexes = new int[] { 0,0,0,0,0,0,0,0,0,0,-1 };
|
834
|
|
835
|
centers = new float[][]
|
836
|
{
|
837
|
{ (float)(-S/2), 0.25f, (float)(-S/2-0.5) }
|
838
|
};
|
839
|
|
840
|
centerIndexes = new int[] { 0,0,0,0,0,0,0,0,0,0,0 };
|
841
|
|
842
|
numComponents = 8;
|
843
|
}
|
844
|
|
845
|
///// SQUARE-1 MIDDLE ///////////////////////////////////////////////////////////////
|
846
|
|
847
|
else if( mode==9 )
|
848
|
{
|
849
|
final float X = 3*(2-SQ3)/2;
|
850
|
|
851
|
vertices = new double[][]
|
852
|
{
|
853
|
{ -1.5-X, 0.5, 1.5 },
|
854
|
{ 0.0, 0.5, 1.5 },
|
855
|
{ 0.0, 0.5,-1.5 },
|
856
|
{ -1.5+X, 0.5,-1.5 },
|
857
|
{ -1.5-X,-0.5, 1.5 },
|
858
|
{ 0.0,-0.5, 1.5 },
|
859
|
{ 0.0,-0.5,-1.5 },
|
860
|
{ -1.5+X,-0.5,-1.5 }
|
861
|
};
|
862
|
|
863
|
vertIndexes = new int[][]
|
864
|
{
|
865
|
{0,1,2,3}, // counterclockwise!
|
866
|
{4,5,6,7},
|
867
|
{4,5,1,0},
|
868
|
{5,6,2,1},
|
869
|
{6,7,3,2},
|
870
|
{7,4,0,3}
|
871
|
};
|
872
|
|
873
|
bands = new float[][]
|
874
|
{
|
875
|
{0.040f,35,0.8f,1.0f,5,2,1},
|
876
|
{0.020f,35,0.8f,1.0f,5,2,1},
|
877
|
{0.001f,35,0.8f,1.0f,5,2,1}
|
878
|
};
|
879
|
|
880
|
bandIndexes = new int[] { 2,2,1,1,0,2 };
|
881
|
|
882
|
corners = new float[][]
|
883
|
{
|
884
|
{0.04f,0.05f}
|
885
|
};
|
886
|
|
887
|
cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
888
|
|
889
|
centers = new float[][]
|
890
|
{
|
891
|
{ -0.75f, 0.0f, 0.0f}
|
892
|
};
|
893
|
|
894
|
centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
895
|
|
896
|
numComponents = 6;
|
897
|
}
|
898
|
|
899
|
///// SQUARE-1 EDGE ///////////////////////////////////////////////////////////////
|
900
|
|
901
|
else if( mode==10 )
|
902
|
{
|
903
|
final float X = 3*(2-SQ3)/2;
|
904
|
|
905
|
vertices = new double[][]
|
906
|
{
|
907
|
{ -X, 0.5, 0.0 },
|
908
|
{ +X, 0.5, 0.0 },
|
909
|
{0.0, 0.5,-1.5 },
|
910
|
{ -X,-0.5, 0.0 },
|
911
|
{ +X,-0.5, 0.0 },
|
912
|
{0.0,-0.5,-1.5 },
|
913
|
};
|
914
|
|
915
|
vertIndexes = new int[][]
|
916
|
{
|
917
|
{0,1,2}, // counterclockwise!
|
918
|
{3,4,5},
|
919
|
{3,4,1,0},
|
920
|
{4,5,2,1},
|
921
|
{5,3,0,2}
|
922
|
};
|
923
|
|
924
|
bands = new float[][]
|
925
|
{
|
926
|
{0.038f,35,0.5f,0.9f, 5,2,1},
|
927
|
{0.001f,35,0.5f,0.9f, 5,2,1}
|
928
|
};
|
929
|
|
930
|
bandIndexes = new int[] { 0,1,0,1,1 };
|
931
|
|
932
|
corners = new float[][]
|
933
|
{
|
934
|
{0.06f,0.20f}
|
935
|
};
|
936
|
|
937
|
cornerIndexes = new int[] { 0,0,-1,0,0,-1 };
|
938
|
|
939
|
centers = new float[][]
|
940
|
{
|
941
|
{ 0.0f, 0.0f,-0.5f}
|
942
|
};
|
943
|
|
944
|
centerIndexes = new int[] { 0,0,-1,0,0,-1 };
|
945
|
|
946
|
numComponents = 6;
|
947
|
}
|
948
|
|
949
|
///// SQUARE-1 CORNER ///////////////////////////////////////////////////////////////
|
950
|
|
951
|
else if( mode==11 )
|
952
|
{
|
953
|
final float X = 3*(2-SQ3)/2;
|
954
|
|
955
|
vertices = new double[][]
|
956
|
{
|
957
|
{ X-1.5, 0.5, 0.0 },
|
958
|
{ 0.0, 0.5, 0.0 },
|
959
|
{ 0.0, 0.5,X-1.5 },
|
960
|
{ -1.5, 0.5, -1.5 },
|
961
|
{ X-1.5,-0.5, 0.0 },
|
962
|
{ 0.0,-0.5, 0.0 },
|
963
|
{ 0.0,-0.5,X-1.5 },
|
964
|
{ -1.5,-0.5, -1.5 }
|
965
|
};
|
966
|
|
967
|
vertIndexes = new int[][]
|
968
|
{
|
969
|
{0,1,2,3}, // counterclockwise!
|
970
|
{4,5,6,7},
|
971
|
{4,5,1,0},
|
972
|
{5,6,2,1},
|
973
|
{7,4,0,3},
|
974
|
{6,7,3,2}
|
975
|
};
|
976
|
|
977
|
bands = new float[][]
|
978
|
{
|
979
|
{0.038f,35,0.9f,1.0f, 5,2,1},
|
980
|
{0.001f,35,0.9f,1.0f, 5,2,1}
|
981
|
};
|
982
|
|
983
|
bandIndexes = new int[] { 0,1,0,0,1,1 };
|
984
|
|
985
|
corners = new float[][]
|
986
|
{
|
987
|
{0.08f,0.20f}
|
988
|
};
|
989
|
|
990
|
cornerIndexes = new int[] { 0,0,0,-1,0,0,0,-1 };
|
991
|
|
992
|
centers = new float[][]
|
993
|
{
|
994
|
{ -0.5f, 0.0f,-0.5f}
|
995
|
};
|
996
|
|
997
|
centerIndexes = new int[] { -1,0,-1,-1,-1,0,-1,-1 };
|
998
|
|
999
|
numComponents = 6;
|
1000
|
}
|
1001
|
|
1002
|
///// SQUARE-2 CORNER ///////////////////////////////////////////////////////////////
|
1003
|
|
1004
|
else if( mode==12 )
|
1005
|
{
|
1006
|
final float X = 3*(2-SQ3)/2;
|
1007
|
final float Z = 0.75f - X/2;
|
1008
|
|
1009
|
vertices = new double[][]
|
1010
|
{
|
1011
|
{ X-1.5+Z, 0.5, 0.0 },
|
1012
|
{ Z, 0.5, 0.0 },
|
1013
|
{ -1.5+Z, 0.5, -1.5 },
|
1014
|
{ X-1.5+Z,-0.5, 0.0 },
|
1015
|
{ Z,-0.5, 0.0 },
|
1016
|
{ -1.5+Z,-0.5, -1.5 }
|
1017
|
};
|
1018
|
|
1019
|
vertIndexes = new int[][]
|
1020
|
{
|
1021
|
{0,1,2}, // counterclockwise!
|
1022
|
{5,4,3},
|
1023
|
{3,4,1,0},
|
1024
|
{4,5,2,1},
|
1025
|
{5,3,0,2}
|
1026
|
};
|
1027
|
|
1028
|
bands = new float[][]
|
1029
|
{
|
1030
|
{0.040f,35,0.9f,1.0f, 5,2,1},
|
1031
|
{0.001f,35,0.9f,1.0f, 5,2,1}
|
1032
|
};
|
1033
|
|
1034
|
bandIndexes = new int[] { 0,0,0,1,1 };
|
1035
|
|
1036
|
corners = new float[][]
|
1037
|
{
|
1038
|
{0.05f,0.13f}
|
1039
|
};
|
1040
|
|
1041
|
cornerIndexes = new int[] { 0,0,-1,0,0,-1 };
|
1042
|
|
1043
|
centers = new float[][]
|
1044
|
{
|
1045
|
{ 0.0f, 0.0f,-0.5f}
|
1046
|
};
|
1047
|
|
1048
|
centerIndexes = new int[] { 0,0,-1,0,0,-1 };
|
1049
|
|
1050
|
numComponents = 5;
|
1051
|
}
|
1052
|
|
1053
|
///// REDI CORNER ///////////////////////////////////////////////////////////////
|
1054
|
|
1055
|
else if( mode==13 )
|
1056
|
{
|
1057
|
vertices = new double[][]
|
1058
|
{
|
1059
|
{ 0.0f, 0.0f, 0.0f },
|
1060
|
{-0.5f, 0.5f, 0.5f },
|
1061
|
{-0.5f,-0.5f, 0.5f },
|
1062
|
{ 0.5f, 0.5f, 0.5f },
|
1063
|
{ 0.5f,-0.5f, 0.5f },
|
1064
|
{ 0.5f, 0.5f,-0.5f },
|
1065
|
{ 0.5f,-0.5f,-0.5f },
|
1066
|
{-0.5f, 0.5f,-0.5f },
|
1067
|
};
|
1068
|
|
1069
|
vertIndexes = new int[][]
|
1070
|
{
|
1071
|
{ 2,4,3,1 },
|
1072
|
{ 1,3,5,7 },
|
1073
|
{ 4,6,5,3 },
|
1074
|
|
1075
|
{ 2,4,0 },
|
1076
|
{ 5,7,0 },
|
1077
|
{ 4,6,0 },
|
1078
|
{ 7,1,0 },
|
1079
|
{ 1,2,0 },
|
1080
|
{ 6,5,0 }
|
1081
|
};
|
1082
|
|
1083
|
bands = new float[][]
|
1084
|
{
|
1085
|
{0.06f,35,0.5f,0.7f,5,2,2},
|
1086
|
{0.01f,35,0.2f,0.4f,5,2,2}
|
1087
|
};
|
1088
|
|
1089
|
bandIndexes = new int[] { 0,0,0,1,1,1,1,1,1 };
|
1090
|
|
1091
|
corners = new float[][]
|
1092
|
{
|
1093
|
{0.06f,0.12f}
|
1094
|
};
|
1095
|
|
1096
|
cornerIndexes = new int[] { -1,0,-1,0,0,0,-1,-1 };
|
1097
|
|
1098
|
centers = new float[][]
|
1099
|
{
|
1100
|
{ 0.0f, 0.0f, 0.0f}
|
1101
|
};
|
1102
|
|
1103
|
centerIndexes = new int[] { -1,0,-1,0,0,0,-1,-1 };
|
1104
|
|
1105
|
numComponents = 9;
|
1106
|
}
|
1107
|
|
1108
|
///// JING CORNER ///////////////////////////////////////////////////////////////
|
1109
|
|
1110
|
else if( mode==14 )
|
1111
|
{
|
1112
|
final float F = 0.24f;
|
1113
|
final float X = F/2;
|
1114
|
final float Y = F*SQ2/2;
|
1115
|
final float Z =-F/2;
|
1116
|
|
1117
|
vertices = new double[][]
|
1118
|
{
|
1119
|
{ 0.0, 0.0, 0.0 },
|
1120
|
{ X, Y, Z },
|
1121
|
{ 0.0, 2*Y, 2*Z },
|
1122
|
{ -X, Y, Z },
|
1123
|
{ 0.0, 0.0, -F },
|
1124
|
{ X, Y, Z-F },
|
1125
|
{ 0.0, 2*Y, 2*Z-F },
|
1126
|
{ -X, Y, Z-F },
|
1127
|
};
|
1128
|
|
1129
|
vertIndexes = new int[][]
|
1130
|
{
|
1131
|
{0,1,2,3},
|
1132
|
{1,0,4,5},
|
1133
|
{7,4,0,3},
|
1134
|
{1,5,6,2},
|
1135
|
{7,3,2,6},
|
1136
|
{4,7,6,5}
|
1137
|
};
|
1138
|
|
1139
|
bands = new float[][]
|
1140
|
{
|
1141
|
{0.015f,35,0.5f*F,F,5,1,1},
|
1142
|
{0.001f,35,0.5f*F,F,5,1,1}
|
1143
|
};
|
1144
|
|
1145
|
bandIndexes = new int[] { 0,0,0,1,1,1 };
|
1146
|
|
1147
|
corners = new float[][]
|
1148
|
{
|
1149
|
{0.08f,0.20f*F},
|
1150
|
{0.07f,0.20f*F}
|
1151
|
};
|
1152
|
|
1153
|
cornerIndexes = new int[] { 0,1,1,-1,1,-1,-1,-1 };
|
1154
|
|
1155
|
centers = new float[][]
|
1156
|
{
|
1157
|
{ 0.0f, Y, Z-F/2}
|
1158
|
};
|
1159
|
|
1160
|
centerIndexes = new int[] { 0,0,0,-1,0,-1,-1,-1 };
|
1161
|
|
1162
|
numComponents = 6;
|
1163
|
}
|
1164
|
|
1165
|
///// JING EDGE ///////////////////////////////////////////////////////////////
|
1166
|
|
1167
|
else if( mode==15 )
|
1168
|
{
|
1169
|
final float F = 0.24f;
|
1170
|
final float X = F/2;
|
1171
|
final float Y = F*SQ2/2;
|
1172
|
final float Z =-F/2;
|
1173
|
|
1174
|
vertices = new double[][]
|
1175
|
{
|
1176
|
{ 0.0, 0.0, 0.5-F },
|
1177
|
{ X, Y, Z+0.5-F },
|
1178
|
{ 0.0, 2*Y, 2*Z+0.5-F },
|
1179
|
{ -X, Y, Z+0.5-F },
|
1180
|
{ 0.0, 0.0, -0.5+F },
|
1181
|
{ X, Y, -Z-0.5+F },
|
1182
|
{ 0.0, 2*Y,-2*Z-0.5+F },
|
1183
|
{ -X, Y, -Z-0.5+F },
|
1184
|
};
|
1185
|
|
1186
|
vertIndexes = new int[][]
|
1187
|
{
|
1188
|
{0,4,5,1},
|
1189
|
{3,7,4,0},
|
1190
|
{0,1,2,3},
|
1191
|
{4,7,6,5},
|
1192
|
{1,5,6,2},
|
1193
|
{2,6,7,3}
|
1194
|
};
|
1195
|
|
1196
|
bands = new float[][]
|
1197
|
{
|
1198
|
{0.015f,35,0.5f*F,F,5,1,1},
|
1199
|
{0.001f,35,0.5f*F,F,5,1,1}
|
1200
|
};
|
1201
|
|
1202
|
bandIndexes = new int[] { 0,0,1,1,1,1 };
|
1203
|
|
1204
|
corners = new float[][]
|
1205
|
{
|
1206
|
{0.07f,0.20f*F}
|
1207
|
};
|
1208
|
|
1209
|
cornerIndexes = new int[] { 0,0,-1,0,0,0,-1,0 };
|
1210
|
|
1211
|
centers = new float[][]
|
1212
|
{
|
1213
|
{ 0, F*SQ2/2, 0 }
|
1214
|
};
|
1215
|
|
1216
|
centerIndexes = new int[] { 0,0,-1,0,0,0,-1,0 };
|
1217
|
|
1218
|
numComponents = 6;
|
1219
|
}
|
1220
|
|
1221
|
///// JING FACE ///////////////////////////////////////////////////////////////
|
1222
|
|
1223
|
else if( mode==16 )
|
1224
|
{
|
1225
|
final float F = 0.24f;
|
1226
|
final float L = (1-3*F);
|
1227
|
final float X = L/2;
|
1228
|
final float Y = L*SQ2/2;
|
1229
|
final float Z =-L/2;
|
1230
|
final float D = F/L;
|
1231
|
|
1232
|
vertices = new double[][]
|
1233
|
{
|
1234
|
{ 0.0, -2*Y/3, -2*Z/3 },
|
1235
|
{ X, Y/3, Z/3 },
|
1236
|
{ -X, Y/3, Z/3 },
|
1237
|
{ 0.0, -2*Y/3, -2*Z/3+2*D*Z },
|
1238
|
{ X-D*X, Y/3-D*Y, Z/3+D*Z },
|
1239
|
{ -X+D*X, Y/3-D*Y, Z/3+D*Z },
|
1240
|
};
|
1241
|
|
1242
|
vertIndexes = new int[][]
|
1243
|
{
|
1244
|
{0,1,2},
|
1245
|
{3,5,4},
|
1246
|
{0,3,4,1},
|
1247
|
{5,3,0,2},
|
1248
|
{4,5,2,1}
|
1249
|
};
|
1250
|
|
1251
|
bands = new float[][]
|
1252
|
{
|
1253
|
{0.025f,35,0.20f*(1-3*F),0.6f*(1-3*F),5,1,1},
|
1254
|
{0.001f,35,0.05f*(1-3*F),0.1f*(1-3*F),5,1,1}
|
1255
|
};
|
1256
|
|
1257
|
bandIndexes = new int[] { 0,1,1,1,1,1 };
|
1258
|
|
1259
|
corners = new float[][]
|
1260
|
{
|
1261
|
{0.04f,0.15f}
|
1262
|
};
|
1263
|
|
1264
|
cornerIndexes = new int[] { 0,0,0,-1,-1,-1 };
|
1265
|
|
1266
|
centers = new float[][]
|
1267
|
{
|
1268
|
{ 0, -2*Y/3, 4*Z/3 }
|
1269
|
};
|
1270
|
|
1271
|
centerIndexes = new int[] { 0,0,0,-1,-1,-1 };
|
1272
|
|
1273
|
numComponents = 6;
|
1274
|
}
|
1275
|
|
1276
|
///// END DEFINITIONS /////////////////////////////////////////////////////////////////
|
1277
|
|
1278
|
FactoryCubit factory = FactoryCubit.getInstance();
|
1279
|
|
1280
|
factory.clear();
|
1281
|
factory.createNewFaceTransform(vertices,vertIndexes);
|
1282
|
mMesh = factory.createRoundedSolid(vertices, vertIndexes,
|
1283
|
bands, bandIndexes,
|
1284
|
corners, cornerIndexes,
|
1285
|
centers, centerIndexes,
|
1286
|
numComponents, convexCenter );
|
1287
|
|
1288
|
int numEff = mMesh.getNumEffComponents();
|
1289
|
|
1290
|
for(int i=0; i<numEff; i++)
|
1291
|
{
|
1292
|
mMesh.setEffectAssociation(i, 0, i);
|
1293
|
}
|
1294
|
}
|
1295
|
|
1296
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1297
|
|
1298
|
private void openMesh(int resourceID)
|
1299
|
{
|
1300
|
Context con = mView.getContext();
|
1301
|
Resources res = con.getResources();
|
1302
|
InputStream is = res.openRawResource(resourceID);
|
1303
|
DataInputStream dos = new DataInputStream(is);
|
1304
|
mMesh = new MeshFile(dos);
|
1305
|
|
1306
|
int numEff = mMesh.getNumEffComponents();
|
1307
|
|
1308
|
for(int i=0; i<numEff; i++)
|
1309
|
{
|
1310
|
mMesh.setEffectAssociation(i, 0, i);
|
1311
|
}
|
1312
|
|
1313
|
try
|
1314
|
{
|
1315
|
is.close();
|
1316
|
}
|
1317
|
catch(IOException e)
|
1318
|
{
|
1319
|
android.util.Log.e("MeshFile", "Error closing InputStream: "+e.toString());
|
1320
|
}
|
1321
|
}
|
1322
|
|
1323
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1324
|
|
1325
|
MeshBase getMesh()
|
1326
|
{
|
1327
|
return mMesh;
|
1328
|
}
|
1329
|
|
1330
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1331
|
|
1332
|
long getTime()
|
1333
|
{
|
1334
|
return mTime;
|
1335
|
}
|
1336
|
|
1337
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1338
|
|
1339
|
int getBytes()
|
1340
|
{
|
1341
|
if( mMesh instanceof MeshFile )
|
1342
|
{
|
1343
|
return ((MeshFile)mMesh).getNumBytes();
|
1344
|
}
|
1345
|
|
1346
|
return 0;
|
1347
|
}
|
1348
|
|
1349
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1350
|
|
1351
|
int getVertices()
|
1352
|
{
|
1353
|
return mMesh.getNumVertices();
|
1354
|
}
|
1355
|
|
1356
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1357
|
|
1358
|
int getEndEffIndex(int component)
|
1359
|
{
|
1360
|
return mMesh.getLastVertexEff(component);
|
1361
|
}
|
1362
|
|
1363
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1364
|
|
1365
|
int getEndTexIndex(int component)
|
1366
|
{
|
1367
|
return mMesh.getLastVertexTex(component);
|
1368
|
}
|
1369
|
|
1370
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1371
|
|
1372
|
int getEffComponentNum()
|
1373
|
{
|
1374
|
return mMesh.getNumEffComponents();
|
1375
|
}
|
1376
|
|
1377
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1378
|
|
1379
|
int getTexComponentNum()
|
1380
|
{
|
1381
|
return mMesh.getNumTexComponents();
|
1382
|
}
|
1383
|
}
|