Project

General

Profile

« Previous | Next » 

Revision 314bffaf

Added by Leszek Koltunski over 3 years ago

RubikControl: fixes; progress.

View differences:

src/main/java/org/distorted/control/RubikControl.java
30 30

  
31 31
public class RubikControl implements EffectListener
32 32
  {
33
  private static RubikControl mControl;
34

  
33 35
  WeakReference<RubikActivity> mRefAct;
34 36
  boolean mWholeReturned, mRotateReturned;
35 37

  
......
127 129
    }
128 130

  
129 131
///////////////////////////////////////////////////////////////////////////////////////////////////
130
// PUBLIC
131 132

  
132
  public RubikControl()
133
  private RubikControl()
133 134
    {
134 135
    mWhole = new RubikControlWhole(this);
135 136
    mRotate= new RubikControlRotate(this);
136 137
    }
137 138

  
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140
// PUBLIC
141

  
142
  public static RubikControl getInstance()
143
    {
144
    if( mControl==null ) mControl = new RubikControl();
145

  
146
    return mControl;
147
    }
148

  
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

  
151
  public void postDrawFrame(long time)
152
    {
153
    mWhole.postDrawFrame(time);
154
    }
155

  
138 156
///////////////////////////////////////////////////////////////////////////////////////////////////
139 157

  
140 158
  public void effectFinished(long effectID)
src/main/java/org/distorted/control/RubikControlWhole.java
54 54

  
55 55
  private static final int[] DUR = { D1, D2, D3, D2, D1/4, 3*D1/4, D1/4, D2, D4, D5, D4, D2, D1 };
56 56

  
57
  private float X0, X1, X2, Y1, D, s001, s014, s033, F;
58

  
57 59
  private final RubikControl mControl;
58 60
  private DistortedEffects[] mEffects;
59 61
  private DistortedNode[] mNodes;
60 62
  private long mEffectID;
61
  private int mStageFinished, mWidth, mHeight;
63
  private int mCurrentStage, mWidth, mHeight;
62 64

  
63 65
  private MeshQuad mQuad;
64 66
  private DistortedTexture mTextureShad, mTextureCirc;
......
73 75
  private MatrixEffectMove mMoveHand2, mMoveShad2;
74 76
  private MatrixEffectScale mScaleHand2, mScaleShad2;
75 77

  
78
  private Dynamic3D mDyn1, mDyn2;
79
  private Static3D mPosition1, mPosition2;
80
  private float[] mHandPosition;
81
  private long mLastTime, mDiffTime;
82

  
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

  
85
   private void setPostFrame(boolean on)
86
     {
87
     RubikActivity act = mControl.getActivity();
88
     act.setControlState(on);
89
     mLastTime = -1;
90
     }
91

  
76 92
///////////////////////////////////////////////////////////////////////////////////////////////////
77 93

  
78 94
   private Bitmap openBitmap(RubikActivity act, int resource)
......
109 125
    mDynScaleHand1.resetToBeginning();
110 126
    mDynScaleShad1.resetToBeginning();
111 127

  
112
    mStageFinished = stage;
128
    mCurrentStage = stage;
113 129
    }
114 130

  
115 131
///////////////////////////////////////////////////////////////////////////////////////////////////
......
133 149
    mDynScaleShad2.resetToBeginning();
134 150
    }
135 151

  
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

  
154
  private void resetDynamics3(int stage)
155
    {
156
    int dur = DUR[stage-1];
157

  
158
    mDyn1.removeAll();
159
    mDyn2.removeAll();
160
    mDyn1.setDuration(dur);
161
    mDyn2.setDuration(dur);
162
    mDyn1.resetToBeginning();
163
    mDyn2.resetToBeginning();
164
    }
165

  
136 166
///////////////////////////////////////////////////////////////////////////////////////////////////
137 167
// first finger appears and approaches the screen
138 168

  
......
141 171
    resetDynamics1(1);
142 172
    resetDynamics2(1);
143 173

  
144
    float x0 = mWidth*0.55f;
145
    float x1 = mWidth*0.45f;
146
    float x2 = mWidth*0.35f;
147
    float y1 = mHeight*0.28f;
148
    float z  = 0;
149
    float d  = mWidth*0.01f;
150
    float s  = mWidth*0.33f;
151

  
152
    Static3D point0h = new Static3D(-x0    ,-y1    , z);
153
    Static3D point1h = new Static3D(-x1    ,-y1    , z);
154
    Static3D point2h = new Static3D(-x2    ,-y1    , z);
155
    Static3D point3h = new Static3D(-x2  +d,-y1  +d, z);
156
    Static3D point0s = new Static3D(-x0+2*d,-y1+2*d, z);
157
    Static3D point1s = new Static3D(-x1+2*d,-y1+2*d, z);
158
    Static3D point2s = new Static3D(-x2+2*d,-y1+2*d, z);
159
    Static3D point3s = new Static3D(-x2  +d,-y1  +d, z);
160

  
161
    Static3D pointSc = new Static3D(s,s,s);
174
    Static3D point0h = new Static3D(-X0    ,-Y1    , 0);
175
    Static3D point1h = new Static3D(-X1    ,-Y1    , 0);
176
    Static3D point2h = new Static3D(-X2    ,-Y1    , 0);
177
    Static3D point3h = new Static3D(-X2  +D,-Y1  +D, 0);
178
    Static3D point0s = new Static3D(-X0+2*D,-Y1+2*D, 0);
179
    Static3D point1s = new Static3D(-X1+2*D,-Y1+2*D, 0);
180
    Static3D point2s = new Static3D(-X2+2*D,-Y1+2*D, 0);
181
    Static3D point3s = new Static3D(-X2  +D,-Y1  +D, 0);
182

  
183
    Static3D pointSc = new Static3D(s033,s033,s033);
162 184

  
163 185
    mDynMoveHand1.add(point0h);
164 186
    mDynMoveHand1.add(point1h);
......
183 205
    {
184 206
    resetDynamics1(2);
185 207

  
186
    float x2 = mWidth*0.35f;
187
    float y1 = mHeight*0.28f;
188
    float z  = 0;
189
    float d  = mWidth*0.01f;
190
    float sS = mWidth*0.0001f;
191
    float sF = mWidth*0.14f;
192
    float sH = mWidth*0.33f;
193

  
194
    Static3D point3h = new Static3D(-x2  +d,-y1  +d, z);
195
    Static3D scaleS  = new Static3D(sS,sS,sS);
196
    Static3D scaleF  = new Static3D(sF,sF,sF);
197
    Static3D pointH  = new Static3D(sH,sH,sH);
208
    Static3D point3h = new Static3D(-X2  +D,-Y1  +D, 0);
209
    Static3D scaleS  = new Static3D(s001,s001,s001);
210
    Static3D scaleF  = new Static3D(s014,s014,s014);
211
    Static3D pointH  = new Static3D(s033,s033,s033);
198 212

  
199 213
    mDynMoveHand1.add(point3h);
200 214
    mDynMoveShad1.add(point3h);
......
213 227
  private void setEffectsStage3()
214 228
    {
215 229
    resetDynamics1(3);
230
    resetDynamics3(3);
216 231

  
217
    float x2 = mWidth*0.35f;
218

  
219
    float y1 = mHeight*0.28f;
220
    float z  = 0;
221
    float d  = mWidth*0.01f;
222
    float sH = mWidth*0.33f;
223
    float sF = mWidth*0.14f;
224

  
225
    Static3D scaleS = new Static3D(sF,sF,sF);
226
    Static3D pointH = new Static3D(sH,sH,sH);
227
    Static3D point1 = new Static3D(-x2  +d,-y1  +d, z);
228
    Static3D point2 = new Static3D(     +d,-y1  +d, z);
229
    Static3D point3 = new Static3D(+x2  +d,-y1  +d, z);
230
    Static3D point4 = new Static3D(+x2  +d,     +d, z);
231
    Static3D point5 = new Static3D(+x2  +d,+y1  +d, z);
232
    Static3D point6 = new Static3D(     +d,     +d, z);
232
    Static3D scaleS = new Static3D(s014,s014,s014);
233
    Static3D pointH = new Static3D(s033,s033,s033);
234
    Static3D point1 = new Static3D(-X2  +D,-Y1  +D, 0);
235
    Static3D point2 = new Static3D(     +D,-Y1  +D, 0);
236
    Static3D point3 = new Static3D(+X2  +D,-Y1  +D, 0);
237
    Static3D point4 = new Static3D(+X2  +D,     +D, 0);
238
    Static3D point5 = new Static3D(+X2  +D,+Y1  +D, 0);
239
    Static3D point6 = new Static3D(     +D,     +D, 0);
233 240

  
234 241
    mDynScaleHand1.add(pointH);
235 242
    mDynScaleShad1.add(scaleS);
236 243

  
237
    mDynMoveHand1.add(point1);
238
    mDynMoveHand1.add(point1);
239
    mDynMoveHand1.add(point2);
240
    mDynMoveHand1.add(point3);
241
    mDynMoveHand1.add(point3);
242
    mDynMoveHand1.add(point4);
243
    mDynMoveHand1.add(point5);
244
    mDynMoveHand1.add(point5);
245
    mDynMoveHand1.add(point6);
246
    mDynMoveHand1.add(point1);
247
    mDynMoveHand1.add(point1);
244
    mDyn1.add(point1);
245
    mDyn1.add(point1);
246
    mDyn1.add(point2);
247
    mDyn1.add(point3);
248
    mDyn1.add(point3);
249
    mDyn1.add(point4);
250
    mDyn1.add(point5);
251
    mDyn1.add(point5);
252
    mDyn1.add(point6);
253
    mDyn1.add(point1);
254
    mDyn1.add(point1);
248 255

  
249
    mDynMoveShad1.add(point1);
250
    mDynMoveShad1.add(point1);
251
    mDynMoveShad1.add(point2);
252
    mDynMoveShad1.add(point3);
253
    mDynMoveShad1.add(point3);
254
    mDynMoveShad1.add(point4);
255
    mDynMoveShad1.add(point5);
256
    mDynMoveShad1.add(point5);
257
    mDynMoveShad1.add(point6);
258
    mDynMoveShad1.add(point1);
259
    mDynMoveShad1.add(point1);
256
    mPosition1.set(point1);
260 257

  
261
    mMoveHand1.notifyWhenFinished(this);
258
    mDynMoveHand1.add(mPosition1);
259
    mDynMoveShad1.add(mPosition1);
260

  
261
    setPostFrame(true);
262 262
    }
263 263

  
264 264
///////////////////////////////////////////////////////////////////////////////////////////////////
......
268 268
    {
269 269
    resetDynamics1(4);
270 270

  
271
    float x2 = mWidth*0.35f;
272
    float y1 = mHeight*0.28f;
273
    float z  = 0;
274
    float d  = mWidth*0.01f;
275
    float sF = mWidth*0.0001f;
276
    float sS = mWidth*0.14f;
277
    float sH = mWidth*0.33f;
278

  
279
    Static3D point3h = new Static3D(-x2  +d,-y1  +d, z);
280
    Static3D scaleS  = new Static3D(sS,sS,sS);
281
    Static3D scaleF  = new Static3D(sF,sF,sF);
282
    Static3D pointH  = new Static3D(sH,sH,sH);
271
    Static3D point3h = new Static3D(-X2+D,-Y1+D, 0);
272
    Static3D scaleS  = new Static3D(s014,s014,s014);
273
    Static3D scaleF  = new Static3D(s001,s001,s001);
274
    Static3D pointH  = new Static3D(s033,s033,s033);
283 275

  
284 276
    mDynMoveHand1.add(point3h);
285 277
    mDynMoveShad1.add(point3h);
......
297 289
    {
298 290
    resetDynamics1(5);
299 291

  
300
    float x2 = mWidth*0.35f;
301
    float y1 = mHeight*0.28f;
302
    float z  = 0;
303
    float d  = mWidth*0.01f;
304
    float s  = mWidth*0.33f;
305

  
306
    Static3D pointH = new Static3D(-x2    ,-y1    , z);
307
    Static3D point0 = new Static3D(-x2  +d,-y1  +d, z);
308
    Static3D pointS = new Static3D(-x2+2*d,-y1+2*d, z);
309
    Static3D pointSc = new Static3D(s,s,s);
292
    Static3D pointH = new Static3D(-X2    ,-Y1    , 0);
293
    Static3D point0 = new Static3D(-X2  +D,-Y1  +D, 0);
294
    Static3D pointS = new Static3D(-X2+2*D,-Y1+2*D, 0);
295
    Static3D pointSc = new Static3D(s033,s033,s033);
310 296

  
311 297
    mDynScaleHand1.add(pointSc);
312 298
    mDynScaleShad1.add(pointSc);
......
327 313
    resetDynamics1(6);
328 314
    resetDynamics2(6);
329 315

  
330
    float x0 = mWidth*0.55f;
331
    float x1 = mWidth*0.45f;
332
    float x2 = mWidth*0.35f;
333
    float y1 = mHeight*0.28f;
334
    float z  = 0;
335
    float d  = mWidth*0.01f;
336
    float s  = mWidth*0.33f;
337

  
338
    Static3D pointH = new Static3D(-x2    ,-y1    , z);
339
    Static3D pointS = new Static3D(-x2+2*d,-y1+2*d, z);
340
    Static3D pointSc= new Static3D(s,s,s);
316
    Static3D pointH = new Static3D(-X2    ,-Y1    , 0);
317
    Static3D pointS = new Static3D(-X2+2*D,-Y1+2*D, 0);
318
    Static3D pointSc= new Static3D(s033,s033,s033);
341 319

  
342 320
    mDynScaleHand1.add(pointSc);
343 321
    mDynScaleShad1.add(pointSc);
344 322
    mDynMoveHand1.add(pointH);
345 323
    mDynMoveShad1.add(pointS);
346 324

  
347
    Static3D point0h = new Static3D( x0    , y1    , z);
348
    Static3D point1h = new Static3D( x1    , y1    , z);
349
    Static3D point2h = new Static3D( x2    , y1    , z);
350
    Static3D point0s = new Static3D( x0+2*d, y1+2*d, z);
351
    Static3D point1s = new Static3D( x1+2*d, y1+2*d, z);
352
    Static3D point2s = new Static3D( x2+2*d, y1+2*d, z);
353
    Static3D pointSm= new Static3D(-s,s,s);
325
    Static3D point0h = new Static3D( X0    , Y1    , 0);
326
    Static3D point1h = new Static3D( X1    , Y1    , 0);
327
    Static3D point2h = new Static3D( X2    , Y1    , 0);
328
    Static3D point0s = new Static3D( X0+2*D, Y1+2*D, 0);
329
    Static3D point1s = new Static3D( X1+2*D, Y1+2*D, 0);
330
    Static3D point2s = new Static3D( X2+2*D, Y1+2*D, 0);
331
    Static3D pointSm= new Static3D(-s033,s033,s033);
354 332

  
355 333
    mDynMoveHand2.add(point0h);
356 334
    mDynMoveHand2.add(point1h);
......
374 352
    resetDynamics1(7);
375 353
    resetDynamics2(7);
376 354

  
377
    float x2 = mWidth*0.35f;
378
    float y1 = mHeight*0.28f;
379
    float z  = 0;
380
    float d  = mWidth*0.01f;
381
    float s  = mWidth*0.33f;
382

  
383
    Static3D point1H = new Static3D(-x2    ,-y1    , z);
384
    Static3D point1F = new Static3D(-x2  +d,-y1  +d, z);
385
    Static3D point1S = new Static3D(-x2+2*d,-y1+2*d, z);
386
    Static3D point1Sc= new Static3D(s,s,s);
355
    Static3D point1H = new Static3D(-X2    ,-Y1    , 0);
356
    Static3D point1F = new Static3D(-X2  +D,-Y1  +D, 0);
357
    Static3D point1S = new Static3D(-X2+2*D,-Y1+2*D, 0);
358
    Static3D point1Sc= new Static3D(s033,s033,s033);
387 359

  
388 360
    mDynScaleHand1.add(point1Sc);
389 361
    mDynScaleShad1.add(point1Sc);
......
392 364
    mDynMoveShad1.add(point1S);
393 365
    mDynMoveShad1.add(point1F);
394 366

  
395
    Static3D point2H = new Static3D( x2    , y1    , z);
396
    Static3D point2F = new Static3D( x2  +d, y1  +d, z);
397
    Static3D point2S = new Static3D( x2+2*d, y1+2*d, z);
398
    Static3D point2Sc= new Static3D(-s,s,s);
367
    Static3D point2H = new Static3D( X2    , Y1    , 0);
368
    Static3D point2F = new Static3D( X2  +D, Y1  +D, 0);
369
    Static3D point2S = new Static3D( X2+2*D, Y1+2*D, 0);
370
    Static3D point2Sc= new Static3D(-s033,s033,s033);
399 371

  
400 372
    mDynScaleHand2.add(point2Sc);
401 373
    mDynScaleShad2.add(point2Sc);
......
415 387
    resetDynamics1(8);
416 388
    resetDynamics2(8);
417 389

  
418
    float x2 = mWidth*0.35f;
419
    float y1 = mHeight*0.28f;
420
    float z  = 0;
421
    float d  = mWidth*0.01f;
422
    float sS = mWidth*0.0001f;
423
    float sF = mWidth*0.14f;
424
    float sH = mWidth*0.33f;
425

  
426
    Static3D point1h= new Static3D(-x2  +d,-y1  +d, z);
427
    Static3D point2h= new Static3D( x2  +d, y1  +d, z);
428
    Static3D scale1S = new Static3D( sS,sS,sS);
429
    Static3D scale1F = new Static3D( sF,sF,sF);
430
    Static3D point1H = new Static3D( sH,sH,sH);
431
    Static3D scale2S = new Static3D(-sS,sS,sS);
432
    Static3D scale2F = new Static3D(-sF,sF,sF);
433
    Static3D point2H = new Static3D(-sH,sH,sH);
390
    Static3D point1h= new Static3D(-X2  +D,-Y1  +D, 0);
391
    Static3D point2h= new Static3D( X2  +D, Y1  +D, 0);
392
    Static3D scale1S = new Static3D( s001,s001,s001);
393
    Static3D scale1F = new Static3D( s014,s014,s014);
394
    Static3D point1H = new Static3D( s033,s033,s033);
395
    Static3D scale2S = new Static3D(-s001,s001,s001);
396
    Static3D scale2F = new Static3D(-s014,s014,s014);
397
    Static3D point2H = new Static3D(-s033,s033,s033);
434 398

  
435 399
    mDynMoveHand1.add(point1h);
436 400
    mDynMoveShad1.add(point1h);
......
444 408
    mDynScaleShad2.add(scale2S);
445 409
    mDynScaleShad2.add(scale2F);
446 410

  
447
    mScaleShad1.notifyWhenFinished(this);
411
    mScaleShad2.notifyWhenFinished(this);
448 412

  
449 413
    mNodes[0].changeInputSurface(mTextureCirc);
450 414
    mNodes[1].changeInputSurface(mTextureCirc);
......
457 421
    {
458 422
    resetDynamics1(9);
459 423
    resetDynamics2(9);
424
    resetDynamics3(9);
460 425

  
461
    float x2 = mWidth*0.35f;
462
    float y1 = mHeight*0.28f;
463
    float z  = 0;
464
    float d  = mWidth*0.01f;
465
    float f  = 0.60f;
466
    float sF = mWidth*0.14f;
467
    float sH = mWidth*0.33f;
468

  
469
    Static3D point1s= new Static3D(-x2  +d,-y1  +d, z);
470
    Static3D point2s= new Static3D( x2  +d, y1  +d, z);
471
    Static3D point1f= new Static3D((-x2  +d)*f,(-y1  +d)*f, z);
472
    Static3D point2f= new Static3D(( x2  +d)*f,( y1  +d)*f, z);
473
    Static3D scale1F = new Static3D( sF,sF,sF);
474
    Static3D point1H = new Static3D( sH,sH,sH);
475
    Static3D scale2F = new Static3D(-sF,sF,sF);
476
    Static3D point2H = new Static3D(-sH,sH,sH);
426
    Static3D point1s= new Static3D(-X2  +D,-Y1  +D, 0);
427
    Static3D point2s= new Static3D( X2  +D, Y1  +D, 0);
428
    Static3D point1f= new Static3D((-X2  +D)*F,(-Y1  +D)*F, 0);
429
    Static3D point2f= new Static3D(( X2  +D)*F,( Y1  +D)*F, 0);
430
    Static3D scale1F = new Static3D( s014,s014,s014);
431
    Static3D point1H = new Static3D( s033,s033,s033);
432
    Static3D scale2F = new Static3D(-s014,s014,s014);
433
    Static3D point2H = new Static3D(-s033,s033,s033);
477 434

  
478
    mDynMoveHand1.add(point1s);
479
    mDynMoveHand1.add(point1f);
480
    mDynMoveShad1.add(point1s);
481
    mDynMoveShad1.add(point1f);
482 435
    mDynScaleHand1.add(point1H);
483 436
    mDynScaleShad1.add(scale1F);
484

  
485
    mDynMoveHand2.add(point2s);
486
    mDynMoveHand2.add(point2f);
487
    mDynMoveShad2.add(point2s);
488
    mDynMoveShad2.add(point2f);
489 437
    mDynScaleHand2.add(point2H);
490 438
    mDynScaleShad2.add(scale2F);
491 439

  
492
    mMoveShad1.notifyWhenFinished(this);
440
    mDyn1.add(point1s);
441
    mDyn1.add(point1f);
442
    mDyn2.add(point2s);
443
    mDyn2.add(point2f);
444

  
445
    mPosition1.set(point1s);
446
    mPosition2.set(point2s);
447

  
448
    mDynMoveHand1.add(mPosition1);
449
    mDynMoveShad1.add(mPosition1);
450
    mDynMoveHand2.add(mPosition2);
451
    mDynMoveShad2.add(mPosition2);
452

  
453
    setPostFrame(true);
493 454
    }
494 455

  
495 456
///////////////////////////////////////////////////////////////////////////////////////////////////
......
500 461
    resetDynamics1(10);
501 462
    resetDynamics2(10);
502 463

  
503
    float sF = mWidth*0.14f;
504
    float sH = mWidth*0.33f;
505
    float x2 = mWidth*0.35f;
506
    float y1 = mHeight*0.28f;
507
    float z  = 0;
508
    float d  = mWidth*0.01f;
509
    float f  = 0.60f;
510

  
511
    Static3D scale1F = new Static3D( sF,sF,sF);
512
    Static3D point1H = new Static3D( sH,sH,sH);
513
    Static3D scale2F = new Static3D(-sF,sF,sF);
514
    Static3D point2H = new Static3D(-sH,sH,sH);
464
    Static3D scale1F = new Static3D( s014,s014,s014);
465
    Static3D point1H = new Static3D( s033,s033,s033);
466
    Static3D scale2F = new Static3D(-s014,s014,s014);
467
    Static3D point2H = new Static3D(-s033,s033,s033);
515 468

  
516
    Static3D point0= new Static3D((-x2  +d)*f,(-y1  +d)*f, z);
517
    Static3D point1= new Static3D((-x2  +d)*f,( y1  +d)*f, z);
518
    Static3D point2= new Static3D(( x2  +d)*f,( y1  +d)*f, z);
519
    Static3D point3= new Static3D(( x2  +d)*f,(-y1  +d)*f, z);
469
    Static3D point0= new Static3D((-X2+D)*F,(-Y1+D)*F, 0);
470
    Static3D point1= new Static3D((-X2+D)*F,( Y1+D)*F, 0);
471
    Static3D point2= new Static3D(( X2+D)*F,( Y1+D)*F, 0);
472
    Static3D point3= new Static3D(( X2+D)*F,(-Y1+D)*F, 0);
520 473

  
521 474
    mDynMoveHand1.add(point0);
522 475
    mDynMoveHand1.add(point1);
......
560 513
    resetDynamics1(11);
561 514
    resetDynamics2(11);
562 515

  
563
    float x2 = mWidth*0.35f;
564
    float y1 = mHeight*0.28f;
565
    float z  = 0;
566
    float d  = mWidth*0.01f;
567
    float f  = 0.60f;
568
    float sF = mWidth*0.14f;
569
    float sH = mWidth*0.33f;
570

  
571
    Static3D point1s= new Static3D(-x2  +d,-y1  +d, z);
572
    Static3D point2s= new Static3D( x2  +d, y1  +d, z);
573
    Static3D point1f= new Static3D((-x2  +d)*f,(-y1  +d)*f, z);
574
    Static3D point2f= new Static3D(( x2  +d)*f,( y1  +d)*f, z);
575
    Static3D scale1F= new Static3D( sF,sF,sF);
576
    Static3D point1H= new Static3D( sH,sH,sH);
577
    Static3D scale2F= new Static3D(-sF,sF,sF);
578
    Static3D point2H= new Static3D(-sH,sH,sH);
516
    Static3D point1s= new Static3D( -X2+D   , -Y1+D   , 0);
517
    Static3D point2s= new Static3D(  X2+D   ,  Y1+D   , 0);
518
    Static3D point1f= new Static3D((-X2+D)*F,(-Y1+D)*F, 0);
519
    Static3D point2f= new Static3D(( X2+D)*F,( Y1+D)*F, 0);
520
    Static3D scale1F= new Static3D( s014,s014,s014);
521
    Static3D point1H= new Static3D( s033,s033,s033);
522
    Static3D scale2F= new Static3D(-s014,s014,s014);
523
    Static3D point2H= new Static3D(-s033,s033,s033);
579 524

  
580 525
    mDynMoveHand1.add(point1f);
581 526
    mDynMoveHand1.add(point1s);
......
607 552
    resetDynamics1(12);
608 553
    resetDynamics2(12);
609 554

  
610
    float x2 = mWidth*0.35f;
611
    float y1 = mHeight*0.28f;
612
    float z  = 0;
613
    float d  = mWidth*0.01f;
614
    float sS = mWidth*0.0001f;
615
    float sF = mWidth*0.14f;
616
    float sH = mWidth*0.33f;
617

  
618
    Static3D point1h= new Static3D(-x2  +d,-y1  +d, z);
619
    Static3D point2h= new Static3D( x2  +d, y1  +d, z);
620
    Static3D scale1S = new Static3D( sS,sS,sS);
621
    Static3D scale1F = new Static3D( sF,sF,sF);
622
    Static3D point1H = new Static3D( sH,sH,sH);
623
    Static3D scale2S = new Static3D(-sS,sS,sS);
624
    Static3D scale2F = new Static3D(-sF,sF,sF);
625
    Static3D point2H = new Static3D(-sH,sH,sH);
555
    Static3D point1h = new Static3D(-X2+D,-Y1+D, 0);
556
    Static3D point2h = new Static3D( X2+D, Y1+D, 0);
557
    Static3D scale1S = new Static3D( s014,s014,s014);
558
    Static3D scale1F = new Static3D( s001,s001,s001);
559
    Static3D point1H = new Static3D( s033,s033,s033);
560
    Static3D scale2S = new Static3D(-s014,s014,s014);
561
    Static3D scale2F = new Static3D(-s001,s001,s001);
562
    Static3D point2H = new Static3D(-s033,s033,s033);
626 563

  
627 564
    mDynMoveHand1.add(point1h);
628 565
    mDynMoveShad1.add(point1h);
......
647 584
    resetDynamics1(13);
648 585
    resetDynamics2(13);
649 586

  
650
    float x0 = mWidth*0.55f;
651
    float x1 = mWidth*0.45f;
652
    float x2 = mWidth*0.35f;
653
    float y1 = mHeight*0.28f;
654
    float z  = 0;
655
    float d  = mWidth*0.01f;
656
    float s  = mWidth*0.33f;
657

  
658
    Static3D point1_0 = new Static3D(-x2  +d,-y1  +d, z);
659
    Static3D point11H = new Static3D(-x2    ,-y1    , z);
660
    Static3D point12H = new Static3D(-x1    ,-y1    , z);
661
    Static3D point13H = new Static3D(-x0    ,-y1    , z);
662
    Static3D point11S = new Static3D(-x2+2*d,-y1+2*d, z);
663
    Static3D point12S = new Static3D(-x1+2*d,-y1+2*d, z);
664
    Static3D point13S = new Static3D(-x0+2*d,-y1+2*d, z);
665
    Static3D point1Sc = new Static3D( s,s,s);
587
    Static3D point1_0 = new Static3D(-X2  +D,-Y1  +D, 0);
588
    Static3D point11H = new Static3D(-X2    ,-Y1    , 0);
589
    Static3D point12H = new Static3D(-X1    ,-Y1    , 0);
590
    Static3D point13H = new Static3D(-X0    ,-Y1    , 0);
591
    Static3D point11S = new Static3D(-X2+2*D,-Y1+2*D, 0);
592
    Static3D point12S = new Static3D(-X1+2*D,-Y1+2*D, 0);
593
    Static3D point13S = new Static3D(-X0+2*D,-Y1+2*D, 0);
594
    Static3D point1Sc = new Static3D( s033,s033,s033);
666 595

  
667 596
    mDynScaleHand1.add(point1Sc);
668 597
    mDynScaleShad1.add(point1Sc);
......
677 606
    mDynMoveShad1.add(point12S);
678 607
    mDynMoveShad1.add(point13S);
679 608

  
680
    Static3D point2_0 = new Static3D( x2  +d, y1  +d, z);
681
    Static3D point21H = new Static3D( x2    , y1    , z);
682
    Static3D point22H = new Static3D( x1    , y1    , z);
683
    Static3D point23H = new Static3D( x0    , y1    , z);
684
    Static3D point21S = new Static3D( x2+2*d, y1+2*d, z);
685
    Static3D point22S = new Static3D( x1+2*d, y1+2*d, z);
686
    Static3D point23S = new Static3D( x0+2*d, y1+2*d, z);
687
    Static3D point2Sc= new Static3D(-s,s,s);
609
    Static3D point2_0 = new Static3D( X2  +D, Y1  +D, 0);
610
    Static3D point21H = new Static3D( X2    , Y1    , 0);
611
    Static3D point22H = new Static3D( X1    , Y1    , 0);
612
    Static3D point23H = new Static3D( X0    , Y1    , 0);
613
    Static3D point21S = new Static3D( X2+2*D, Y1+2*D, 0);
614
    Static3D point22S = new Static3D( X1+2*D, Y1+2*D, 0);
615
    Static3D point23S = new Static3D( X0+2*D, Y1+2*D, 0);
616
    Static3D point2Sc= new Static3D(-s033,s033,s033);
688 617

  
689 618
    mDynScaleHand2.add(point2Sc);
690 619
    mDynScaleShad2.add(point2Sc);
......
714 643

  
715 644
    int time = DUR[0];
716 645

  
646
    mDyn1 = new Dynamic3D(time,0.5f);
647
    mDyn1.setMode(Dynamic.MODE_PATH);
648
    mDyn1.setConvexity(0.0f);
649
    mDyn2 = new Dynamic3D(time,0.5f);
650
    mDyn2.setMode(Dynamic.MODE_PATH);
651
    mDyn2.setConvexity(0.0f);
652

  
653
    mPosition1 = new Static3D(0,0,0);
654
    mPosition2 = new Static3D(0,0,0);
655

  
656
    mHandPosition = new float[6];
657

  
717 658
    mDynMoveHand1 = new Dynamic3D(time,0.5f);
718 659
    mDynMoveHand1.setMode(Dynamic.MODE_PATH);
719 660
    mDynMoveHand1.setConvexity(0.0f);
......
763 704
    DistortedScreen screen = mControl.getScreen();
764 705
    mWidth = screen.getWidth();
765 706
    mHeight= screen.getHeight();
707

  
708
    X0 = mWidth*0.55f;
709
    X1 = mWidth*0.45f;
710
    X2 = mWidth*0.35f;
711
    Y1 = mHeight*0.28f;
712
    D  = mWidth*0.01f;
713
    s001 = mWidth*0.0001f;
714
    s014 = mWidth*0.14f;
715
    s033 = mWidth*0.33f;
716
    F  = 0.60f;
766 717
    }
767 718

  
768 719
///////////////////////////////////////////////////////////////////////////////////////////////////
......
838 789

  
839 790
  public void effectFinished(long effectID)
840 791
    {
841
    switch( mStageFinished )
792
    switch( mCurrentStage )
842 793
      {
843 794
      case  1: setEffectsStage2(); break;
844 795
      case  2: setEffectsStage3(); break;
......
857 808
               break;
858 809
      }
859 810
    }
811

  
812
///////////////////////////////////////////////////////////////////////////////////////////////////
813

  
814
  public void postDrawFrame(long time)
815
    {
816
    if( mLastTime<0 ) mLastTime = time;
817
    else mDiffTime = time - mLastTime;
818
    mLastTime = time;
819

  
820
    switch( mCurrentStage )
821
      {
822
      case  3:
823

  
824
      mDyn1.setDebug(true);
825
      boolean finished = mDyn1.get( mHandPosition,0, time, mDiffTime);
826
               mPosition1.set(mHandPosition[0], mHandPosition[1], mHandPosition[2]);
827
               if( finished )
828
                 {
829
                 setPostFrame(false);
830
                 effectFinished(0);
831
                 }
832
               break;
833
      case  9: boolean finished1 = mDyn1.get( mHandPosition,0, time, mDiffTime);
834
               boolean finished2 = mDyn2.get( mHandPosition,3, time, mDiffTime);
835
               mPosition1.set(mHandPosition[0], mHandPosition[1], mHandPosition[2]);
836
               mPosition2.set(mHandPosition[3], mHandPosition[4], mHandPosition[5]);
837
               if( finished1 && finished2 )
838
                 {
839
                 setPostFrame(false);
840
                 effectFinished(0);
841
                 }
842
               break;
843
      default: android.util.Log.e("D", "WHAT? "+mCurrentStage);
844
      }
845
    }
860 846
  }
src/main/java/org/distorted/main/RubikActivity.java
505 505
        }
506 506
      }
507 507

  
508
///////////////////////////////////////////////////////////////////////////////////////////////////
509

  
510
    public void setControlState(boolean on)
511
      {
512
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
513
      RubikRenderer renderer = view.getRenderer();
514
      renderer.setControlState(on);
515
      }
516

  
508 517
///////////////////////////////////////////////////////////////////////////////////////////////////
509 518

  
510 519
    public void acceptPrivacy()
src/main/java/org/distorted/main/RubikRenderer.java
22 22
import android.opengl.GLES30;
23 23
import android.opengl.GLSurfaceView;
24 24

  
25
import org.distorted.control.RubikControl;
25 26
import org.distorted.effects.BaseEffect;
26 27
import org.distorted.library.effect.EffectType;
27 28
import org.distorted.library.effect.VertexEffectQuaternion;
......
47 48
   private final Fps mFPS;
48 49
   private boolean mErrorShown;
49 50
   private boolean mDebugSent;
51
   private RubikControl mControl;
50 52

  
51 53
   private static class Fps
52 54
     {
......
97 99
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
98 100
     }
99 101

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

  
104
   public void setControlState(boolean on)
105
     {
106
     mControl = on ? RubikControl.getInstance() : null;
107
     }
108

  
100 109
///////////////////////////////////////////////////////////////////////////////////////////////////
101 110
// various things are done here delayed, 'after the next render' as not to be done mid-render and
102 111
// cause artifacts.
......
108 117
     mFPS.onRender(time);
109 118
     mView.getPreRender().preRender();
110 119
     mScreen.render(time);
120

  
121
     if( mControl!=null ) mControl.postDrawFrame(time);
111 122
     }
112 123

  
113 124
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/screens/RubikScreenPlay.java
72 72
  private float mButtonSize, mMenuItemSize, mMenuTextSize;
73 73
  private int mColCount, mRowCount;
74 74
  private LinearLayout mPlayLayout;
75
  private RubikControl mControlWhole;
76 75

  
77 76
///////////////////////////////////////////////////////////////////////////////////////////////////
78 77

  
......
395 394
              pDiag.setArguments(pBundle);
396 395
              pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
397 396
              break;
398
      case 2: if( mControlWhole==null ) mControlWhole = new RubikControl();
399
              mControlWhole.animateAll(act);
397
      case 2: RubikControl control = RubikControl.getInstance();
398
              control.animateAll(act);
400 399
              break;
401 400
      case 3: ScreenList.switchScreen(act, ScreenList.SVER);
402 401
              break;

Also available in: Unified diff