Project

General

Profile

« Previous | Next » 

Revision c7e79b69

Added by Leszek Koltunski over 3 years ago

Progress with Dino Movement

View differences:

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

  
61
    // Where did we get this sqrt(3)/2 ? From the (default, i.e. 60 degrees - see InternalOutputSurface!)
62
    // FOV of the projection matrix of the Node onto the Screen.
63
    // Take a look how the CAMERA_POINT is used in onTouchEvent - (x,y) there are expressed in sort of
64
    // 'half-NDC' coordinates i.e. they range from +0.5 to -0.5; thus CAMERA_POINT also needs to be
65
    // in 'half-NDC'. Since in this coordinate system the height of the screen is equal to 1, then the
66
    // Z-distance from the center of the object to the camera is equal to (scrHeight/2)/tan(FOV/2) =
67
    // 0.5/tan(30) = sqrt(3)/2.
68
    // Why is the Z-distance between the camera and the object equal to (scrHeight/2)/tan(FOV/2)?
69
    // Because of the way the View part of the ModelView matrix is constructed in EffectQueueMatrix.send().
70
    private final Static4D CAMERA_POINT = new Static4D(0, 0, (float)Math.sqrt(3)*0.5f, 0);
61
    private final Static4D CAMERA_POINT = new Static4D(0, 0, 1, 0);
71 62

  
72 63
    private RubikRenderer mRenderer;
73 64
    private RubikPreRender mPreRender;
src/main/java/org/distorted/objects/RubikCube.java
53 53
  // the six axis that determine the faces
54 54
  static final Static3D[] FACE_AXIS = new Static3D[]
55 55
         {
56
           new Static3D(-1,0,0), new Static3D(1,0,0),
57
           new Static3D(0,-1,0), new Static3D(0,1,0),
58
           new Static3D(0,0,-1), new Static3D(0,0,1)
56
           new Static3D(1,0,0), new Static3D(-1,0,0),
57
           new Static3D(0,1,0), new Static3D(0,-1,0),
58
           new Static3D(0,0,1), new Static3D(0,0,-1)
59 59
         };
60 60

  
61 61
  private static final int[] FACE_COLORS = new int[]
src/main/java/org/distorted/objects/RubikDino.java
94 94
  // centers of the 12 edges. Must be in the same order like QUATs above.
95 95
  private static final Static3D[] CENTERS = new Static3D[]
96 96
         {
97
           new Static3D( 0.0f, 0.5f, 0.5f ),
98
           new Static3D( 0.5f, 0.0f, 0.5f ),
99
           new Static3D( 0.0f,-0.5f, 0.5f ),
100
           new Static3D(-0.5f, 0.0f, 0.5f ),
101
           new Static3D( 0.5f, 0.5f, 0.0f ),
102
           new Static3D( 0.5f,-0.5f, 0.0f ),
103
           new Static3D(-0.5f,-0.5f, 0.0f ),
104
           new Static3D(-0.5f, 0.5f, 0.0f ),
105
           new Static3D( 0.0f, 0.5f,-0.5f ),
106
           new Static3D( 0.5f, 0.0f,-0.5f ),
107
           new Static3D( 0.0f,-0.5f,-0.5f ),
108
           new Static3D(-0.5f, 0.0f,-0.5f )
97
           new Static3D( 0.0f, 1.5f, 1.5f ),
98
           new Static3D( 1.5f, 0.0f, 1.5f ),
99
           new Static3D( 0.0f,-1.5f, 1.5f ),
100
           new Static3D(-1.5f, 0.0f, 1.5f ),
101
           new Static3D( 1.5f, 1.5f, 0.0f ),
102
           new Static3D( 1.5f,-1.5f, 0.0f ),
103
           new Static3D(-1.5f,-1.5f, 0.0f ),
104
           new Static3D(-1.5f, 1.5f, 0.0f ),
105
           new Static3D( 0.0f, 1.5f,-1.5f ),
106
           new Static3D( 1.5f, 0.0f,-1.5f ),
107
           new Static3D( 0.0f,-1.5f,-1.5f ),
108
           new Static3D(-1.5f, 0.0f,-1.5f )
109 109
         };
110 110

  
111 111
  private static final int[] mFaceMap = {2,4, 4,0, 3,4, 4,1,
......
228 228

  
229 229
    MatrixEffectMove   moveEffect = new MatrixEffectMove  ( new Static3D(0.0f,SQ3*SQ2/12,SQ3/6) );
230 230
    MatrixEffectRotate rot1Effect = new MatrixEffectRotate( new Static1D(180+ANGLE_FACES/2), axis, cent);
231
    MatrixEffectScale  scalEffect = new MatrixEffectScale ( new Static3D(1.0f, SQ2/2, 0.5f) );
231
    MatrixEffectScale  scalEffect = new MatrixEffectScale ( new Static3D(3.0f, 3*SQ2/2, 1.5f) );
232 232
    MatrixEffectRotate rot2Effect = new MatrixEffectRotate( new Static1D(-45), axis, cent);
233 233

  
234 234
    mMesh.apply(moveEffect, 0xffffffff, 0);
......
241 241

  
242 242
  float getScreenRatio()
243 243
    {
244
    return 1.5f;
244
    return 0.5f;
245 245
    }
246 246

  
247 247
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff