Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedCreatorRenderer.java @ 3b8f5220

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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.bandaged;
21

    
22
import javax.microedition.khronos.egl.EGLConfig;
23
import javax.microedition.khronos.opengles.GL10;
24

    
25
import android.app.Activity;
26
import android.opengl.GLES31;
27
import android.opengl.GLSurfaceView;
28
import android.widget.Toast;
29

    
30
import org.distorted.dialogs.RubikDialogBandagedSave;
31
import org.distorted.library.effect.EffectType;
32
import org.distorted.library.effect.FragmentEffectBrightness;
33
import org.distorted.library.effect.PostprocessEffectBorder;
34
import org.distorted.library.main.DistortedEffects;
35
import org.distorted.library.main.DistortedFramebuffer;
36
import org.distorted.library.main.DistortedLibrary;
37
import org.distorted.library.main.DistortedNode;
38
import org.distorted.library.main.DistortedScreen;
39

    
40
import org.distorted.library.main.InternalOutputSurface;
41
import org.distorted.library.mesh.MeshBase;
42
import org.distorted.library.type.Static1D;
43
import org.distorted.library.type.Static3D;
44
import org.distorted.library.type.Static4D;
45
import org.distorted.objectlib.json.JsonWriter;
46
import org.distorted.objectlib.main.ShapeHexahedron;
47
import org.distorted.objectlib.main.TwistyObject;
48
import org.distorted.objectlib.objects.TwistyBandagedGeneric;
49
import org.json.JSONException;
50

    
51
import java.io.File;
52
import java.io.FileNotFoundException;
53
import java.io.IOException;
54
import java.nio.ByteBuffer;
55
import java.nio.ByteOrder;
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

    
59
public class BandagedCreatorRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
60
{
61
   public static final float BRIGHTNESS = 0.333f;
62
   private static final int RESET_DURATION = 1000;
63
   private static final float MAX_SIZE_CHANGE = 1.70f;
64
   private static final float MIN_SIZE_CHANGE = 0.50f;
65
   private static final float INIT_RATIO = 0.5f;
66

    
67
   private final BandagedCreatorView mView;
68
   private final DistortedScreen mScreen;
69
   private final Static3D mScale;
70
   private final Static4D mQuatT, mQuatA;
71
   private final int[] mObjSize;
72

    
73
   private BandagedCubit[] mCubits;
74
   private boolean mInitialPhase;
75
   private long mStartTime;
76
   private float mQuatX, mQuatY, mQuatZ, mQuatW;
77
   private int mX, mY, mZ, mNumCubits;
78
   private boolean mResetQuats, mSetQuatT, mResettingObject, mConnectingCubits, mCreatingCubits, mRescaling;
79
   private int mIndex1, mIndex2;
80
   private int mSaveIcon;
81
   private DistortedFramebuffer mFramebuffer;
82
   private String mPath;
83
   private boolean mCubitsCreated;
84
   private int mWidth, mHeight;
85
   private float mScaleValue, mObjectScreenRatio;
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
   BandagedCreatorRenderer(BandagedCreatorView v)
90
     {
91
     mQuatT = new Static4D(0,0,0,1);
92
     mQuatA = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
93

    
94
     mView = v;
95

    
96
     mResetQuats       = false;
97
     mSetQuatT         = false;
98
     mResettingObject  = false;
99
     mConnectingCubits = false;
100
     mCubitsCreated    = false;
101
     mCreatingCubits   = false;
102
     mRescaling        = false;
103

    
104
     mObjectScreenRatio= INIT_RATIO;
105
     mSaveIcon = -1;
106
     mObjSize  = new int[3];
107

    
108
     mScreen = new DistortedScreen();
109
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
110
     mScale = new Static3D(1,1,1);
111
     }
112

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

    
115
   private boolean isAdjacent(float[] pos1, float[] pos2)
116
     {
117
     int len1 = pos1.length/3;
118
     int len2 = pos2.length/3;
119

    
120
     for(int i=0; i<len1; i++)
121
       for(int j=0; j<len2; j++)
122
         {
123
         float d0 = pos1[3*i  ] - pos2[3*j  ];
124
         float d1 = pos1[3*i+1] - pos2[3*j+1];
125
         float d2 = pos1[3*i+2] - pos2[3*j+2];
126

    
127
         if( d0*d0 + d1*d1 + d2*d2 == 1 ) return true;
128
         }
129

    
130
     return false;
131
     }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
   private int computeNumCubits(int x, int y, int z)
136
     {
137
     return ( x<=1 || y<=1 || z<=1 ) ? x*y*z : x*y*z-(x-2)*(y-2)*(z-2);
138
     }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
   private void createCubits()
143
     {
144
     mCubits = new BandagedCubit[mNumCubits];
145
     int c=0;
146

    
147
     float begX = 0.5f*(1-mX);
148
     float begY = 0.5f*(1-mY);
149
     float begZ = 0.5f*(1-mZ);
150

    
151
     for(int x=0; x<mX; x++)
152
       for(int y=0; y<mY; y++)
153
          for(int z=0; z<mZ; z++)
154
            if( x==0 || x==mX-1 || y==0 || y==mY-1 || z==0 || z==mZ-1 )
155
              {
156
              float[] pos = new float[] { begX+x,begY+y,begZ+z };
157
              mCubits[c] = new BandagedCubit(pos,mX,mY,mZ,mQuatT,mQuatA,mScale,false);
158
              c++;
159
              }
160

    
161
     mView.setCubits(mCubits,mX,mY,mZ);
162
     }
163

    
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165

    
166
   private void resetObject()
167
     {
168
     mView.resetCubits();
169

    
170
     for(int c=0; c<mNumCubits; c++)
171
       {
172
       if( !mCubits[c].isAttached() )
173
         {
174
         mCubits[c].attach();
175
         mCubits[c].setUnmarked();
176
         mScreen.attach(mCubits[c].getNode());
177
         }
178
       if( mCubits[c].getPosition().length>3 )
179
         {
180
         mCubits[c].reset(mScaleValue);
181
         }
182
       }
183
     }
184

    
185
///////////////////////////////////////////////////////////////////////////////////////////////////
186

    
187
   @Override
188
   public void onDrawFrame(GL10 glUnused)
189
     {
190
     long time = System.currentTimeMillis();
191
     mScreen.render(time);
192

    
193
     if( mSetQuatT )
194
       {
195
       mSetQuatT = false;
196
       mQuatT.set(mQuatX,mQuatY,mQuatZ,mQuatW);
197
       }
198

    
199
     if( mResetQuats )
200
       {
201
       mResetQuats = false;
202

    
203
       float qx = mQuatT.get0();
204
       float qy = mQuatT.get1();
205
       float qz = mQuatT.get2();
206
       float qw = mQuatT.get3();
207

    
208
       float rx = mQuatA.get0();
209
       float ry = mQuatA.get1();
210
       float rz = mQuatA.get2();
211
       float rw = mQuatA.get3();
212

    
213
       float tx = rw*qx - rz*qy + ry*qz + rx*qw;
214
       float ty = rw*qy + rz*qx + ry*qw - rx*qz;
215
       float tz = rw*qz + rz*qw - ry*qx + rx*qy;
216
       float tw = rw*qw - rz*qz - ry*qy - rx*qx;
217

    
218
       mQuatT.set(0f, 0f, 0f, 1f);
219
       mQuatA.set(tx, ty, tz, tw);
220
       }
221

    
222
     if( mResettingObject )
223
       {
224
       boolean done = continueResetting(time);
225
       if( done ) mResettingObject = false;
226
       }
227

    
228
     if( mSaveIcon>=0 )
229
       {
230
       renderIcon(time); // for some reason we need to call render() twice here, otherwise the
231
       mSaveIcon++;      // icon turns out black. Probably some problem with binding the texture.
232
       }
233
     if( mSaveIcon>=2 )
234
       {
235
       saveIcon();
236
       mSaveIcon = -1;
237
       }
238

    
239
     if( mConnectingCubits )
240
       {
241
       mConnectingCubits = false;
242
       tryConnectingCubits(mIndex1,mIndex2);
243
       }
244

    
245
     if( mCreatingCubits )
246
       {
247
       mCreatingCubits = false;
248

    
249
       rescaleObject();
250

    
251
       if( mCubitsCreated )
252
         {
253
         createCubits();
254

    
255
         mScreen.detachAll();
256
         mView.resetCubits();
257

    
258
         for(int i=0; i<mNumCubits; i++)
259
           {
260
           mCubits[i].scaleMove(mScaleValue);
261
           DistortedNode node = mCubits[i].getNode();
262
           mScreen.attach(node);
263
           }
264
         }
265
       }
266

    
267
     if( mRescaling )
268
       {
269
       mRescaling = false;
270
       rescaleObject();
271
       for(int i=0; i<mNumCubits; i++) mCubits[i].scaleMove(mScaleValue);
272
       BandagedCreatorTouchControl control = mView.getTouchControl();
273
       control.setObjectRatio(mObjectScreenRatio);
274
       }
275
     }
276

    
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

    
279
   @Override
280
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
281
      {
282
      if( width!=mWidth || height!=mHeight )
283
        {
284
        mWidth = width;
285
        mHeight= height;
286
        rescaleObject();
287

    
288
        mScreen.detachAll();
289
        int touched = mView.getTouched();
290

    
291
        for(int i=0; i<mNumCubits; i++)
292
          if( mCubits[i].isAttached() )
293
            {
294
            mCubits[i].scaleMove(mScaleValue);
295
            if( touched==i ) mCubits[i].setMarked();
296
            else             mCubits[i].setUnmarked();
297
            DistortedNode node = mCubits[i].getNode();
298
            mScreen.attach(node);
299
            }
300

    
301
        mView.setScreenSize(width,height);
302
        mScreen.resize(width,height);
303
        }
304
      }
305

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

    
308
   @Override
309
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
310
      {
311
      DistortedLibrary.setMax(EffectType.VERTEX,0);
312
      MeshBase.setMaxEffComponents(120);
313

    
314
      FragmentEffectBrightness.enable();
315

    
316
      DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
317
      DistortedLibrary.setCull(true);
318

    
319
      if( mCubits==null )
320
        {
321
        createCubits();
322
        }
323
      else
324
        {
325
        for(int i=0; i<mNumCubits; i++) mCubits[i].recreateBitmap();
326
        }
327

    
328
      mCubitsCreated = true;
329
      mWidth = 0;
330
      mHeight= 0;
331
      }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

    
335
   public void distortedException(Exception ex)
336
     {
337
     android.util.Log.e("CREATOR", "unexpected exception: "+ex.getMessage() );
338
     }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
   public BandagedCubit[] getCubits()
343
     {
344
     return mCubits;
345
     }
346

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

    
349
   public DistortedScreen getScreen()
350
     {
351
     return mScreen;
352
     }
353

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

    
356
   void setConnecting(int index1, int index2)
357
     {
358
     mIndex1 = index1;
359
     mIndex2 = index2;
360
     mConnectingCubits = true;
361
     }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
   private void tryConnectingCubits(int index1, int index2)
366
     {
367
     if( index1!=index2 )
368
       {
369
       float[] pos1 = mCubits[index1].getPosition();
370
       float[] pos2 = mCubits[index2].getPosition();
371

    
372
       if( isAdjacent(pos1,pos2) )
373
         {
374
         mCubits[index2].join(pos1,mScaleValue);
375
         mCubits[index1].detach();
376
         mScreen.detach(mCubits[index1].getNode());
377
         }
378
       }
379
     }
380

    
381
///////////////////////////////////////////////////////////////////////////////////////////////////
382

    
383
   public Static4D getQuatAccu()
384
     {
385
     return mQuatA;
386
     }
387

    
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389

    
390
   public void setQuatTemp(float x, float y, float z, float w)
391
     {
392
     mQuatX = x;
393
     mQuatY = y;
394
     mQuatZ = z;
395
     mQuatW = w;
396

    
397
     mSetQuatT = true;
398
     }
399

    
400
///////////////////////////////////////////////////////////////////////////////////////////////////
401

    
402
   public void resetQuats()
403
     {
404
     mResetQuats = true;
405
     }
406

    
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408

    
409
   public boolean isBusy()
410
     {
411
     return mResettingObject;
412
     }
413

    
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415

    
416
   public void saveObject()
417
     {
418
     int numAttached=0;
419

    
420
     for(int i=0; i<mNumCubits; i++)
421
       if( mCubits[i].isAttached() ) numAttached++;
422

    
423
     float[][] pos = new float[numAttached][];
424
     int attached=0;
425

    
426
     for(int i=0; i<mNumCubits; i++)
427
       if( mCubits[i].isAttached() )
428
         {
429
         pos[attached++] = mCubits[i].getPosition();
430
         }
431

    
432
     TwistyBandagedGeneric.setPositions(pos);
433
     TwistyObject obj = new TwistyBandagedGeneric( mObjSize, TwistyObject.MESH_NICE, TwistyObject.MODE_NORM,
434
                                                   new Static4D(0,0,0,1), new Static3D(0,0,0), 1.0f, null );
435
     String name = obj.getShortName();
436
     BandagedCreatorActivity act = (BandagedCreatorActivity) mView.getContext();
437

    
438
     if( act.objectDoesntExist(name) && createObjectJson(obj,act) )
439
       {
440
       setupIconCreation(act);
441
       act.addObject(obj.getShortName());
442
       }
443
     }
444

    
445
///////////////////////////////////////////////////////////////////////////////////////////////////
446

    
447
   private boolean createObjectJson(TwistyObject object, Activity act)
448
     {
449
     final String name = object.getShortName()+"_object.json";
450
     File file = new File(act.getFilesDir(), name);
451
     String filename = file.getAbsolutePath();
452

    
453
     try
454
       {
455
       JsonWriter writer = JsonWriter.getInstance();
456
       String json = writer.createObjectString(object,24);
457
       writer.write(filename,json);
458
       return true;
459
       }
460
     catch(JSONException ex)
461
       {
462
       act.runOnUiThread(new Runnable()
463
         {
464
         public void run()
465
           {
466
           String message = "JSON Exception saving to \n\n"+filename+"\n\n failed:\n\n"+ex.getMessage();
467
           Toast.makeText(act,message,Toast.LENGTH_LONG).show();
468
           }
469
         });
470

    
471
       return false;
472
       }
473
     catch(FileNotFoundException ex)
474
       {
475
       act.runOnUiThread(new Runnable()
476
         {
477
         public void run()
478
           {
479
           String message = "FileNotFound exception saving to \n\n"+filename+"\n\n failed:\n\n"+ex.getMessage();
480
           Toast.makeText(act,message,Toast.LENGTH_LONG).show();
481
           }
482
         });
483

    
484
       return false;
485
       }
486
     catch(IOException ex)
487
       {
488
       act.runOnUiThread(new Runnable()
489
         {
490
         public void run()
491
           {
492
           String message = "IO exception saving to \n\n"+filename+"\n\n failed:\n\n"+ex.getMessage();
493
           Toast.makeText(act,message,Toast.LENGTH_LONG).show();
494
           }
495
         });
496

    
497
       return false;
498
       }
499
     }
500

    
501
///////////////////////////////////////////////////////////////////////////////////////////////////
502

    
503
   private int computeProjectionAngle()
504
     {
505
     float quot1 = mObjSize[2]/ (float)mObjSize[0];
506
     float quot2 = mObjSize[2]/ (float)mObjSize[1];
507
     float quot3 = mObjSize[0]/ (float)mObjSize[2];
508
     float quot4 = mObjSize[0]/ (float)mObjSize[1];
509

    
510
     float quot5 = Math.max(quot1,quot2);
511
     float quot6 = Math.max(quot3,quot4);
512
     float quot7 = Math.max(quot5,quot6);
513

    
514
          if( quot7<=1.0f ) return 120;
515
     else if( quot7<=1.5f ) return 90;
516
     else if( quot7<=2.0f ) return 60;
517
     else                   return 30;
518
     }
519

    
520
///////////////////////////////////////////////////////////////////////////////////////////////////
521

    
522
   private void setupIconCreation(Activity act)
523
     {
524
     final float R=1.0f;
525
     final int FBO_WIDTH  = (int)(R*720);
526
     final int FBO_HEIGHT = (int)(R*1280);
527
     final float OBJECT_SIZE = R*0.35f;
528

    
529
     TwistyObject obj = new TwistyBandagedGeneric( mObjSize, TwistyObject.MESH_NICE, TwistyObject.MODE_ICON,
530
                                                   ShapeHexahedron.DEFAULT_ROT, new Static3D(0,0,0), OBJECT_SIZE, null );
531

    
532
     DistortedEffects effects = obj.getObjectEffects();
533
     DistortedNode node = obj.getNode();
534

    
535
     if( mFramebuffer==null )
536
       {
537
       mFramebuffer = new DistortedFramebuffer(FBO_WIDTH,FBO_HEIGHT,1, InternalOutputSurface.DEPTH_NO_STENCIL);
538
       mFramebuffer.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
539
       }
540

    
541
     mFramebuffer.setProjection( computeProjectionAngle() ,0.1f);
542
     mFramebuffer.detachAll();
543
     mFramebuffer.attach(node);
544

    
545
     Static1D halo = new Static1D(5);
546
     Static4D color = new Static4D(0,0,0,1);
547
     PostprocessEffectBorder border = new PostprocessEffectBorder(halo,color);
548
     border.setHaloDepth(false);
549
     effects.apply(border);
550

    
551
     final String name = obj.getShortName()+".png";
552
     File file = new File(act.getFilesDir(), name);
553
     String filename = file.getAbsolutePath();
554

    
555
     mSaveIcon = 0;
556
     mPath = filename;
557
     }
558

    
559
///////////////////////////////////////////////////////////////////////////////////////////////////
560

    
561
   private void renderIcon(long time)
562
     {
563
     mFramebuffer.render(time);
564
     }
565

    
566
///////////////////////////////////////////////////////////////////////////////////////////////////
567

    
568
   private void saveIcon()
569
     {
570
     int fW = mFramebuffer.getWidth();
571
     int fH = mFramebuffer.getHeight();
572

    
573
     ByteBuffer buf = ByteBuffer.allocateDirect(fW*fH*4);
574
     buf.order(ByteOrder.LITTLE_ENDIAN);
575

    
576
     mFramebuffer.setAsReadFramebuffer(0);
577
     GLES31.glReadBuffer(GLES31.GL_COLOR_ATTACHMENT0);
578
     GLES31.glReadPixels( 0, 0, fW, fH, GLES31.GL_RGBA, GLES31.GL_UNSIGNED_BYTE, buf);
579
     BandagedCreatorWorkerThread.newBuffer(buf,fW,fH,6,mPath);
580
     GLES31.glBindFramebuffer(GLES31.GL_READ_FRAMEBUFFER, 0);
581

    
582
     mSaveIcon = -1;
583
     }
584

    
585
///////////////////////////////////////////////////////////////////////////////////////////////////
586

    
587
   void mulObjectRatio(float ratio)
588
     {
589
     mObjectScreenRatio *= ratio;
590

    
591
     if( mObjectScreenRatio>MAX_SIZE_CHANGE*INIT_RATIO) mObjectScreenRatio = MAX_SIZE_CHANGE*INIT_RATIO;
592
     if( mObjectScreenRatio<MIN_SIZE_CHANGE*INIT_RATIO) mObjectScreenRatio = MIN_SIZE_CHANGE*INIT_RATIO;
593

    
594
     mRescaling = true;
595
     }
596

    
597
///////////////////////////////////////////////////////////////////////////////////////////////////
598

    
599
   float getObjectRatio()
600
     {
601
     return mObjectScreenRatio;
602
     }
603

    
604
///////////////////////////////////////////////////////////////////////////////////////////////////
605

    
606
   private void rescaleObject()
607
     {
608
     final int size = mX>mY ? Math.max(mX, mZ) : Math.max(mY, mZ);
609
     final float Q = mObjectScreenRatio/size;
610
     mScaleValue = mWidth<mHeight ? Q*mWidth : Q*mHeight;
611
     mScale.set( mScaleValue,mScaleValue,mScaleValue );
612
     }
613

    
614
///////////////////////////////////////////////////////////////////////////////////////////////////
615

    
616
   public void changeObject(int x, int y, int z)
617
     {
618
     if( mX!=x || mY!=y || mZ!=z )
619
       {
620
       mX = x;
621
       mY = y;
622
       mZ = z;
623

    
624
       mObjSize[0] = mX;
625
       mObjSize[1] = mY;
626
       mObjSize[2] = mZ;
627

    
628
       mNumCubits = computeNumCubits(mX,mY,mZ);
629

    
630
       mCreatingCubits = true;
631
       }
632
     }
633

    
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635

    
636
   public void displaySavingDialog()
637
     {
638
     BandagedCreatorActivity act = (BandagedCreatorActivity)mView.getContext();
639
     RubikDialogBandagedSave saveDiag = new RubikDialogBandagedSave();
640
     saveDiag.show(act.getSupportFragmentManager(), null);
641
     }
642

    
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644

    
645
   public void setupReset()
646
     {
647
     mResettingObject = true;
648
     mInitialPhase    = true;
649
     mStartTime       = System.currentTimeMillis();
650
     }
651

    
652
///////////////////////////////////////////////////////////////////////////////////////////////////
653

    
654
   public boolean continueResetting(long time)
655
     {
656
     long diff = time-mStartTime;
657
     float quotient = ((float)diff)/RESET_DURATION;
658

    
659
     if( mInitialPhase && quotient>0.5f )
660
       {
661
       mInitialPhase=false;
662
       resetObject();
663
       }
664

    
665
     double angle = 2*Math.PI*quotient*quotient*(3-2*quotient);
666

    
667
     float sinA = (float)Math.sin(angle);
668
     float cosA = (float)Math.cos(angle);
669

    
670
     mQuatT.set(0, -sinA, 0, cosA);
671

    
672
     return quotient>1.0f;
673
     }
674

    
675
///////////////////////////////////////////////////////////////////////////////////////////////////
676

    
677
  public void touchCubit(int index)
678
    {
679
    if( index>=0 && index<mNumCubits && mCubits[index]!=null ) mCubits[index].setMarked();
680
    }
681

    
682
///////////////////////////////////////////////////////////////////////////////////////////////////
683

    
684
  public void untouchCubit(int index)
685
    {
686
    if( index>=0 && index<mNumCubits && mCubits[index]!=null ) mCubits[index].setUnmarked();
687
    }
688
}
(3-3/13)