Project

General

Profile

« Previous | Next » 

Revision 8becce57

Added by Leszek Koltunski over 4 years ago

Major progress with Prretty Patterns - hopefully only initializing the Object remains!

View differences:

src/main/java/org/distorted/effect/BaseEffect.java
27 27
import org.distorted.effect.sizechange.SizeChangeEffect;
28 28
import org.distorted.effect.solve.SolveEffect;
29 29
import org.distorted.effect.win.WinEffect;
30
import org.distorted.library.main.DistortedScreen;
30 31
import org.distorted.magic.R;
31
import org.distorted.magic.RubikRenderer;
32
import org.distorted.magic.RubikPostRender;
32 33

  
33 34
///////////////////////////////////////////////////////////////////////////////////////////////////
34 35

  
......
196 197

  
197 198
  ////////////////////////////////////////////////////////////////////////////////
198 199

  
199
    public long startEffect(RubikRenderer renderer) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
200
    public long startEffect(DistortedScreen screen, RubikPostRender post) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
200 201
      {
201 202
      Method method1 = mClass.getDeclaredMethod("create", int.class);
202 203

  
203 204
      Object value1 = method1.invoke(null,mCurrentType);
204 205
      BaseEffect baseEffect = (BaseEffect)value1;
205 206

  
206
      Method method2 = mClass.getDeclaredMethod("start", int.class, RubikRenderer.class);
207
      Method method2 = mClass.getDeclaredMethod("start", int.class, DistortedScreen.class, RubikPostRender.class);
207 208

  
208 209
      Integer translated = translatePos(mCurrentPos)+1;
209
      Object value2 = method2.invoke(baseEffect,translated,renderer);
210
      Object value2 = method2.invoke(baseEffect,translated,screen,post);
210 211
      return (Long)value2;
211 212
      }
212 213

  
src/main/java/org/distorted/effect/scramble/ScrambleEffect.java
22 22
import org.distorted.effect.BaseEffect;
23 23
import org.distorted.library.effect.Effect;
24 24
import org.distorted.library.main.DistortedEffects;
25
import org.distorted.library.main.DistortedScreen;
25 26
import org.distorted.library.message.EffectListener;
26
import org.distorted.magic.RubikRenderer;
27
import org.distorted.magic.RubikPostRender;
27 28
import org.distorted.object.RubikObject;
28 29

  
29 30
import java.lang.reflect.Method;
......
31 32

  
32 33
///////////////////////////////////////////////////////////////////////////////////////////////////
33 34

  
34
public abstract class ScrambleEffect extends BaseEffect implements EffectListener
35
public abstract class ScrambleEffect extends BaseEffect implements EffectListener, RubikPostRender.ActionFinishedListener
35 36
{
36 37
  public enum Type
37 38
    {
......
62 63
      }
63 64
    }
64 65

  
65
  private EffectListener mListener;
66
  private RubikPostRender mPostRender;
66 67
  private int mEffectReturned;
67
  private long mCurrentBaseEffectID;
68 68
  private int mNumDoubleScramblesLeft, mNumScramblesLeft;
69 69
  private int mLastVector;
70 70
  private long mDurationSingleTurn;
......
154 154
        android.util.Log.e("effect", "ERROR: "+mNumDoubleScramblesLeft);
155 155
        }
156 156

  
157
      mCurrentBaseEffectID = mObject.addNewRotation(mLastVector, rowBitmap, angle*(360/mBasicAngle), durationMillis, this );
157
      mPostRender.addRotation(this, mLastVector, rowBitmap, angle*(360/mBasicAngle), durationMillis);
158 158
      }
159 159
    else
160 160
      {
......
162 162

  
163 163
      if( mEffectReturned == mCubeEffectNumber+mNodeEffectNumber )
164 164
        {
165
        mListener.effectFinished(FAKE_EFFECT_ID);
165
        mPostRender.effectFinished(FAKE_EFFECT_ID);
166 166
        }
167 167
      }
168 168
    }
......
242 242

  
243 243
///////////////////////////////////////////////////////////////////////////////////////////////////
244 244

  
245
  public void effectFinished(final long effectID)
245
  public void onActionFinished(final long effectID)
246 246
    {
247
    if( effectID == mCurrentBaseEffectID )
248
      {
249
      mObject.removeRotationNow();
250
      addNewScramble();
251
      return;
252
      }
247
    mObject.removeRotationNow();
248
    addNewScramble();
249
    }
253 250

  
251
///////////////////////////////////////////////////////////////////////////////////////////////////
252

  
253
  public void effectFinished(final long effectID)
254
    {
254 255
    for(int i=0; i<mCubeEffectNumber; i++)
255 256
      {
256 257
      long id = mCubeEffects[i].getID();
......
266 267

  
267 268
          if( mNumScramblesLeft==0 )
268 269
            {
269
            mListener.effectFinished(FAKE_EFFECT_ID);
270
            mPostRender.effectFinished(FAKE_EFFECT_ID);
270 271
            }
271 272
          }
272 273

  
......
289 290

  
290 291
          if( mNumScramblesLeft==0 )
291 292
            {
292
            mListener.effectFinished(FAKE_EFFECT_ID);
293
            mPostRender.effectFinished(FAKE_EFFECT_ID);
293 294
            }
294 295
          }
295 296

  
......
301 302
///////////////////////////////////////////////////////////////////////////////////////////////////
302 303

  
303 304
  @SuppressWarnings("unused")
304
  public long start(int duration, RubikRenderer renderer)
305
  public long start(int duration, DistortedScreen screen, RubikPostRender post)
305 306
    {
306
    mObject   = renderer.getObject();
307
    mListener = renderer;
307
    mObject     = post.getObject();
308
    mPostRender = post;
308 309

  
309 310
    mObject.solve();
310 311

  
311 312
    mNumAxis    = mObject.getRotationAxis().length;
312 313
    mBasicAngle = mObject.getBasicAngle();
313 314

  
314
    int numScrambles = renderer.getNumScrambles();
315
    int numScrambles = post.getNumScrambles();
315 316
    int dura = (int)(duration*Math.pow(numScrambles,0.6f));
316 317
    createBaseEffects(dura,numScrambles);
317 318
    createEffects    (dura,numScrambles);
src/main/java/org/distorted/effect/sizechange/SizeChangeEffect.java
24 24
import org.distorted.library.main.DistortedEffects;
25 25
import org.distorted.library.main.DistortedScreen;
26 26
import org.distorted.library.message.EffectListener;
27
import org.distorted.magic.RubikRenderer;
27
import org.distorted.magic.RubikPostRender;
28 28
import org.distorted.object.RubikObject;
29 29

  
30 30
import java.lang.reflect.Method;
......
224 224
///////////////////////////////////////////////////////////////////////////////////////////////////
225 225

  
226 226
  @SuppressWarnings("unused")
227
  public long start(int duration, RubikRenderer renderer)
227
  public long start(int duration, DistortedScreen screen, RubikPostRender post)
228 228
    {
229
    mScreen   = renderer.getScreen();
230
    mObject[0]= renderer.getOldObject();
231
    mObject[1]= renderer.getObject();
232
    mListener = renderer;
229
    mScreen   = screen;
230
    mObject[0]= post.getOldObject();
231
    mObject[1]= post.getObject();
232
    mListener = post;
233 233
    mDuration = duration;
234 234

  
235 235
    if( mObject[0]!=null )
src/main/java/org/distorted/effect/solve/SolveEffect.java
24 24
import org.distorted.library.main.DistortedEffects;
25 25
import org.distorted.library.main.DistortedScreen;
26 26
import org.distorted.library.message.EffectListener;
27
import org.distorted.magic.RubikRenderer;
27
import org.distorted.magic.RubikPostRender;
28 28
import org.distorted.object.RubikObject;
29 29

  
30 30
import java.lang.reflect.Method;
......
197 197
///////////////////////////////////////////////////////////////////////////////////////////////////
198 198

  
199 199
  @SuppressWarnings("unused")
200
  public long start(int duration, RubikRenderer renderer)
200
  public long start(int duration, DistortedScreen screen, RubikPostRender post)
201 201
    {
202
    mScreen   = renderer.getScreen();
203
    mObject   = renderer.getObject();
204
    mListener = renderer;
202
    mScreen   = screen;
203
    mObject   = post.getObject();
204
    mListener = post;
205 205
    mDuration = duration;
206 206

  
207 207
    createEffectsPhase0(mDuration);
src/main/java/org/distorted/effect/win/WinEffect.java
24 24
import org.distorted.library.main.DistortedEffects;
25 25
import org.distorted.library.main.DistortedScreen;
26 26
import org.distorted.library.message.EffectListener;
27
import org.distorted.magic.RubikRenderer;
27
import org.distorted.magic.RubikPostRender;
28 28
import org.distorted.object.RubikObject;
29 29

  
30 30
import java.lang.reflect.Method;
......
163 163
///////////////////////////////////////////////////////////////////////////////////////////////////
164 164

  
165 165
  @SuppressWarnings("unused")
166
  public long start(int duration, RubikRenderer renderer)
166
  public long start(int duration, DistortedScreen screen, RubikPostRender post)
167 167
    {
168
    mScreen   = renderer.getScreen();
169
    mObject   = renderer.getObject();
170
    mListener = renderer;
168
    mScreen   = screen;
169
    mObject   = post.getObject();
170
    mListener = post;
171 171
    mDuration = duration;
172 172

  
173 173
    createEffects(mDuration);
src/main/java/org/distorted/magic/RubikActivity.java
102 102
        if( sizeIndex>=0 && sizeIndex<sizes.length )
103 103
          {
104 104
          success = true;
105
          view.getRenderer().changeObject( obj, size, null );
105
          view.getPostRender().changeObject( obj, size, null );
106 106
          }
107 107

  
108 108
        }
......
113 113
        int s = RubikStatePlay.DEF_SIZE;
114 114

  
115 115
        play.setObjectAndSize(obj,s);
116
        view.getRenderer().changeObject(obj,s, null);
116
        view.getPostRender().changeObject(obj,s, null);
117 117
        }
118 118
      }
119 119
    
......
145 145

  
146 146
      RubikState.savePreferences(editor);
147 147
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
148
      view.getRenderer().savePreferences(editor);
148
      view.getPostRender().savePreferences(editor);
149 149

  
150 150
      editor.apply();
151 151
      }
......
169 169
      RubikState.restorePreferences(preferences);
170 170

  
171 171
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
172
      view.getRenderer().restorePreferences(preferences);
172
      view.getPostRender().restorePreferences(preferences);
173 173
      }
174 174

  
175 175
///////////////////////////////////////////////////////////////////////////////////////////////////
......
179 179
    public RubikObject getObject()
180 180
      {
181 181
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
182
      RubikRenderer renderer = view.getRenderer();
183
      return renderer.getObject();
182
      RubikPostRender post = view.getPostRender();
183
      return post.getObject();
184
      }
185

  
186
///////////////////////////////////////////////////////////////////////////////////////////////////
187

  
188
    public RubikPostRender getPostRender()
189
      {
190
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
191
      return view.getPostRender();
184 192
      }
185 193

  
186 194
///////////////////////////////////////////////////////////////////////////////////////////////////
......
188 196
    public void changeObject(RubikObjectList object, int size, String moves)
189 197
      {
190 198
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
191
      RubikRenderer renderer = view.getRenderer();
199
      RubikPostRender post = view.getPostRender();
192 200

  
193
      if( renderer.canDrag() )
201
      if( post.canDrag() )
194 202
        {
195
        renderer.changeObject(object,size,moves);
203
        post.changeObject(object,size,moves);
196 204
        }
197 205
      }
198 206

  
......
266 274
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
267 275
      RubikStatePlay play = (RubikStatePlay)RubikState.PLAY.getStateClass();
268 276
      int scramble = play.getPicker();
269
      view.getRenderer().scrambleObject(scramble);
277
      view.getPostRender().scrambleObject(scramble);
270 278
      }
271 279

  
272 280
///////////////////////////////////////////////////////////////////////////////////////////////////
......
274 282
    public void Solve(View v)
275 283
      {
276 284
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
277
      view.getRenderer().solveObject();
285
      view.getPostRender().solveObject();
278 286
      }
279 287
}
src/main/java/org/distorted/magic/RubikPostRender.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.magic;
21

  
22
import android.content.SharedPreferences;
23
import android.os.Bundle;
24

  
25
import org.distorted.dialog.RubikDialogNewRecord;
26
import org.distorted.dialog.RubikDialogSolved;
27
import org.distorted.effect.BaseEffect;
28
import org.distorted.library.message.EffectListener;
29
import org.distorted.object.RubikObject;
30
import org.distorted.object.RubikObjectList;
31
import org.distorted.scores.RubikScores;
32
import org.distorted.uistate.RubikState;
33
import org.distorted.uistate.RubikStateSolving;
34

  
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36

  
37
public class RubikPostRender implements EffectListener
38
  {
39
  public interface ActionFinishedListener
40
    {
41
    void onActionFinished(long effectID);
42
    }
43

  
44
  private RubikSurfaceView mView;
45
  private boolean mFinishRotation, mRemoveRotation, mAddRotation, mSetQuatCurrent, mSetQuatAccumulated;
46
  private boolean mChangeObject, mSolveObject, mScrambleObject;
47
  private boolean mCanRotate, mCanDrag, mCanUI;
48
  private boolean mIsSolved;
49
  private RubikObjectList mNextObject;
50
  private int mNextSize;
51
  private long mRotationFinishedID;
52
  private long[] mEffectID;
53
  private boolean mIsNewRecord;
54
  private long mNewRecord;
55
  private int mScreenWidth, mScreenHeight;
56
  private SharedPreferences mPreferences;
57
  private String mNextMoves;
58
  private RubikObject mOldObject, mNewObject;
59
  private int mScrambleObjectNum;
60
  private int mAddRotationAxis, mAddRotationRowBitmap, mAddRotationAngle;
61
  private long mAddRotationDuration;
62
  private ActionFinishedListener mAddActionListener;
63
  private long mAddRotationID;
64

  
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

  
67
  RubikPostRender(RubikSurfaceView view)
68
    {
69
    mView = view;
70

  
71
    mFinishRotation     = false;
72
    mRemoveRotation     = false;
73
    mAddRotation        = false;
74
    mSetQuatCurrent     = false;
75
    mSetQuatAccumulated = false;
76
    mChangeObject       = false;
77
    mSolveObject        = false;
78
    mScrambleObject     = false;
79

  
80
    mCanRotate   = true;
81
    mCanDrag     = true;
82
    mCanUI       = true;
83

  
84
    mOldObject = null;
85
    mNewObject = null;
86

  
87
    mScreenWidth = mScreenHeight = 0;
88
    mScrambleObjectNum = 0;
89

  
90
    mEffectID = new long[BaseEffect.Type.LENGTH];
91
    }
92

  
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

  
95
  private void createObjectNow(RubikObjectList object, int size, String moves)
96
    {
97
    boolean firstTime = (mNewObject==null);
98

  
99
    if( mOldObject!=null ) mOldObject.releaseResources();
100
    mOldObject = mNewObject;
101

  
102
    mNewObject = object.create(size, mView.getQuatCurrent(), mView.getQuatAccumulated(), moves);
103
    mNewObject.createTexture();
104
    mView.setMovement(object.getObjectMovementClass());
105

  
106
    if( firstTime ) mNewObject.restorePreferences(mPreferences);
107

  
108
    if( mScreenWidth!=0 )
109
      {
110
      mNewObject.recomputeScaleFactor(mScreenWidth, mScreenHeight);
111
      }
112

  
113
    mIsSolved = true;
114
    }
115

  
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
// do all 'adjustable' effects (SizeChange, Solve, Scramble)
118

  
119
  private void doEffectNow(BaseEffect.Type type)
120
    {
121
    int index = type.ordinal();
122

  
123
    try
124
      {
125
      mEffectID[index] = type.startEffect(mView.getRenderer().getScreen(),this);
126
      }
127
    catch( Exception ex )
128
      {
129
      android.util.Log.e("renderer", "exception starting effect: "+ex.getMessage());
130

  
131
      mCanUI     = true;
132
      mCanRotate = true;
133
      mCanDrag   = true;
134
      }
135
    }
136

  
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138

  
139
  private void removeRotationNow()
140
    {
141
    mRemoveRotation=false;
142
    mNewObject.removeRotationNow();
143

  
144
    boolean solved = mNewObject.isSolved();
145

  
146
    if( solved && !mIsSolved )
147
      {
148
      if( RubikState.getCurrentState()==RubikState.SOLV )
149
        {
150
        RubikStateSolving solving = (RubikStateSolving)RubikState.SOLV.getStateClass();
151
        mNewRecord = solving.stopCounting((RubikActivity)mView.getContext());
152

  
153
        if( mNewRecord< 0 )
154
          {
155
          mNewRecord = -mNewRecord;
156
          mIsNewRecord = false;
157
          }
158
        else
159
          {
160
          mIsNewRecord = true;
161
          }
162
        }
163

  
164
android.util.Log.e("post", "1 canDrag true");
165

  
166
      mCanDrag   = true;
167
      mCanRotate = false;
168
      mCanUI     = false;
169
      doEffectNow( BaseEffect.Type.WIN );
170
      }
171
    else
172
      {
173
      mCanRotate = true;
174
      mCanUI     = true;
175
      }
176

  
177
    mIsSolved = solved;
178
    }
179

  
180
///////////////////////////////////////////////////////////////////////////////////////////////////
181

  
182
  private void removeRotation()
183
    {
184
    mRemoveRotation = true;
185
    }
186

  
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

  
189
  private void addRotationNow()
190
    {
191
    mAddRotation = false;
192

  
193
    mAddRotationID = mNewObject.addNewRotation( mAddRotationAxis, mAddRotationRowBitmap,
194
                                                mAddRotationAngle, mAddRotationDuration, this);
195
    }
196

  
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198

  
199
  private void finishRotationNow()
200
    {
201
    mFinishRotation = false;
202
    mCanRotate      = false;
203
    mCanUI          = false;
204
    mRotationFinishedID = mNewObject.finishRotationNow(this);
205

  
206
    if( mRotationFinishedID==0 ) // failed to add effect - should never happen
207
      {
208
      mCanRotate = true;
209
      mCanUI     = true;
210
      }
211
    }
212

  
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214

  
215
  private void changeObjectNow()
216
    {
217
    mChangeObject = false;
218

  
219
    if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getSize()!=mNextSize)
220
      {
221
      mCanDrag      = false;
222
      mCanRotate    = false;
223
      mCanUI        = false;
224
      createObjectNow(mNextObject, mNextSize, mNextMoves);
225
      doEffectNow( BaseEffect.Type.SIZECHANGE );
226
      }
227
    else
228
      {
229
      mNewObject.initializeObject(mNextMoves);
230
      }
231
    }
232

  
233
///////////////////////////////////////////////////////////////////////////////////////////////////
234

  
235
  private void scrambleObjectNow()
236
    {
237
    mScrambleObject = false;
238
    mCanDrag        = false;
239
    mCanRotate      = false;
240
    mCanUI          = false;
241
    mIsSolved       = false;
242
    RubikScores.getInstance().incrementNumPlays();
243
    doEffectNow( BaseEffect.Type.SCRAMBLE );
244
    }
245

  
246
///////////////////////////////////////////////////////////////////////////////////////////////////
247

  
248
  private void solveObjectNow()
249
    {
250
    mSolveObject    = false;
251
    mCanDrag        = false;
252
    mCanRotate      = false;
253
    mCanUI          = false;
254
    doEffectNow( BaseEffect.Type.SOLVE );
255
    }
256

  
257
///////////////////////////////////////////////////////////////////////////////////////////////////
258

  
259
  private void setQuatCurrentNow()
260
    {
261
    mSetQuatCurrent = false;
262
    mView.setQuatCurrent();
263
    }
264

  
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

  
267
  private void setQuatAccumulatedNow()
268
    {
269
    mSetQuatAccumulated = false;
270
    mView.setQuatAccumulated();
271
    }
272

  
273
///////////////////////////////////////////////////////////////////////////////////////////////////
274
//
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276

  
277
  void setScreenSize(int width, int height)
278
    {
279
    if( mNewObject!=null )
280
      {
281
      mNewObject.createTexture();
282
      mNewObject.recomputeScaleFactor(width,height);
283
      }
284

  
285
    mScreenHeight = height;
286
    mScreenWidth  = width;
287
    }
288

  
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

  
291
  void savePreferences(SharedPreferences.Editor editor)
292
    {
293
    if( mNewObject!=null )
294
      {
295
      mNewObject.savePreferences(editor);
296
      }
297
    }
298

  
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300

  
301
  void restorePreferences(SharedPreferences preferences)
302
    {
303
    mPreferences = preferences;
304
    }
305

  
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

  
308
  void finishRotation()
309
    {
310
    mFinishRotation = true;
311
    }
312

  
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

  
315
  void changeObject(RubikObjectList object, int size, String moves)
316
    {
317
    if( size>0 )
318
      {
319
      mChangeObject = true;
320
      mNextObject = object;
321
      mNextSize   = size;
322
      mNextMoves  = moves;
323
      }
324
    }
325

  
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

  
328
  void scrambleObject(int num)
329
    {
330
    if( mCanUI )
331
      {
332
      mScrambleObject = true;
333
      mScrambleObjectNum = num;
334
      }
335
    }
336

  
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

  
339
  void solveObject()
340
    {
341
    if( mCanUI )
342
      {
343
      mSolveObject = true;
344
      }
345
    }
346

  
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

  
349
  boolean canRotate()
350
    {
351
    return mCanRotate;
352
    }
353

  
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

  
356
  boolean canDrag()
357
    {
358
    return mCanDrag;
359
    }
360

  
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

  
363
  void setQuatCurrentOnNextRender()
364
    {
365
    mSetQuatCurrent = true;
366
    }
367

  
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369

  
370
  void setQuatAccumulatedOnNextRender()
371
    {
372
    mSetQuatAccumulated = true;
373
    }
374

  
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376

  
377
  void postRender()
378
    {
379
    if( mSetQuatCurrent     ) setQuatCurrentNow();
380
    if( mSetQuatAccumulated ) setQuatAccumulatedNow();
381
    if( mFinishRotation     ) finishRotationNow();
382
    if( mRemoveRotation     ) removeRotationNow();
383
    if( mChangeObject       ) changeObjectNow();
384
    if( mSolveObject        ) solveObjectNow();
385
    if( mScrambleObject     ) scrambleObjectNow();
386
    if( mAddRotation        ) addRotationNow();
387
    }
388

  
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390
// PUBLIC API
391
///////////////////////////////////////////////////////////////////////////////////////////////////
392

  
393
  public void addRotation(ActionFinishedListener listener, int axis, int rowBitmap, int angle, long duration)
394
    {
395
    mAddRotation = true;
396

  
397
    mAddActionListener    = listener;
398
    mAddRotationAxis      = axis;
399
    mAddRotationRowBitmap = rowBitmap;
400
    mAddRotationAngle     = angle;
401
    mAddRotationDuration  = duration;
402
    }
403

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

  
406
  public RubikObject getObject()
407
    {
408
    return mNewObject;
409
    }
410

  
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412

  
413
  public RubikObject getOldObject()
414
    {
415
    return mOldObject;
416
    }
417

  
418
///////////////////////////////////////////////////////////////////////////////////////////////////
419

  
420
  public int getNumScrambles()
421
    {
422
    return mScrambleObjectNum;
423
    }
424

  
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426

  
427
  public void effectFinished(final long effectID)
428
    {
429
    if( effectID == mRotationFinishedID )
430
      {
431
      mRotationFinishedID = 0;
432
      removeRotation();
433
      }
434
    else if( effectID == mAddRotationID )
435
      {
436
      mAddRotationID = 0;
437
      mAddActionListener.onActionFinished(effectID);
438
      }
439
    else
440
      {
441
      for(int i=0; i<BaseEffect.Type.LENGTH; i++)
442
        {
443
        if( effectID == mEffectID[i] )
444
          {
445
          mCanRotate   = true;
446
          mCanDrag     = true;
447
          mCanUI       = true;
448

  
449
          if( i==BaseEffect.Type.SCRAMBLE.ordinal() )
450
            {
451
            final RubikActivity act = (RubikActivity)mView.getContext();
452

  
453
            act.runOnUiThread(new Runnable()
454
              {
455
              @Override
456
              public void run()
457
                {
458
                RubikState.switchState( act, RubikState.SOLV);
459
                }
460
              });
461
            }
462

  
463
          if( i==BaseEffect.Type.WIN.ordinal() )
464
            {
465
            if( RubikState.getCurrentState()==RubikState.SOLV )
466
              {
467
              final RubikActivity act = (RubikActivity)mView.getContext();
468
              Bundle bundle = new Bundle();
469
              bundle.putLong("time", mNewRecord );
470

  
471
              if( mIsNewRecord )
472
                {
473
                RubikDialogNewRecord dialog = new RubikDialogNewRecord();
474
                dialog.setArguments(bundle);
475
                dialog.show( act.getSupportFragmentManager(), null);
476
                }
477
              else
478
                {
479
                RubikDialogSolved dialog = new RubikDialogSolved();
480
                dialog.setArguments(bundle);
481
                dialog.show( act.getSupportFragmentManager(), null);
482
                }
483
              }
484
            }
485

  
486
          break;
487
          }
488
        }
489
      }
490
    }
491
  }
src/main/java/org/distorted/magic/RubikRenderer.java
19 19

  
20 20
package org.distorted.magic;
21 21

  
22
import android.content.SharedPreferences;
23 22
import android.opengl.GLSurfaceView;
24
import android.os.Bundle;
25

  
26
import org.distorted.dialog.RubikDialogNewRecord;
27
import org.distorted.dialog.RubikDialogSolved;
28 23
import org.distorted.effect.BaseEffect;
29 24
import org.distorted.library.effect.VertexEffectSink;
30 25
import org.distorted.library.main.DistortedLibrary;
31 26
import org.distorted.library.main.DistortedScreen;
32
import org.distorted.library.message.EffectListener;
33
import org.distorted.object.RubikObject;
34
import org.distorted.object.RubikObjectList;
35
import org.distorted.scores.RubikScores;
36
import org.distorted.uistate.RubikState;
37
import org.distorted.uistate.RubikStateSolving;
38 27

  
39 28
import javax.microedition.khronos.egl.EGLConfig;
40 29
import javax.microedition.khronos.opengles.GL10;
41 30

  
42 31
///////////////////////////////////////////////////////////////////////////////////////////////////
43 32

  
44
public class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
33
public class RubikRenderer implements GLSurfaceView.Renderer
45 34
{
46
    public static final int NODE_FBO_SIZE = 600;
47

  
48
    private RubikSurfaceView mView;
49
    private DistortedScreen mScreen;
50
    private RubikObjectList mNextObject;
51
    private int mNextSize;
52
    private int mScrambleObjectNum;
53
    private long mRotationFinishedID;
54
    private long[] mEffectID;
55
    private boolean mFinishRotation, mRemoveRotation, mSetQuatCurrent, mSetQuatAccumulated;
56
    private boolean mChangeObject, mSolveObject, mScrambleObject;
57
    private boolean mCanRotate, mCanDrag, mCanUI;
58
    private boolean mIsSolved;
59
    private boolean mIsNewRecord;
60
    private long mNewRecord;
61
    private RubikObject mOldObject, mNewObject;
62
    private int mScreenWidth, mScreenHeight;
63
    private SharedPreferences mPreferences;
64
    private String mNextMoves;
65

  
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

  
68
    RubikRenderer(RubikSurfaceView v)
69
      {
70
      mView = v;
71
      mScreen = new DistortedScreen();
72

  
73
      mOldObject = null;
74
      mNewObject = null;
75

  
76
      mScreenWidth = mScreenHeight = 0;
77
      mScrambleObjectNum = 0;
78

  
79
      mFinishRotation     = false;
80
      mRemoveRotation     = false;
81
      mSetQuatCurrent     = false;
82
      mSetQuatAccumulated = false;
83
      mChangeObject       = false;
84
      mSolveObject        = false;
85
      mScrambleObject     = false;
86

  
87
      mCanRotate   = true;
88
      mCanDrag     = true;
89
      mCanUI       = true;
90

  
91
      mEffectID = new long[BaseEffect.Type.LENGTH];
92
      }
93

  
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

  
96
   private void createObjectNow(RubikObjectList object, int size, String moves)
97
     {
98
     boolean firstTime = (mNewObject==null);
99

  
100
     if( mOldObject!=null ) mOldObject.releaseResources();
101
     mOldObject = mNewObject;
102

  
103
     mNewObject = object.create(size, mView.getQuatCurrent(), mView.getQuatAccumulated(), moves);
104
     mNewObject.createTexture();
105
     mView.setMovement(object.getObjectMovementClass());
106

  
107
     if( firstTime ) mNewObject.restorePreferences(mPreferences);
108

  
109
     if( mScreenWidth!=0 )
110
       {
111
       mNewObject.recomputeScaleFactor(mScreenWidth, mScreenHeight);
112
       }
113

  
114
     mIsSolved = true;
115
     }
116

  
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118
// do all 'adjustable' effects (SizeChange, Solve, Scramble)
119

  
120
   private void doEffectNow(BaseEffect.Type type)
121
     {
122
     int index = type.ordinal();
123

  
124
     try
125
       {
126
       mEffectID[index] = type.startEffect(this);
127
       }
128
     catch( Exception ex )
129
       {
130
       android.util.Log.e("renderer", "exception starting effect: "+ex.getMessage());
131

  
132
       mCanUI     = true;
133
       mCanRotate = true;
134
       mCanDrag   = true;
135
       }
136
     }
137

  
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

  
140
   void savePreferences(SharedPreferences.Editor editor)
141
     {
142
     if( mNewObject!=null )
143
       {
144
       mNewObject.savePreferences(editor);
145
       }
146
     }
147

  
148
///////////////////////////////////////////////////////////////////////////////////////////////////
149

  
150
   void restorePreferences(SharedPreferences preferences)
151
     {
152
     mPreferences = preferences;
153
     }
154

  
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156
// no this will not race with onDrawFrame
157

  
158
   void finishRotation()
159
     {
160
     mFinishRotation = true;
161
     }
162

  
163
///////////////////////////////////////////////////////////////////////////////////////////////////
164

  
165
   void changeObject(RubikObjectList object, int size, String moves)
166
     {
167
     if( size>0 )
168
       {
169
       mChangeObject = true;
170
       mNextObject = object;
171
       mNextSize   = size;
172
       mNextMoves  = moves;
173
       }
174
     }
35
   public static final int NODE_FBO_SIZE = 600;
175 36

  
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177

  
178
   void scrambleObject(int num)
179
     {
180
     if( mCanUI )
181
       {
182
       mScrambleObject = true;
183
       mScrambleObjectNum = num;
184
       }
185
     }
37
   private RubikSurfaceView mView;
38
   private DistortedScreen mScreen;
186 39

  
187 40
///////////////////////////////////////////////////////////////////////////////////////////////////
188 41

  
189
   void solveObject()
42
   RubikRenderer(RubikSurfaceView v)
190 43
     {
191
     if( mCanUI )
192
       {
193
       mSolveObject = true;
194
       }
195
     }
196

  
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198

  
199
   boolean canRotate()
200
     {
201
     return mCanRotate;
202
     }
203

  
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205

  
206
   boolean canDrag()
207
     {
208
     return mCanDrag;
209
     }
210

  
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

  
213
   void setQuatCurrentOnNextRender()
214
     {
215
     mSetQuatCurrent = true;
216
     }
217

  
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

  
220
   void setQuatAccumulatedOnNextRender()
221
     {
222
     mSetQuatAccumulated = true;
44
     mView = v;
45
     mScreen = new DistortedScreen();
223 46
     }
224 47

  
225 48
///////////////////////////////////////////////////////////////////////////////////////////////////
......
230 53
   public void onDrawFrame(GL10 glUnused)
231 54
     {
232 55
     mScreen.render( System.currentTimeMillis() );
233

  
234
     if( mSetQuatCurrent )
235
       {
236
       mSetQuatCurrent = false;
237
       mView.setQuatCurrent();
238
       }
239

  
240
     if( mSetQuatAccumulated )
241
       {
242
       mSetQuatAccumulated = false;
243
       mView.setQuatAccumulated();
244
       }
245

  
246
     if( mFinishRotation )
247
       {
248
       mFinishRotation = false;
249
       mCanRotate      = false;
250
       mCanUI          = false;
251
       mRotationFinishedID = mNewObject.finishRotationNow(this);
252

  
253
       if( mRotationFinishedID==0 ) // failed to add effect - should never happen
254
         {
255
         mCanRotate = true;
256
         mCanUI     = true;
257
         }
258
       }
259

  
260
     if( mRemoveRotation )
261
       {
262
       mRemoveRotation=false;
263
       mNewObject.removeRotationNow();
264

  
265
       boolean solved = mNewObject.isSolved();
266

  
267
       if( solved && !mIsSolved )
268
         {
269
         if( RubikState.getCurrentState()==RubikState.SOLV )
270
           {
271
           RubikStateSolving solving = (RubikStateSolving)RubikState.SOLV.getStateClass();
272
           mNewRecord = solving.stopCounting((RubikActivity)mView.getContext());
273

  
274
           if( mNewRecord< 0 )
275
             {
276
             mNewRecord = -mNewRecord;
277
             mIsNewRecord = false;
278
             }
279
           else
280
             {
281
             mIsNewRecord = true;
282
             }
283
           }
284

  
285
         mCanDrag   = true;
286
         mCanRotate = false;
287
         mCanUI     = false;
288
         doEffectNow( BaseEffect.Type.WIN );
289
         }
290
       else
291
         {
292
         mCanRotate = true;
293
         mCanUI     = true;
294
         }
295

  
296
       mIsSolved = solved;
297
       }
298

  
299
     if( mChangeObject )
300
       {
301
       mChangeObject = false;
302
       mCanDrag      = false;
303
       mCanRotate    = false;
304
       mCanUI        = false;
305

  
306
       if( mNewObject==null )
307
         {
308
         createObjectNow(mNextObject, mNextSize, mNextMoves);
309
         doEffectNow( BaseEffect.Type.SIZECHANGE );
310
         }
311
       else
312
         {
313
         RubikObjectList list = mNewObject.getObjectList();
314
         int size = mNewObject.getSize();
315

  
316
         if (list!=mNextObject || mNextSize!=size)
317
           {
318
           createObjectNow(mNextObject, mNextSize, mNextMoves);
319
           doEffectNow( BaseEffect.Type.SIZECHANGE );
320
           }
321
         else
322
           {
323
           mNewObject.initializeObject(mNextMoves);
324
           }
325
         }
326
       }
327

  
328
     if( mSolveObject )
329
       {
330
       mSolveObject    = false;
331
       mCanDrag        = false;
332
       mCanRotate      = false;
333
       mCanUI          = false;
334
       doEffectNow( BaseEffect.Type.SOLVE );
335
       }
336

  
337
     if( mScrambleObject )
338
       {
339
       mScrambleObject = false;
340
       mCanDrag        = false;
341
       mCanRotate      = false;
342
       mCanUI          = false;
343
       mIsSolved       = false;
344
       RubikScores.getInstance().incrementNumPlays();
345
       doEffectNow( BaseEffect.Type.SCRAMBLE );
346
       }
56
     mView.getPostRender().postRender();
347 57
     }
348 58

  
349 59
///////////////////////////////////////////////////////////////////////////////////////////////////
......
351 61
   @Override
352 62
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
353 63
      {
354
      if( mNewObject!=null ) mNewObject.createTexture();
355

  
356
      mScreen.resize(width, height);
64
      mScreen.resize(width,height);
357 65
      mView.setScreenSize(width,height);
358

  
359
      if( mNewObject!=null )
360
        {
361
        mNewObject.recomputeScaleFactor(width,height);
362
        }
363

  
364
      mScreenHeight = height;
365
      mScreenWidth  = width;
66
      mView.getPostRender().setScreenSize(width,height);
366 67
      }
367 68

  
368 69
///////////////////////////////////////////////////////////////////////////////////////////////////
......
383 84
        }
384 85
      }
385 86

  
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387
// PUBLIC API
388 87
///////////////////////////////////////////////////////////////////////////////////////////////////
389 88

  
390
   public void effectFinished(final long effectID)
391
     {
392
     if( effectID == mRotationFinishedID )
393
       {
394
       mRemoveRotation = true;
395
       }
396
     else
397
       {
398
       for(int i=0; i<BaseEffect.Type.LENGTH; i++)
399
         {
400
         if( effectID == mEffectID[i] )
401
           {
402
           mCanRotate   = true;
403
           mCanDrag     = true;
404
           mCanUI       = true;
405

  
406
           if( i==BaseEffect.Type.SCRAMBLE.ordinal() )
407
             {
408
             final RubikActivity act = (RubikActivity)mView.getContext();
409

  
410
             act.runOnUiThread(new Runnable()
411
               {
412
               @Override
413
               public void run()
414
                 {
415
                 RubikState.switchState( act, RubikState.SOLV);
416
                 }
417
               });
418
             }
419

  
420
           if( i==BaseEffect.Type.WIN.ordinal() )
421
             {
422
             if( RubikState.getCurrentState()==RubikState.SOLV )
423
               {
424
               final RubikActivity act = (RubikActivity)mView.getContext();
425
               Bundle bundle = new Bundle();
426
               bundle.putLong("time", mNewRecord );
427

  
428
               if( mIsNewRecord )
429
                 {
430
                 RubikDialogNewRecord dialog = new RubikDialogNewRecord();
431
                 dialog.setArguments(bundle);
432
                 dialog.show( act.getSupportFragmentManager(), null);
433
                 }
434
               else
435
                 {
436
                 RubikDialogSolved dialog = new RubikDialogSolved();
437
                 dialog.setArguments(bundle);
438
                 dialog.show( act.getSupportFragmentManager(), null);
439
                 }
440
               }
441
             }
442

  
443
           break;
444
           }
445
         }
446
       }
447
     }
448

  
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450

  
451
   public RubikObject getObject()
452
     {
453
     return mNewObject;
454
     }
455

  
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457

  
458
   public RubikObject getOldObject()
459
     {
460
     return mOldObject;
461
     }
462

  
463
///////////////////////////////////////////////////////////////////////////////////////////////////
464

  
465
   public DistortedScreen getScreen()
89
   DistortedScreen getScreen()
466 90
     {
467 91
     return mScreen;
468 92
     }
469

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

  
472
   public int getNumScrambles()
473
     {
474
     return mScrambleObjectNum;
475
     }
476 93
}
src/main/java/org/distorted/magic/RubikSurfaceView.java
58 58
    private final Static4D CAMERA_POINT = new Static4D(0, 0, (float)Math.sqrt(3)*0.5f, 0);
59 59

  
60 60
    private RubikRenderer mRenderer;
61
    private RubikPostRender mPostRender;
61 62
    private RubikObjectMovement mMovement;
62 63
    private boolean mDragging, mBeginningRotation, mContinuingRotation;
63 64
    private int mScreenWidth, mScreenHeight, mScreenMin;
......
96 97
      return mRenderer;
97 98
      }
98 99

  
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

  
102
    RubikPostRender getPostRender()
103
      {
104
      return mPostRender;
105
      }
106

  
99 107
///////////////////////////////////////////////////////////////////////////////////////////////////
100 108

  
101 109
    void setQuatAccumulated()
......
177 185
        if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) )
178 186
          {
179 187
          mDragging           = false;
180
          mBeginningRotation  = mRenderer.canRotate();
188
          mBeginningRotation  = mPostRender.canRotate();
181 189
          mContinuingRotation = false;
182 190
          }
183 191
        else
184 192
          {
185
          mDragging           = mRenderer.canDrag();
193
          mDragging           = mPostRender.canDrag();
186 194
          mBeginningRotation  = false;
187 195
          mContinuingRotation = false;
188 196
          }
......
288 296

  
289 297
      if(!isInEditMode())
290 298
        {
291
        mRenderer = new RubikRenderer(this);
299
        mRenderer   = new RubikRenderer(this);
300
        mPostRender = new RubikPostRender(this);
292 301

  
293 302
        final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
294 303
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
......
323 332
                                           Static4D rotatedTouchPoint2= rotateVectorByInvertedQuat(touchPoint2, mQuatAccumulated);
324 333

  
325 334
                                           Static2D res = mMovement.newRotation(rotatedTouchPoint2);
326
                                           RubikObject object = mRenderer.getObject();
335
                                           RubikObject object = mPostRender.getObject();
327 336

  
328 337
                                           int axis = (int)res.get0();
329 338
                                           float offset = res.get1();
......
345 354
                                       else if( mContinuingRotation )
346 355
                                         {
347 356
                                         float angle = continueRotation(x-mStartRotX,y-mStartRotY);
348
                                         mRenderer.getObject().continueRotation(SWIPING_SENSITIVITY*angle);
357
                                         mPostRender.getObject().continueRotation(SWIPING_SENSITIVITY*angle);
349 358
                                         }
350 359
                                       else if( mDragging )
351 360
                                         {
352 361
                                         mTempCurrent.set(quatFromDrag(mX-x,y-mY));
353
                                         mRenderer.setQuatCurrentOnNextRender();
362
                                         mPostRender.setQuatCurrentOnNextRender();
354 363

  
355 364
                                         if( (mX-x)*(mX-x) + (mY-y)*(mY-y) > 1.0f/(DIRECTION_SENSITIVITY*DIRECTION_SENSITIVITY) )
356 365
                                           {
......
358 367
                                           mY = y;
359 368
                                           mTempAccumulated.set(quatMultiply(mQuatCurrent, mQuatAccumulated));
360 369
                                           mTempCurrent.set(0f, 0f, 0f, 1f);
361
                                           mRenderer.setQuatCurrentOnNextRender();
362
                                           mRenderer.setQuatAccumulatedOnNextRender();
370
                                           mPostRender.setQuatCurrentOnNextRender();
371
                                           mPostRender.setQuatAccumulatedOnNextRender();
363 372
                                           }
364 373
                                         }
365
                                       else if( mRenderer.canRotate() || mRenderer.canDrag() )
374
                                       else if( mPostRender.canRotate() || mPostRender.canDrag() )
366 375
                                         {
367 376
                                         setUpDragOrRotate(x,y);
368 377
                                         }
......
371 380
                                         {
372 381
                                         mTempAccumulated.set(quatMultiply(mQuatCurrent, mQuatAccumulated));
373 382
                                         mTempCurrent.set(0f, 0f, 0f, 1f);
374
                                         mRenderer.setQuatCurrentOnNextRender();
375
                                         mRenderer.setQuatAccumulatedOnNextRender();
383
                                         mPostRender.setQuatCurrentOnNextRender();
384
                                         mPostRender.setQuatAccumulatedOnNextRender();
376 385
                                         }
377 386

  
378 387
                                       if( mContinuingRotation )
379 388
                                         {
380
                                         mRenderer.finishRotation();
389
                                         mPostRender.finishRotation();
381 390
                                         }
382 391
                                       break;
383 392
         }
src/main/java/org/distorted/object/RubikObject.java
220 220
    rotationAngle.add(mRotationAngleFinal);
221 221
    }
222 222

  
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224
// TODO
225
// rotV : 0 --> VECTX, 1--> VECTY, 2 --> VECTZ
226
// rotRC: 01010 --> move the 2nd and 4th layer
227
// rotA : counterclockwise by rotA*90 degrees
228

  
229
	private boolean scheduleMultiRotation(int rotV, int rotRC, int rotA)
230
	  {
231
	  /*
232
		int index, tmp;
233

  
234
		if( numRotations>0 )
235
		  {
236
			if( rotVector!=rotV ) return false;
237

  
238
			index=0;
239
			tmp=rotRC;
240

  
241
			while( tmp!=0 )
242
			  {
243
				if( (tmp&0x1)==1 && rotAngle[index]!=0 ) return false;
244
				index++;
245
				tmp/=2;
246
			  }
247
		  }
248

  
249
		index=0;
250
		tmp=rotRC;
251
		rotVector = rotV;
252

  
253
		while( tmp!=0 )
254
		  {
255
			if( (tmp&0x1)==1 )
256
			  {
257
				rotAngle[index] = rotA*90;
258
				rotSpeed[index] = (int)(rotS/RubikWorld.hardwareSpeed);
259

  
260
				if( rotSpeed[index]<=0 && rotS>0 ) rotSpeed[index] = 1;
261
				if( rotSpeed[index]>=0 && rotS<0 ) rotSpeed[index] =-1;
262

  
263
				numRotations++;
264
			  }
265

  
266
			index++;
267
			tmp/=2;
268
		  }
269
    */
270
		return true;
271
	  }
272

  
273 223
///////////////////////////////////////////////////////////////////////////////////////////////////
274 224
// TODO
275 225

  
......
571 521
     mRotationAngleStatic.set0(0);
572 522
     }
573 523

  
574
///////////////////////////////////////////////////////////////////////////////////////////////////
575

  
576
  public boolean makeMove(String move)
577
    {
578
    int a1=move.charAt(1)-'0';
579
		int a2=move.charAt(2)-'0';
580
		int a3=move.charAt(3)-'0';
581

  
582
    int rotVector = (10*a1+a2)/32;
583
    int rotBitmap = (10*a1+a2)%32;
584
    int rotAngle  = 2-a3;
585

  
586
		return scheduleMultiRotation(rotVector, rotBitmap, rotAngle);
587
    }
588

  
589
///////////////////////////////////////////////////////////////////////////////////////////////////
590

  
591
  public boolean backMove(String move)
592
    {
593
    int a1=move.charAt(1)-'0';
594
		int a2=move.charAt(2)-'0';
595
		int a3=move.charAt(3)-'0';
596

  
597
    int rotVector = (10*a1+a2)/32;
598
    int rotBitmap = (10*a1+a2)%32;
599
    int rotAngle  = a3-2;
600

  
601
		return scheduleMultiRotation(rotVector, rotBitmap, rotAngle);
602
    }
603

  
604 524
///////////////////////////////////////////////////////////////////////////////////////////////////
605 525

  
606 526
  public void initializeObject(String moves)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff