Project

General

Profile

Download (17.8 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / rubik / RubikSurfaceView.java @ af8b42cc

1 5b4a2d76 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2 8647eae2 Leszek Koltunski
// Copyright 2019 Leszek Koltunski                                                               //
3 5b4a2d76 Leszek Koltunski
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.examples.rubik;
21
22
import android.app.ActivityManager;
23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
25
import android.opengl.GLSurfaceView;
26 201376f3 Leszek Koltunski
import android.util.AttributeSet;
27 5b4a2d76 Leszek Koltunski
import android.view.MotionEvent;
28
29 e4c0057e Leszek Koltunski
import org.distorted.library.type.Static4D;
30
31 5b4a2d76 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33
class RubikSurfaceView extends GLSurfaceView
34
{
35 af8b42cc Leszek Koltunski
    // Moving the finger from the middle of the vertical screen to the right edge will rotate a
36
    // given face by SWIPING_SENSITIVITY/2 degrees.
37
    private final static int SWIPING_SENSITIVITY = 240;
38
39 840d83be Leszek Koltunski
    private final static int NONE   =-1;
40 c6223217 Leszek Koltunski
    private final static int FRONT  = 0;  // has to be 6 consecutive ints
41
    private final static int BACK   = 1;  // FRONT ... BOTTOM
42
    private final static int LEFT   = 2;  //
43
    private final static int RIGHT  = 3;  //
44
    private final static int TOP    = 4;  //
45
    private final static int BOTTOM = 5;  //
46 e4c0057e Leszek Koltunski
47 dc8979ba Leszek Koltunski
    static final int VECTX = 0;  //
48 af8b42cc Leszek Koltunski
    static final int VECTY = 1;  // don't change this
49 dc8979ba Leszek Koltunski
    static final int VECTZ = 2;  //
50
51
    private static final int[] VECT = {VECTX,VECTY,VECTZ};
52 840d83be Leszek Koltunski
53 d4374cd3 Leszek Koltunski
    private boolean mDragging, mBeginningRotation, mContinuingRotation;
54 5b4a2d76 Leszek Koltunski
    private int mX, mY;
55 94cc96ff Leszek Koltunski
    private Static4D mQuatCurrent, mQuatAccumulated;
56 c6223217 Leszek Koltunski
    private int mRotationVect;
57 5b4a2d76 Leszek Koltunski
    private RubikRenderer mRenderer;
58
59 8fbe9426 Leszek Koltunski
    private float[] mPoint, mCamera, mTouchPointCastOntoFace, mDiff, mTouchPoint; // all in screen space
60 840d83be Leszek Koltunski
    private int mLastTouchedFace;
61 18709ae0 Leszek Koltunski
    private int mScreenWidth, mScreenHeight, mScreenMin;
62
    private float mCameraDistance;
63 840d83be Leszek Koltunski
64 5b4a2d76 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
65
66 201376f3 Leszek Koltunski
    public RubikSurfaceView(Context context, AttributeSet attrs)
67 5b4a2d76 Leszek Koltunski
      {
68 201376f3 Leszek Koltunski
      super(context,attrs);
69 5b4a2d76 Leszek Koltunski
70 201376f3 Leszek Koltunski
      if(!isInEditMode())
71
        {
72
        mRotationVect = VECT[0];
73 dc8979ba Leszek Koltunski
74 201376f3 Leszek Koltunski
        mPoint = new float[3];
75
        mCamera= new float[3];
76
        mDiff  = new float[3];
77
        mTouchPoint = new float[3];
78
        mTouchPointCastOntoFace = new float[3];
79 c6223217 Leszek Koltunski
80 201376f3 Leszek Koltunski
        mScreenWidth = mScreenHeight = mScreenMin = 0;
81 18709ae0 Leszek Koltunski
82 201376f3 Leszek Koltunski
        mRenderer = new RubikRenderer(this);
83 af8b42cc Leszek Koltunski
        mRenderer.createCube(RubikActivity.DEFAULT_SIZE);
84 94cc96ff Leszek Koltunski
85 201376f3 Leszek Koltunski
        mQuatCurrent     = new Static4D(0,0,0,1);
86
        mQuatAccumulated = mRenderer.initializeQuat();
87 94cc96ff Leszek Koltunski
88 201376f3 Leszek Koltunski
        final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
89
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
90
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
91
        setRenderer(mRenderer);
92
        }
93 5b4a2d76 Leszek Koltunski
      }
94
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
97 e4c0057e Leszek Koltunski
    @Override
98
    public boolean onTouchEvent(MotionEvent event)
99 5b4a2d76 Leszek Koltunski
      {
100
      int action = event.getAction();
101
      int x = (int)event.getX();
102
      int y = (int)event.getY();
103
104
      switch(action)
105
         {
106 840d83be Leszek Koltunski
         case MotionEvent.ACTION_DOWN: mX = x;
107
                                       mY = y;
108
                                       mLastTouchedFace = faceTouched(x,y);
109
110 d4374cd3 Leszek Koltunski
                                       if( mLastTouchedFace != NONE )
111
                                         {
112
                                         mDragging           = false;
113
                                         mBeginningRotation  = mRenderer.canRotate();
114
                                         mContinuingRotation = false;
115
                                         }
116
                                       else
117
                                         {
118
                                         mDragging           = true;
119
                                         mBeginningRotation  = false;
120
                                         mContinuingRotation = false;
121
                                         }
122 5b4a2d76 Leszek Koltunski
                                       break;
123 94cc96ff Leszek Koltunski
         case MotionEvent.ACTION_MOVE: if( mDragging )
124
                                         {
125
                                         mQuatCurrent.set(quatFromDrag(mX-x,mY-y));
126
                                         mRenderer.setQuatCurrent(mQuatCurrent);
127
                                         }
128 d4374cd3 Leszek Koltunski
                                       if( mBeginningRotation )
129 840d83be Leszek Koltunski
                                         {
130 b62eb334 Leszek Koltunski
                                         int minimumDistToStartRotating = (mScreenMin*mScreenMin)/100;
131 840d83be Leszek Koltunski
132 b62eb334 Leszek Koltunski
                                         if( (mX-x)*(mX-x)+(mY-y)*(mY-y) > minimumDistToStartRotating )
133 840d83be Leszek Koltunski
                                           {
134 c6223217 Leszek Koltunski
                                           addNewRotation(x,y);
135 d4374cd3 Leszek Koltunski
                                           mBeginningRotation = false;
136
                                           mContinuingRotation= true;
137 840d83be Leszek Koltunski
                                           }
138
                                         }
139 d4374cd3 Leszek Koltunski
                                       else if( mContinuingRotation )
140 c6223217 Leszek Koltunski
                                         {
141
                                         continueRotation(x,y);
142
                                         }
143 e4c0057e Leszek Koltunski
                                       break;
144 d4374cd3 Leszek Koltunski
         case MotionEvent.ACTION_UP  : if( mDragging )
145
                                         {
146
                                         mQuatAccumulated.set(quatMultiply(mQuatCurrent, mQuatAccumulated));
147
                                         mQuatCurrent.set(0f, 0f, 0f, 1f);
148
                                         mRenderer.setQuatCurrent(mQuatCurrent);
149
                                         mRenderer.setQuatAccumulated(mQuatAccumulated);
150
                                         }
151
152
                                       if( mContinuingRotation )
153
                                         {
154
                                         finishRotation();
155
                                         }
156
157 5b4a2d76 Leszek Koltunski
                                       break;
158
         }
159
160
      return true;
161
      }
162
163 5d8a1d51 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
164
165
    void setNewCubeSize(int newCubeSize)
166
      {
167 af8b42cc Leszek Koltunski
      mRenderer.createCube(newCubeSize);
168 5d8a1d51 Leszek Koltunski
      }
169
170
///////////////////////////////////////////////////////////////////////////////////////////////////
171
172
    void scrambleCube()
173
      {
174 af8b42cc Leszek Koltunski
      mRenderer.scrambleCube();
175 5d8a1d51 Leszek Koltunski
      }
176
177 7f986357 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
178
179
    void setScreenSize(int width, int height)
180
      {
181
      mScreenWidth = width;
182
      mScreenHeight= height;
183
184
      mScreenMin = width<height ? width:height;
185
      }
186
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188
189 483ae94e Leszek Koltunski
    void setCameraDist(float distance)
190 7f986357 Leszek Koltunski
      {
191 483ae94e Leszek Koltunski
      mCameraDistance = distance;
192 7f986357 Leszek Koltunski
      }
193
194 840d83be Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
195
196 dc8979ba Leszek Koltunski
    private int faceTouched(int xTouch, int yTouch)
197 840d83be Leszek Koltunski
      {
198 dc8979ba Leszek Koltunski
      float cubeHalfSize= mRenderer.returnCubeSizeInScreenSpace()*0.5f;
199 840d83be Leszek Koltunski
200 dc8979ba Leszek Koltunski
      convertTouchPointToScreenSpace(xTouch,yTouch);
201
      convertCameraPointToScreenSpace();
202 840d83be Leszek Koltunski
203 dc8979ba Leszek Koltunski
      for(int face=FRONT; face<=BOTTOM; face++)
204 840d83be Leszek Koltunski
        {
205 dc8979ba Leszek Koltunski
        if( faceIsVisible(face,cubeHalfSize) )
206
          {
207 8fbe9426 Leszek Koltunski
          castTouchPointOntoFace(face,cubeHalfSize, mTouchPointCastOntoFace);
208 840d83be Leszek Koltunski
209 8fbe9426 Leszek Koltunski
          float qX= (mTouchPointCastOntoFace[0]+cubeHalfSize) / (2*cubeHalfSize);
210
          float qY= (mTouchPointCastOntoFace[1]+cubeHalfSize) / (2*cubeHalfSize);
211
          float qZ= (mTouchPointCastOntoFace[2]+cubeHalfSize) / (2*cubeHalfSize);
212 f843630b Leszek Koltunski
213 dc8979ba Leszek Koltunski
          if( qX<=1 && qX>=0 && qY<=1 && qY>=0 && qZ<=1 && qZ>=0 ) return face;
214
          }
215 f843630b Leszek Koltunski
        }
216 c6223217 Leszek Koltunski
217 dc8979ba Leszek Koltunski
      return NONE;
218
      }
219
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221
222
    private void addNewRotation(int x, int y)
223
      {
224
      float cubeHalfSize= mRenderer.returnCubeSizeInScreenSpace()*0.5f;
225
226
      convertTouchPointToScreenSpace(x,y);
227
      castTouchPointOntoFace(mLastTouchedFace,cubeHalfSize,mDiff);
228
229 8fbe9426 Leszek Koltunski
      mDiff[0] -= mTouchPointCastOntoFace[0];
230
      mDiff[1] -= mTouchPointCastOntoFace[1];
231
      mDiff[2] -= mTouchPointCastOntoFace[2];
232 dc8979ba Leszek Koltunski
233
      int xAxis = retFaceXaxis(mLastTouchedFace);
234
      int yAxis = retFaceYaxis(mLastTouchedFace);
235
      mRotationVect = (isVertical( mDiff[xAxis], mDiff[yAxis]) ? VECT[xAxis]:VECT[yAxis]);
236 8fbe9426 Leszek Koltunski
      float offset= (mTouchPointCastOntoFace[mRotationVect]+cubeHalfSize)/(2*cubeHalfSize);
237 dc8979ba Leszek Koltunski
238 8fbe9426 Leszek Koltunski
      mTouchPoint[0] = mPoint[0];
239
      mTouchPoint[1] = mPoint[1];
240
      mTouchPoint[2] = mPoint[2];
241 7f986357 Leszek Koltunski
242 af8b42cc Leszek Koltunski
      mRenderer.getCube().addNewRotation(mRotationVect,offset);
243 c6223217 Leszek Koltunski
      }
244
245 f843630b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
246
247
    private boolean isVertical(float x, float y)
248
      {
249
      return (y>x) ? (y>=-x) : (y< -x);
250
      }
251
252 c6223217 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
253
254
    private void continueRotation(int x, int y)
255
      {
256 dc8979ba Leszek Koltunski
      convertTouchPointToScreenSpace(x,y);
257 c6223217 Leszek Koltunski
258 8fbe9426 Leszek Koltunski
      mDiff[0] = mPoint[0]-mTouchPoint[0];
259
      mDiff[1] = mPoint[1]-mTouchPoint[1];
260
      mDiff[2] = mPoint[2]-mTouchPoint[2];
261 c6223217 Leszek Koltunski
262 dc8979ba Leszek Koltunski
      int xAxis= retFaceXaxis(mLastTouchedFace);
263
      int yAxis= retFaceYaxis(mLastTouchedFace);
264
      int sign = retFaceRotationSign(mLastTouchedFace);
265
      float angle = (mRotationVect==xAxis ? mDiff[yAxis] : -mDiff[xAxis]);
266 c6223217 Leszek Koltunski
267 af8b42cc Leszek Koltunski
      mRenderer.getCube().continueRotation(SWIPING_SENSITIVITY*sign*angle/mScreenMin);
268 c6223217 Leszek Koltunski
      }
269
270
///////////////////////////////////////////////////////////////////////////////////////////////////
271
272
    private void finishRotation()
273
      {
274
      mRenderer.finishRotation();
275
      }
276
277 e4c0057e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
278
// return quat1*quat2
279
280 8be29dfc Leszek Koltunski
    static Static4D quatMultiply( Static4D quat1, Static4D quat2 )
281 e4c0057e Leszek Koltunski
      {
282
      float qx = quat1.get1();
283
      float qy = quat1.get2();
284
      float qz = quat1.get3();
285
      float qw = quat1.get4();
286
287
      float rx = quat2.get1();
288
      float ry = quat2.get2();
289
      float rz = quat2.get3();
290
      float rw = quat2.get4();
291
292
      float tx = rw*qx - rz*qy + ry*qz + rx*qw;
293
      float ty = rw*qy + rz*qx + ry*qw - rx*qz;
294
      float tz = rw*qz + rz*qw - ry*qx + rx*qy;
295
      float tw = rw*qw - rz*qz - ry*qy - rx*qx;
296
297
      return new Static4D(tx,ty,tz,tw);
298
      }
299
300 d0418bda Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
301
// rotate 'vector' by quat^(-1)  ( i.e. return (quat^-1)*vector*quat )
302
303
    static Static4D rotateVectorByInvertedQuat(Static4D vector, Static4D quat)
304
      {
305
      float qx = quat.get1();
306
      float qy = quat.get2();
307
      float qz = quat.get3();
308
      float qw = quat.get4();
309
310
      Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
311
      Static4D tmp = quatMultiply(quatInverted,vector);
312
313
      return quatMultiply(tmp,quat);
314
      }
315
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317
// rotate 'vector' by quat  ( i.e. return quat*vector*(quat^-1) )
318
319
    static Static4D rotateVectorByQuat(Static4D vector, Static4D quat)
320
      {
321
      float qx = quat.get1();
322
      float qy = quat.get2();
323
      float qz = quat.get3();
324
      float qw = quat.get4();
325
326
      Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
327
      Static4D tmp = quatMultiply(quat,vector);
328
329
      return quatMultiply(tmp,quatInverted);
330
      }
331
332 e4c0057e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
333
334
    private Static4D quatFromDrag(float dragX, float dragY)
335
      {
336
      float axisX = dragY;  // inverted X and Y - rotation axis is
337 d0418bda Leszek Koltunski
      float axisY = dragX;  // perpendicular to (dragX,dragY)   Why not (-dragY, dragX) ? because Y axis is also inverted!
338 e4c0057e Leszek Koltunski
      float axisZ = 0;
339
      float axisL = (float)Math.sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ);
340
341
      if( axisL>0 )
342
        {
343
        axisX /= axisL;
344
        axisY /= axisL;
345
        axisZ /= axisL;
346
347 18709ae0 Leszek Koltunski
        float cosA = (float)Math.cos(axisL*Math.PI/mScreenMin);
348 e4c0057e Leszek Koltunski
        float sinA = (float)Math.sqrt(1-cosA*cosA);
349
350
        return new Static4D(axisX*sinA, axisY*sinA, axisZ*sinA, cosA);
351
        }
352
353
      return new Static4D(0f, 0f, 0f, 1f);
354
      }
355
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357
358 dc8979ba Leszek Koltunski
    private boolean faceIsVisible(int face, float cubeHalfSize)
359 e4c0057e Leszek Koltunski
      {
360 dc8979ba Leszek Koltunski
      int sign = retFaceSign(face);
361
      int zAxis= retFaceZaxis(face);
362 e4c0057e Leszek Koltunski
363 8fbe9426 Leszek Koltunski
      return sign*mCamera[zAxis] > cubeHalfSize;
364 dc8979ba Leszek Koltunski
      }
365 e4c0057e Leszek Koltunski
366 dc8979ba Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
367 e4c0057e Leszek Koltunski
368 dc8979ba Leszek Koltunski
    private void convertTouchPointToScreenSpace(int x, int y)
369
      {
370
      float halfScrWidth  = mScreenWidth *0.5f;
371
      float halfScrHeight = mScreenHeight*0.5f;
372
      Static4D touchPoint = new Static4D(x-halfScrWidth, halfScrHeight-y, 0, 0);
373
      Static4D rotatedTouchPoint= rotateVectorByInvertedQuat(touchPoint, mQuatAccumulated);
374
375 8fbe9426 Leszek Koltunski
      mPoint[0] = rotatedTouchPoint.get1();
376
      mPoint[1] = rotatedTouchPoint.get2();
377
      mPoint[2] = rotatedTouchPoint.get3();
378 e4c0057e Leszek Koltunski
      }
379
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381
382 dc8979ba Leszek Koltunski
    private void convertCameraPointToScreenSpace()
383 e4c0057e Leszek Koltunski
      {
384 dc8979ba Leszek Koltunski
      Static4D cameraPoint = new Static4D(0, 0, mCameraDistance, 0);
385
      Static4D rotatedCamera= rotateVectorByInvertedQuat(cameraPoint, mQuatAccumulated);
386 e4c0057e Leszek Koltunski
387 8fbe9426 Leszek Koltunski
      mCamera[0] = rotatedCamera.get1();
388
      mCamera[1] = rotatedCamera.get2();
389
      mCamera[2] = rotatedCamera.get3();
390 dc8979ba Leszek Koltunski
      }
391 e4c0057e Leszek Koltunski
392 dc8979ba Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
393 b62eb334 Leszek Koltunski
// given precomputed mCamera and mPoint, respectively camera and touch point positions in ScreenSpace,
394
// cast this touch point onto the surface defined by the 'face' and write the cast coords to 'output'.
395
// Center of the 'face' = (0,0), third coord always +- cubeHalfSize.
396 e4c0057e Leszek Koltunski
397 dc8979ba Leszek Koltunski
    private void castTouchPointOntoFace(int face, float cubeHalfSize, float[] output)
398
      {
399
      int sign = retFaceSign(face);
400
      int zAxis= retFaceZaxis(face);
401 8fbe9426 Leszek Koltunski
      float diff = mPoint[zAxis]-mCamera[zAxis];
402 e4c0057e Leszek Koltunski
403 8fbe9426 Leszek Koltunski
      float ratio =  diff!=0.0f ? (sign*cubeHalfSize-mCamera[zAxis])/diff : 0.0f;
404 e4c0057e Leszek Koltunski
405 8fbe9426 Leszek Koltunski
      output[0] = (mPoint[0]-mCamera[0])*ratio + mCamera[0];
406
      output[1] = (mPoint[1]-mCamera[1])*ratio + mCamera[1];
407
      output[2] = (mPoint[2]-mCamera[2])*ratio + mCamera[2];
408 e4c0057e Leszek Koltunski
      }
409 840d83be Leszek Koltunski
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411
412 dc8979ba Leszek Koltunski
    private int retFaceSign(int face)
413 840d83be Leszek Koltunski
      {
414 dc8979ba Leszek Koltunski
      return (face==FRONT || face==RIGHT || face==TOP) ? 1:-1;
415
      }
416
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418 840d83be Leszek Koltunski
419 dc8979ba Leszek Koltunski
    private int retFaceRotationSign(int face)
420
      {
421
      return (face==BACK || face==RIGHT || face==TOP) ? 1:-1;
422 c6223217 Leszek Koltunski
      }
423 840d83be Leszek Koltunski
424 c6223217 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
425 b62eb334 Leszek Koltunski
// retFace{X,Y,Z}axis: 3 functions which return which real AXIS gets mapped to which when we look
426
// directly at a given face. For example, when we look at the RIGHT face of the cube (with TOP still
427
// in the top) then the 'real' X axis becomes the 'Z' axis, thus retFaceZaxis(RIGHT) = VECTX.
428 c6223217 Leszek Koltunski
429 dc8979ba Leszek Koltunski
    private int retFaceXaxis(int face)
430 c6223217 Leszek Koltunski
      {
431 dc8979ba Leszek Koltunski
      switch(face)
432
        {
433
        case FRONT :
434
        case BACK  : return VECTX;
435
        case LEFT  :
436
        case RIGHT : return VECTZ;
437
        case TOP   :
438
        case BOTTOM: return VECTX;
439
        }
440 840d83be Leszek Koltunski
441 dc8979ba Leszek Koltunski
      return -1;
442 c6223217 Leszek Koltunski
      }
443 840d83be Leszek Koltunski
444 c6223217 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
445
446 dc8979ba Leszek Koltunski
    private int retFaceYaxis(int face)
447 c6223217 Leszek Koltunski
      {
448
      switch(face)
449
        {
450 dc8979ba Leszek Koltunski
        case FRONT :
451
        case BACK  : return VECTY;
452
        case LEFT  :
453
        case RIGHT : return VECTY;
454
        case TOP   :
455
        case BOTTOM: return VECTZ;
456 c6223217 Leszek Koltunski
        }
457
458 dc8979ba Leszek Koltunski
      return -1;
459 c6223217 Leszek Koltunski
      }
460
461
///////////////////////////////////////////////////////////////////////////////////////////////////
462
463 dc8979ba Leszek Koltunski
    private int retFaceZaxis(int face)
464 c6223217 Leszek Koltunski
      {
465
      switch(face)
466
        {
467
        case FRONT :
468 dc8979ba Leszek Koltunski
        case BACK  : return VECTZ;
469 c6223217 Leszek Koltunski
        case LEFT  :
470 dc8979ba Leszek Koltunski
        case RIGHT : return VECTX;
471 c6223217 Leszek Koltunski
        case TOP   :
472 dc8979ba Leszek Koltunski
        case BOTTOM: return VECTY;
473 c6223217 Leszek Koltunski
        }
474
475 dc8979ba Leszek Koltunski
      return -1;
476 840d83be Leszek Koltunski
      }
477 5b4a2d76 Leszek Koltunski
}