Project

General

Profile

« Previous | Next » 

Revision 30bc2d91

Added by Leszek Koltunski almost 4 years ago

Fix movements of objects - before it really worked only when an object's FOV was about 60 degrees.

View differences:

src/main/java/org/distorted/main/RubikSurfaceView.java
57 57
    // Moving the finger by 0.3 of an inch will start a Rotation.
58 58
    private final static float ROTATION_SENSITIVITY = 0.3f;
59 59

  
60
    private final Static4D CAMERA_POINT = new Static4D(0, 0, 1, 0);
60
    private final Static4D CAMERA_POINT = new Static4D(0, 0, 0, 0);
61 61

  
62 62
    private RubikRenderer mRenderer;
63 63
    private RubikPreRender mPreRender;
......
305 305
        }
306 306
      else
307 307
        {
308
        TwistyObject object = mPreRender.getObject();
309
        CAMERA_POINT.set2( object.getCameraDist() );
310

  
308 311
        Static4D touchPoint = new Static4D(x, y, 0, 0);
309 312
        Static4D rotatedTouchPoint= rotateVectorByInvertedQuat(touchPoint, mQuat);
310 313
        Static4D rotatedCamera= rotateVectorByInvertedQuat(CAMERA_POINT, mQuat);
......
328 331
              mLastCubitFace = mMovement.getTouchedFace();
329 332
              float[] point = mMovement.getTouchedPoint3D();
330 333
              int color = solver.getCurrentColor();
331
              TwistyObject object = mPreRender.getObject();
332 334
              mLastCubit = object.getCubit(point);
333 335
              mPreRender.setTextureMap( mLastCubit, mLastCubitFace, color );
334 336
              mLastCubitColor = SolverMain.cubitIsLocked(object.getObjectList(), object.getNumLayers(), mLastCubit);
src/main/java/org/distorted/objects/MovementMinx.java
26 26
import static org.distorted.objects.FactoryCubit.SIN54;
27 27
import static org.distorted.objects.FactoryCubit.COS54;
28 28
import static org.distorted.objects.TwistyObject.SQ5;
29
import static org.distorted.objects.FactoryCubit.COS18;
30
import static org.distorted.objects.TwistyMegaminx.MEGA_D;
31 29

  
32 30
///////////////////////////////////////////////////////////////////////////////////////////////////
33 31

  
......
69 67
      }
70 68
    if( size==5 )
71 69
      {
72
      // TODO
70
      float quot = offset / DIST2D;
73 71

  
74
      float LEN = (0.5f-MEGA_D)*COS18/3;
75

  
76
      android.util.Log.e("mega", "offset = "+offset+" len="+LEN+" dist2D="+DIST2D);
77

  
78
      if( offset<LEN/2 ) return 0;
79
      if( offset<LEN   ) return 1;
72
      if( quot>0.00f && quot<=0.34f ) return 0;
73
      if( quot>0.34f && quot<=1.00f ) return 1;
74
      if( quot>1.00f && quot<=1.66f ) return 3;
75
      if( quot>1.66f && quot<=2.00f ) return 4;
80 76
      }
81 77

  
82 78
    return 0;
src/main/java/org/distorted/objects/TwistyObject.java
110 110
  private final Static3D mRotationAxis;
111 111
  private final Static3D mObjectScale;
112 112
  private final int[] mQuatDebug;
113
  private final float mCameraDist;
113 114
  private int mNumTexRows, mNumTexCols;
114 115
  private int mRotRowBitmap;
115 116
  private int mRotAxis;
......
205 206

  
206 207
    setupPosition(moves);
207 208

  
208
    setProjection( list.getFOV(), 0.1f);
209
    float fov = list.getFOV();
210
    double halfFOV = fov * (Math.PI/360);
211
    mCameraDist = 0.5f*NODE_RATIO / (float)Math.tan(halfFOV);
212

  
213
    setProjection( fov, 0.1f);
209 214
    }
210 215

  
211 216
///////////////////////////////////////////////////////////////////////////////////////////////////
......
759 764
    return speed> 1.2f ? NEAREST*(angle>0 ? 1:-1) : 0;
760 765
    }
761 766

  
767
///////////////////////////////////////////////////////////////////////////////////////////////////
768

  
769
  public float getCameraDist()
770
    {
771
    return mCameraDist;
772
    }
773

  
762 774
///////////////////////////////////////////////////////////////////////////////////////////////////
763 775

  
764 776
  public int getNodeSize()

Also available in: Unified diff